Fix notifications logic and FCM Service Worker config
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
importScripts('https://www.gstatic.com/firebasejs/10.8.0/firebase-app-compat.js');
|
||||
importScripts('https://www.gstatic.com/firebasejs/10.8.0/firebase-messaging-compat.js');
|
||||
|
||||
// Configuração que o utilizador precisa substituir com os dados reais
|
||||
firebase.initializeApp({
|
||||
apiKey: "REPLACE_WITH_API_KEY",
|
||||
projectId: "REPLACE_WITH_PROJECT_ID",
|
||||
messagingSenderId: "REPLACE_WITH_MESSAGING_SENDER_ID",
|
||||
appId: "REPLACE_WITH_APP_ID"
|
||||
apiKey: "AIzaSyBBitFgNKnJ_3B0aqJgbbhGL_erufKd9lk",
|
||||
authDomain: "mycloset1-864c4.firebaseapp.com",
|
||||
projectId: "mycloset1-864c4",
|
||||
storageBucket: "mycloset1-864c4.firebasestorage.app",
|
||||
messagingSenderId: "219982610263",
|
||||
appId: "1:219982610263:web:0ebe67d9cf0e7d2753c812"
|
||||
});
|
||||
|
||||
const messaging = firebase.messaging();
|
||||
|
||||
12
src/App.jsx
12
src/App.jsx
@@ -675,13 +675,14 @@ export default function App() {
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
const now = new Date();
|
||||
const currentHour = String(now.getHours()).padStart(2, '0');
|
||||
const currentMinute = String(now.getMinutes()).padStart(2, '0');
|
||||
const currentTime = `${currentHour}:${currentMinute}`;
|
||||
|
||||
const todayStr = `${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`;
|
||||
|
||||
if (currentTime === dailyOutfitTime && lastNotifiedDate !== todayStr) {
|
||||
if (lastNotifiedDate !== todayStr) {
|
||||
const currentMins = now.getHours() * 60 + now.getMinutes();
|
||||
const [targetH, targetM] = dailyOutfitTime.split(':').map(Number);
|
||||
const targetMins = targetH * 60 + targetM;
|
||||
|
||||
if (currentMins >= targetMins) {
|
||||
const todaysLooks = getLooksForDayGlobal(todayStr);
|
||||
if (todaysLooks.length > 0) {
|
||||
const mainLook = todaysLooks[0];
|
||||
@@ -703,6 +704,7 @@ export default function App() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 30000); // Verifica a cada 30 segundos
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
|
||||
Reference in New Issue
Block a user