remove console logs

This commit is contained in:
Peter Maquiran
2024-10-25 12:23:58 +01:00
parent 41dfb448dd
commit 53497407df
8 changed files with 98 additions and 86 deletions
+48 -48
View File
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Platform } from '@ionic/angular';
//import { LocalNotifications } from '@capacitor/local-notifications';
import { LocalNotifications } from '@capacitor/local-notifications';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
@@ -100,66 +100,66 @@ export class NativeNotificationService {
await this.cancelAllNotification();
// for (const event of events) {
for (const event of events) {
// const eventTime = new Date(event.start).getTime();
// const now = new Date().getTime();
const eventTime = new Date(event.start).getTime();
const now = new Date().getTime();
// // Schedule notifications for 1 hour before and 15 minutes before the event
// const oneHourBefore = eventTime - 60 * 60 * 1000;
// const fifteenMinutesBefore = eventTime - 15 * 60 * 1000;
// Schedule notifications for 1 hour before and 15 minutes before the event
const oneHourBefore = eventTime - 60 * 60 * 1000;
const fifteenMinutesBefore = eventTime - 15 * 60 * 1000;
// const timeDifference = eventTime - now;
// const oneHour = 60 * 60 * 1000; // 1 hour in milliseconds
// const fifteenMinutes = 15 * 60 * 1000; // 15 minutes in milliseconds
const timeDifference = eventTime - now;
const oneHour = 60 * 60 * 1000; // 1 hour in milliseconds
const fifteenMinutes = 15 * 60 * 1000; // 15 minutes in milliseconds
// console.log('notification to notify object', event)
// // if (timeDifference <= fifteenMinutes) {
console.log('notification to notify object', event)
// if (timeDifference <= fifteenMinutes) {
// // console.log({notification: event, e: '15 minutes'})
// // notifications.push({
// // title: 'Event Reminder',
// // body: `Reminder: ${event.Subject} starts in ${this.duration(event.start, new Date())} minutes.£`,
// // id: this.uuidTo32BitInt(event.event.id)
// // });
// // } else if (timeDifference <= oneHour) {
// console.log({notification: event, e: '15 minutes'})
// notifications.push({
// title: 'Event Reminder',
// body: `Reminder: ${event.Subject} starts in ${this.duration(event.start, new Date())} minutes.£`,
// id: this.uuidTo32BitInt(event.event.id)
// });
// } else if (timeDifference <= oneHour) {
// // console.log({notification: event, e: '1 hour.'})
// // notifications.push({
// // title: 'Event Reminder',
// // body: `Reminder: ${event.Subject} starts in ${this.duration(event.start, new Date())} hour.£`,
// // id: this.uuidTo32BitInt(event.id)
// // });
// // } else {
// // console.log("Event is more than 1 hour away.")
// console.log({notification: event, e: '1 hour.'})
// notifications.push({
// title: 'Event Reminder',
// body: `Reminder: ${event.Subject} starts in ${this.duration(event.start, new Date())} hour.£`,
// id: this.uuidTo32BitInt(event.id)
// });
// } else {
// console.log("Event is more than 1 hour away.")
// if (timeDifference >= fifteenMinutes) {
// notifications.push({
// title: 'Event Reminder',
// body: `Reminder: ${event.event.Subject} 15 minutes`,
// id: this.uuidTo32BitInt(event.id)+1,
// schedule: { at: new Date(fifteenMinutesBefore) },
// });
// console.log('15m', new Date(fifteenMinutesBefore))
if (timeDifference >= fifteenMinutes) {
notifications.push({
title: 'Event Reminder',
body: `Reminder: ${event.event.Subject} 15 minutes`,
id: this.uuidTo32BitInt(event.id)+1,
schedule: { at: new Date(fifteenMinutesBefore) },
});
console.log('15m', new Date(fifteenMinutesBefore))
// }
}
// if (timeDifference >= oneHour) {
// notifications.push({
// title: 'Event Reminder',
// body: `Reminder: ${event.event.Subject} 1 hour`,
// id: this.uuidTo32BitInt(event.id)+2,
// schedule: { at: new Date(oneHourBefore) },
// });
// console.log('1h', new Date(oneHourBefore))
// }
if (timeDifference >= oneHour) {
notifications.push({
title: 'Event Reminder',
body: `Reminder: ${event.event.Subject} 1 hour`,
id: this.uuidTo32BitInt(event.id)+2,
schedule: { at: new Date(oneHourBefore) },
});
console.log('1h', new Date(oneHourBefore))
}
// // }
// }
// }
}
// await LocalNotifications.schedule({ notifications });
await LocalNotifications.schedule({ notifications });
}
async eventNotification({eventId}) {