Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,26 @@ export function EventChip({ sessionId }: EventChipProps) {
return eventId;
},
onSuccess: async (assignedEventId) => {
event.refetch();
eventsInPastWithoutAssignedSession.refetch();
// Optimistically update the event query cache to prevent race conditions
const eventDetails = await dbCommands.getEvent(assignedEventId);
if (eventDetails) {
queryClient.setQueryData(["event", sessionId], { ...eventDetails, meetingLink: null });
}

// Wait for critical queries to complete before invalidating sessions
await Promise.all([
event.refetch(),
eventsInPastWithoutAssignedSession.refetch(),
]);

// Only invalidate sessions cache after individual queries are settled
queryClient.invalidateQueries({ queryKey: ["sessions"] });

if (assignedEventId && updateTitle && currentSessionDetails) {
if (assignedEventId && updateTitle && currentSessionDetails && eventDetails?.name) {
try {
const eventDetails = await dbCommands.getEvent(assignedEventId);

if (eventDetails?.name) {
if (!currentSessionDetails.title?.trim()) {
updateTitle(eventDetails.name);
queryClient.invalidateQueries({ queryKey: ["session", sessionId] });
}
if (!currentSessionDetails.title?.trim()) {
updateTitle(eventDetails.name);
queryClient.invalidateQueries({ queryKey: ["session", sessionId] });
}
} catch (error) {
console.error("Failed to update session title after event assignment:", error);
Expand All @@ -119,9 +126,17 @@ export function EventChip({ sessionId }: EventChipProps) {
mutationFn: async () => {
await dbCommands.setSessionEvent(sessionId, null);
},
onSuccess: () => {
event.refetch();
eventsInPastWithoutAssignedSession.refetch();
onSuccess: async () => {
// Optimistically clear the event query cache
queryClient.setQueryData(["event", sessionId], null);

// Wait for critical queries to complete before invalidating sessions
await Promise.all([
event.refetch(),
eventsInPastWithoutAssignedSession.refetch(),
]);

// Only invalidate sessions cache after individual queries are settled
queryClient.invalidateQueries({ queryKey: ["sessions"] });
setIsEventSelectorOpen(false);
},
Expand All @@ -141,9 +156,6 @@ export function EventChip({ sessionId }: EventChipProps) {
const handleSelectEvent = async (eventIdToLink: string) => {
assignEvent.mutate(eventIdToLink, {
onSuccess: () => {
event.refetch();
eventsInPastWithoutAssignedSession.refetch();
queryClient.invalidateQueries({ queryKey: ["sessions"] });
setIsEventSelectorOpen(false);
},
onError: (error) => {
Expand Down
14 changes: 13 additions & 1 deletion apps/desktop/src/components/left-sidebar/notes-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ export default function NotesList({ ongoingSessionId, filter }: NotesListProps)
end: to,
limit: 100,
});
sessions.forEach(insertSession);
// Defensively insert sessions - don't overwrite existing data that might be more recent
sessions.forEach((session) => {
const existingStore = sessionsStore[session.id];
// Only insert if session doesn't exist or existing data is older
if (!existingStore) {
insertSession(session);
} else {
const existingSession = existingStore.getState().session;
if (new Date(existingSession.visited_at) <= new Date(session.visited_at)) {
insertSession(session);
}
}
});

const sessionWithEvents = await Promise.all(sessions.map(async (session) => {
const event = await dbCommands.sessionGetEvent(session.id);
Expand Down
16 changes: 8 additions & 8 deletions apps/desktop/src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ msgid "Apple"
msgstr "Apple"

#: src/components/toolbar/buttons/delete-note-button.tsx:43
#: src/components/left-sidebar/notes-list.tsx:255
#: src/components/left-sidebar/notes-list.tsx:262
msgid "Are you sure you want to delete this note?"
msgstr "Are you sure you want to delete this note?"

Expand Down Expand Up @@ -502,7 +502,7 @@ msgstr "Custom Endpoint"

#: src/components/settings/views/template.tsx:86
#: src/components/settings/views/team.tsx:165
#: src/components/left-sidebar/notes-list.tsx:322
#: src/components/left-sidebar/notes-list.tsx:329
msgid "Delete"
msgstr "Delete"

Expand Down Expand Up @@ -684,7 +684,7 @@ msgstr "Jargons"
msgid "Job title"
msgstr "Job title"

#: src/components/editor-area/note-header/chips/event-chip.tsx:229
#: src/components/editor-area/note-header/chips/event-chip.tsx:241
msgid "Join meeting"
msgstr "Join meeting"

Expand Down Expand Up @@ -716,7 +716,7 @@ msgstr "Live summary of the meeting"
msgid "Loading available models..."
msgstr "Loading available models..."

#: src/components/editor-area/note-header/chips/event-chip.tsx:277
#: src/components/editor-area/note-header/chips/event-chip.tsx:289
msgid "Loading events..."
msgstr "Loading events..."

Expand Down Expand Up @@ -778,7 +778,7 @@ msgstr "My Templates"
msgid "New note"
msgstr "New note"

#: src/components/left-sidebar/notes-list.tsx:299
#: src/components/left-sidebar/notes-list.tsx:306
#: src/components/left-sidebar/events-list.tsx:181
msgid "New window"
msgstr "New window"
Expand All @@ -795,7 +795,7 @@ msgstr "No members found"
#~ msgid "No models available for this endpoint."
#~ msgstr "No models available for this endpoint."

#: src/components/editor-area/note-header/chips/event-chip.tsx:302
#: src/components/editor-area/note-header/chips/event-chip.tsx:314
msgid "No past events found."
msgstr "No past events found."

Expand Down Expand Up @@ -1131,12 +1131,12 @@ msgstr "User:"
msgid "username"
msgstr "username"

#: src/components/left-sidebar/notes-list.tsx:310
#: src/components/left-sidebar/notes-list.tsx:317
msgid "View calendar"
msgstr "View calendar"

#: src/components/left-sidebar/events-list.tsx:193
#: src/components/editor-area/note-header/chips/event-chip.tsx:234
#: src/components/editor-area/note-header/chips/event-chip.tsx:246
msgid "View in calendar"
msgstr "View in calendar"

Expand Down
16 changes: 8 additions & 8 deletions apps/desktop/src/locales/ko/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ msgid "Apple"
msgstr ""

#: src/components/toolbar/buttons/delete-note-button.tsx:43
#: src/components/left-sidebar/notes-list.tsx:255
#: src/components/left-sidebar/notes-list.tsx:262
msgid "Are you sure you want to delete this note?"
msgstr ""

Expand Down Expand Up @@ -502,7 +502,7 @@ msgstr ""

#: src/components/settings/views/template.tsx:86
#: src/components/settings/views/team.tsx:165
#: src/components/left-sidebar/notes-list.tsx:322
#: src/components/left-sidebar/notes-list.tsx:329
msgid "Delete"
msgstr ""

Expand Down Expand Up @@ -684,7 +684,7 @@ msgstr ""
msgid "Job title"
msgstr ""

#: src/components/editor-area/note-header/chips/event-chip.tsx:229
#: src/components/editor-area/note-header/chips/event-chip.tsx:241
msgid "Join meeting"
msgstr ""

Expand Down Expand Up @@ -716,7 +716,7 @@ msgstr ""
msgid "Loading available models..."
msgstr ""

#: src/components/editor-area/note-header/chips/event-chip.tsx:277
#: src/components/editor-area/note-header/chips/event-chip.tsx:289
msgid "Loading events..."
msgstr ""

Expand Down Expand Up @@ -778,7 +778,7 @@ msgstr ""
msgid "New note"
msgstr ""

#: src/components/left-sidebar/notes-list.tsx:299
#: src/components/left-sidebar/notes-list.tsx:306
#: src/components/left-sidebar/events-list.tsx:181
msgid "New window"
msgstr ""
Expand All @@ -795,7 +795,7 @@ msgstr ""
#~ msgid "No models available for this endpoint."
#~ msgstr ""

#: src/components/editor-area/note-header/chips/event-chip.tsx:302
#: src/components/editor-area/note-header/chips/event-chip.tsx:314
msgid "No past events found."
msgstr ""

Expand Down Expand Up @@ -1131,12 +1131,12 @@ msgstr ""
msgid "username"
msgstr ""

#: src/components/left-sidebar/notes-list.tsx:310
#: src/components/left-sidebar/notes-list.tsx:317
msgid "View calendar"
msgstr ""

#: src/components/left-sidebar/events-list.tsx:193
#: src/components/editor-area/note-header/chips/event-chip.tsx:234
#: src/components/editor-area/note-header/chips/event-chip.tsx:246
msgid "View in calendar"
msgstr ""

Expand Down