mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +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 () => {
|
const handleTestNotification = async () => {
|
||||||
try {
|
try {
|
||||||
// Cancel previous test notification if exists
|
// Remove all previous test notifications before scheduling a new one
|
||||||
if (testNotificationId) {
|
const scheduled = notificationService.getScheduledNotifications?.() || [];
|
||||||
await notificationService.cancelNotification(testNotificationId);
|
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 = {
|
const testNotification = {
|
||||||
|
|
@ -176,15 +191,24 @@ const NotificationSettingsScreen = () => {
|
||||||
episodeTitle: 'Test Episode',
|
episodeTitle: 'Test Episode',
|
||||||
season: 1,
|
season: 1,
|
||||||
episode: 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
|
notified: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const notificationId = await notificationService.scheduleEpisodeNotification(testNotification);
|
const notificationId = await notificationService.scheduleEpisodeNotification(testNotification);
|
||||||
|
|
||||||
|
// Restore original timeBeforeAiring
|
||||||
|
if (
|
||||||
|
typeof notificationService.updateSettings === 'function' &&
|
||||||
|
originalTimeBeforeAiring !== undefined
|
||||||
|
) {
|
||||||
|
await notificationService.updateSettings({ timeBeforeAiring: originalTimeBeforeAiring });
|
||||||
|
}
|
||||||
|
|
||||||
if (notificationId) {
|
if (notificationId) {
|
||||||
setTestNotificationId(notificationId);
|
setTestNotificationId(notificationId);
|
||||||
setCountdown(60); // Start 60 second countdown
|
setCountdown(0); // No countdown for instant notification
|
||||||
Alert.alert('Success', 'Test notification scheduled for 1 minute from now');
|
Alert.alert('Success', 'Test notification scheduled to fire instantly');
|
||||||
} else {
|
} else {
|
||||||
Alert.alert('Error', 'Failed to schedule test notification. Make sure notifications are enabled.');
|
Alert.alert('Error', 'Failed to schedule test notification. Make sure notifications are enabled.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue