mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 16:34:54 +00:00
ui changes, fixes
This commit is contained in:
@ -12,6 +12,8 @@ export const useCreateNote = () => {
|
||||
mutationKey: ["createNote"],
|
||||
mutationFn: async (note: Partial<IBrainDump>) => {
|
||||
try {
|
||||
const timestamp = firestore.FieldValue.serverTimestamp();
|
||||
|
||||
if (note.id) {
|
||||
const snapshot = await firestore()
|
||||
.collection("BrainDumps")
|
||||
@ -27,16 +29,22 @@ export const useCreateNote = () => {
|
||||
{
|
||||
...note,
|
||||
creatorId: currentUser?.uid,
|
||||
updatedAt: timestamp
|
||||
},
|
||||
{ merge: true }
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const newDoc = firestore().collection("BrainDumps").doc();
|
||||
await firestore()
|
||||
.collection("BrainDumps")
|
||||
.add({ ...note, id: newDoc.id, creatorId: currentUser?.uid });
|
||||
await newDoc.set({
|
||||
...note,
|
||||
id: newDoc.id,
|
||||
creatorId: currentUser?.uid,
|
||||
updatedAt: timestamp,
|
||||
createdAt: timestamp
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user