mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +00:00
Fixed test notification and is now instant
This commit is contained in:
parent
718868f7b5
commit
c6a2c52365
1 changed files with 31 additions and 7 deletions
|
|
@ -164,9 +164,24 @@ const NotificationSettingsScreen = () => {
|
|||
|
||||
const handleTestNotification = async () => {
|
||||
try {
|
||||
// Cancel previous test notification if exists
|
||||
if (testNotificationId) {
|
||||
await notificationService.cancelNotification(testNotificationId);
|
||||
// Remove all previous test notifications before scheduling a new one
|
||||
const scheduled = notificationService.getScheduledNotifications?.() || [];
|
||||
const testNotifications = scheduled.filter(n => n.id.startsWith('test-notification-'));
|
||||
if (testNotifications.length > 0 && typeof notificationService.cancelNotification === 'function') {
|
||||
for (const n of testNotifications) {
|
||||
await notificationService.cancelNotification(n.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Temporarily override timeBeforeAiring to 0 for the test notification
|
||||
let originalTimeBeforeAiring: number | undefined = undefined;
|
||||
if (typeof notificationService.getSettings === 'function') {
|
||||
const currentSettings = await notificationService.getSettings();
|
||||
originalTimeBeforeAiring = currentSettings.timeBeforeAiring;
|
||||
if (typeof notificationService.updateSettings === 'function') {
|
||||
await notificationService.updateSettings({ timeBeforeAiring: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
const testNotification = {
|
||||
|
|
@ -176,15 +191,24 @@ const NotificationSettingsScreen = () => {
|
|||
episodeTitle: 'Test Episode',
|
||||
season: 1,
|
||||
episode: 1,
|
||||
releaseDate: new Date(Date.now() + 60000).toISOString(), // 1 minute from now
|
||||
releaseDate: new Date(Date.now() + 5000).toISOString(), // 5 seconds from now
|
||||
notified: false
|
||||
};
|
||||
|
||||
|
||||
const notificationId = await notificationService.scheduleEpisodeNotification(testNotification);
|
||||
|
||||
// Restore original timeBeforeAiring
|
||||
if (
|
||||
typeof notificationService.updateSettings === 'function' &&
|
||||
originalTimeBeforeAiring !== undefined
|
||||
) {
|
||||
await notificationService.updateSettings({ timeBeforeAiring: originalTimeBeforeAiring });
|
||||
}
|
||||
|
||||
if (notificationId) {
|
||||
setTestNotificationId(notificationId);
|
||||
setCountdown(60); // Start 60 second countdown
|
||||
Alert.alert('Success', 'Test notification scheduled for 1 minute from now');
|
||||
setCountdown(0); // No countdown for instant notification
|
||||
Alert.alert('Success', 'Test notification scheduled to fire instantly');
|
||||
} else {
|
||||
Alert.alert('Error', 'Failed to schedule test notification. Make sure notifications are enabled.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue