Skip to content

Commit aaa995d

Browse files
committed
fix: dont show notifications
1 parent bba0b1f commit aaa995d

1 file changed

Lines changed: 11 additions & 35 deletions

File tree

Jellyfin.Plugin.Jellysleep/Web/jellysleep.js

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
function createSleepButton() {
114114
// If button already exists, exit
115115
if (document.querySelector('.btnJellysleep')) {
116-
return;
116+
return;
117117
}
118118

119119
// Create the sleep button to match Jellyfin's button structure
@@ -317,14 +317,13 @@
317317
})
318318
.then(response => {
319319
updateButtonAppearance();
320-
showNotification(`Sleep timer set for ${label}`);
321320
})
322321
.catch(error => {
323322
// Reset state on error
324323
isActive = false;
325324
currentTimerType = null;
326325
sleepTimerEndTime = null;
327-
showNotification('Failed to start sleep timer');
326+
console.error('[Jellysleep] Failed to start duration timer:', error);
328327
return;
329328
});
330329
}
@@ -344,13 +343,12 @@
344343
})
345344
.then(response => {
346345
updateButtonAppearance();
347-
showNotification(`Sleep timer set for ${label.toLowerCase()}`);
348346
})
349347
.catch(error => {
350348
// Reset state on error
351349
isActive = false;
352350
currentTimerType = null;
353-
showNotification('Failed to start sleep timer');
351+
console.error('[Jellysleep] Failed to start episode timer:', error);
354352
return;
355353
});
356354
}
@@ -372,12 +370,11 @@
372370
callPluginAPI('cancelTimer')
373371
.then(response => {
374372
updateButtonAppearance();
375-
showNotification('Sleep timer cancelled');
376373
})
377374
.catch(error => {
378375
// Still update UI even if API call fails
379376
updateButtonAppearance();
380-
showNotification('Sleep timer cancelled (locally)');
377+
console.error('[Jellysleep] Failed to cancel sleep timer:', error);
381378
});
382379
}
383380

@@ -399,46 +396,26 @@
399396
}
400397
}
401398

402-
/**
403-
* Show a notification message using Jellyfin's notification system
404-
* Fallback to console log if notification system is not available
405-
*/
406-
const showNotification = (message, type = 'info') => {
407-
try {
408-
if (window.Dashboard?.alert) {
409-
window.Dashboard.alert(message);
410-
} else if (window.Emby?.Notifications) {
411-
window.Emby.Notifications.show({ title: message, type: type, timeout: 3000 });
412-
} else {
413-
console.log(`Notification (${type}): ${message}`);
414-
}
415-
} catch (e) {
416-
console.error("Failed to show notification", e);
417-
console.log(`Notification (${type}): ${message}`);
418-
}
419-
};
420-
421399
const isVideoPage = () => location.hash.startsWith('#/video');
422400

423401
// if current page is a video page, add the sleep button to the player
424402
const updatePlayerUI = () => {
425-
if (isVideoPage()) {
426-
addSleepButtonToPlayer();
427-
}
403+
if (isVideoPage()) {
404+
addSleepButtonToPlayer();
405+
}
428406
};
429407

430-
431408
/**
432409
* Add the sleep button to the media player controls
433410
*/
434411
function addSleepButtonToPlayer() {
435412
// Check if the button already exists to avoid duplicates
436413
if (document.querySelector('.btnJellysleep')) {
437-
return;
414+
return;
438415
}
439416
const controlsContainer = document.querySelector('.videoOsdBottom .buttons.focuscontainer-x');
440417
if (!controlsContainer) {
441-
return;
418+
return;
442419
}
443420

444421
const sleepButtonElement = createSleepButton();
@@ -464,13 +441,12 @@
464441
// Monitor for changes in navigation and call updatePlayerUI
465442
const setupObserver = () => {
466443
const observer = new MutationObserver(() => {
467-
updatePlayerUI();
444+
updatePlayerUI();
468445
});
469446

470447
observer.observe(document.body, { childList: true, subtree: true, attributes: false });
471448
};
472449

473-
474450
/**
475451
* Initialize the plugin
476452
*/
@@ -574,4 +550,4 @@
574550
console.log('Is loading status:', isLoadingStatus);
575551
},
576552
};
577-
})();
553+
})();

0 commit comments

Comments
 (0)