fix: persist notification preferences and clarify delivery controls

This commit is contained in:
2026-09-06 14:14:46 +03:00
parent 83df706631
commit a25dcb7a5d
8 changed files with 85 additions and 35 deletions
+13
View File
@@ -0,0 +1,13 @@
export function validateReminderPreferences(value) {
if(!value || typeof value!=='object' || Array.isArray(value))throw new Error('Bildirim ayarları geçersiz.');
for(const key of ['pushEnabled','quietEnabled'])if(typeof value[key]!=='boolean')throw new Error('Bildirim seçimini kontrol edin.');
for(const key of ['quietStart','quietEnd'])if(typeof value[key]!=='string'||!/^([01]\d|2[0-3]):[0-5]\d$/.test(value[key]))throw new Error('Sessiz saatleri saat:dakika biçiminde girin.');
return value;
}
export function quietNow(preferences,now=new Date()) {
if(!preferences?.quietEnabled)return false;
try {validateReminderPreferences(preferences);}catch{return true;}
const minute=text=>Number(text.slice(0,2))*60+Number(text.slice(3));
const start=minute(preferences.quietStart),end=minute(preferences.quietEnd),current=now.getHours()*60+now.getMinutes();
return start<=end ? current>=start&&current<end : current>=start||current<end;
}