Skip to content
Open
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
72 changes: 37 additions & 35 deletions apps/desktop/src/store/tinybase/store/deleteSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,49 @@ export async function deleteSessionCascade(
indexes: ReturnType<typeof main.UI.useIndexes>,
sessionId: string,
): Promise<void> {
await fsSyncCommands.audioDelete(sessionId);

// Delete from TinyBase first
if (!indexes) {
store.delRow("sessions", sessionId);
return;
}
} else {
store.transaction(() => {
const transcriptIds = indexes.getSliceRowIds(
main.INDEXES.transcriptBySession,
sessionId,
);

store.transaction(() => {
const transcriptIds = indexes.getSliceRowIds(
main.INDEXES.transcriptBySession,
sessionId,
);
for (const transcriptId of transcriptIds) {
store.delRow("transcripts", transcriptId);
}

for (const transcriptId of transcriptIds) {
store.delRow("transcripts", transcriptId);
}
deleteByIndex(
store,
indexes,
main.INDEXES.sessionParticipantsBySession,
sessionId,
"mapping_session_participant",
);
deleteByIndex(
store,
indexes,
main.INDEXES.tagSessionsBySession,
sessionId,
"mapping_tag_session",
);
deleteByIndex(
store,
indexes,
main.INDEXES.enhancedNotesBySession,
sessionId,
"enhanced_notes",
);

deleteByIndex(
store,
indexes,
main.INDEXES.sessionParticipantsBySession,
sessionId,
"mapping_session_participant",
);
deleteByIndex(
store,
indexes,
main.INDEXES.tagSessionsBySession,
sessionId,
"mapping_tag_session",
);
deleteByIndex(
store,
indexes,
main.INDEXES.enhancedNotesBySession,
sessionId,
"enhanced_notes",
);
store.delRow("sessions", sessionId);
});
}

store.delRow("sessions", sessionId);
});
// Explicitly delete the session folder from filesystem
// This replaces reliance on orphan cleanup for session deletion
await fsSyncCommands.deleteSessionFolder(sessionId);
}

export function useDeleteSession() {
Expand Down
Loading