fix: update saveReminder method to handle reset logic for reminders #52

Merged
bragaz_rexita merged 1 commits from wisdom into main 2026-04-30 09:55:20 +00:00
Showing only changes of commit 2c90b4defc - Show all commits

View File

@@ -31,7 +31,7 @@ const filePathLog = path.join(process.cwd(), 'scheduler', 'log.json');
class NotifikasiWaService {
async saveReminder(data) {
async saveReminder(data, isReset = false) {
console.log(`Reminder proses dibuat`);
try {
@@ -64,7 +64,12 @@ class NotifikasiWaService {
created_at: now.toISOString() // opsional (full timestamp)
};
if (!isReset) {
existing.push(newData);
} else {
existing = newData;
}
await fs.writeFile(filePath, JSON.stringify(existing, null, 2), 'utf-8');
@@ -268,7 +273,7 @@ class NotifikasiWaService {
return false;
}
this.saveReminder(newData);
this.saveReminder(newData, true);
await this.saveLogReminder({
message: `Reminder ${id} berhasil dihapus`
@@ -344,7 +349,7 @@ class NotifikasiWaService {
return true;
});
await this.saveReminder(data);
await this.saveReminder(data, true);
}, 60 * 1000);
}