|
|
|
@ -8,15 +8,16 @@ import { exists } from "firebase/firestore/pipelines"; |
|
|
|
// Your web app's Firebase configuration
|
|
|
|
// Your web app's Firebase configuration
|
|
|
|
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
|
|
|
|
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
|
|
|
|
const firebaseConfig = { |
|
|
|
const firebaseConfig = { |
|
|
|
apiKey: "AIzaSyB3Yfrh18w5VNSb36LFHJHvegTSv_W1VOU", |
|
|
|
apiKey: "AIzaSyBPI9CDh0rnGnFAc4xSCfTC43oDDblEAsY", |
|
|
|
authDomain: "uc-23070-grayscale.firebaseapp.com", |
|
|
|
authDomain: "uc-23070-grayscale-backup.firebaseapp.com", |
|
|
|
projectId: "uc-23070-grayscale", |
|
|
|
projectId: "uc-23070-grayscale-backup", |
|
|
|
storageBucket: "uc-23070-grayscale.firebasestorage.app", |
|
|
|
storageBucket: "uc-23070-grayscale-backup.firebasestorage.app", |
|
|
|
messagingSenderId: "866564340708", |
|
|
|
messagingSenderId: "611635514938", |
|
|
|
appId: "1:866564340708:web:31eea78e6c56eeab6825f1", |
|
|
|
appId: "1:611635514938:web:897fdb87381a0e54166f03", |
|
|
|
measurementId: "G-NNY50B5T9F" |
|
|
|
measurementId: "G-F2TFEBMWCN" |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize Firebase
|
|
|
|
// Initialize Firebase
|
|
|
|
const app = initializeApp(firebaseConfig); |
|
|
|
const app = initializeApp(firebaseConfig); |
|
|
|
|
|
|
|
|
|
|
|
@ -79,8 +80,9 @@ export function lookatKeyword(keyword) { |
|
|
|
|
|
|
|
|
|
|
|
// Update the keyword document with the focused state
|
|
|
|
// Update the keyword document with the focused state
|
|
|
|
setDoc(keywordRef, { |
|
|
|
setDoc(keywordRef, { |
|
|
|
id: keyword.id, |
|
|
|
// id: keyword.id,
|
|
|
|
title: keyword.title, |
|
|
|
// title: keyword.title,
|
|
|
|
|
|
|
|
...keyword, |
|
|
|
updatedTime: new Date(), |
|
|
|
updatedTime: new Date(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -128,3 +130,18 @@ export async function getState(){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function onLookatChange(callback) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = getFirestore(app); |
|
|
|
|
|
|
|
const keywordRef = doc(collection(db, "lookat"), 'latest'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const unsubscribe = onSnapshot(keywordRef, (doc) => { |
|
|
|
|
|
|
|
if (doc.exists()) { |
|
|
|
|
|
|
|
callback(doc.data()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.log("No such document!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return unsubscribe; |
|
|
|
|
|
|
|
} |
|
|
|
|