Skip to content

Commit

Permalink
implement delete audiocast session on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Nov 27, 2024
1 parent 436bd60 commit bcabb28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 9 additions & 0 deletions api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,12 @@ async def save_uploaded_files_endpoint(files: list[UploadFile], sessionId: str =
"""
result = await UploadedFiles(session_id=sessionId)._save_sources(files)
return result


@app.delete("/delete-session/{sessionId}")
def delete_session_endpoint(sessionId: str):
"""
Delete audiocast session
"""
SessionManager._delete_session(sessionId)
return "Deleted"
4 changes: 4 additions & 0 deletions api/src/utils/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,7 @@ def on_snapshot(doc_snapshot, _changes, _read_time):
callback(info)

return doc_ref.on_snapshot(on_snapshot)

@staticmethod
def _delete_session(doc_id: str):
return DBManager()._delete_document(collections["audiora_sessions"], doc_id)
14 changes: 7 additions & 7 deletions app/src/lib/components/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import NewAudiocastButton from './NewAudiocastButton.svelte';
import { goto } from '$app/navigation';
import { browser } from '$app/environment';
// import { env } from '@env';
import { env } from '@env';
const dispatch = createEventDispatcher<{ clickItem: void }>();
const { openSettingsDrawer$ } = getAppContext();
Expand All @@ -66,9 +66,9 @@
localStorage.removeItem(`${SESSION_KEY}_${sessionId}`);
sidebarItems = getSidebarItems(getSessionItems());
// void fetch(`${env.API_BASE_URL}/delete-session/${sessionId}`, {
// method: 'DELETE'
// }).catch(() => {});
void fetch(`${env.API_BASE_URL}/delete-session/${sessionId}`, {
method: 'DELETE'
}).catch(() => void 0);
return goto('/', { invalidateAll: true, replaceState: true });
};
Expand Down Expand Up @@ -104,7 +104,7 @@
{/if}

<div class="flex w-full flex-col gap-y-1.5 pt-2" class:hidden={!inLast24Hrs.length}>
<div class="px-2 text-sm font-medium">Today</div>
<div class="px-2 text-sm font-semibold">Today</div>
{#each inLast24Hrs as item (item.sessionId)}
<SidebarItem
{item}
Expand All @@ -115,7 +115,7 @@
</div>

<div class="flex w-full flex-col gap-y-1.5 pt-6" class:hidden={!inLast7Days.length}>
<div class="px-2 text-sm font-medium">Last 7 days</div>
<div class="px-2 text-sm font-semibold">Last 7 days</div>
{#each inLast7Days as item (item.sessionId)}
<SidebarItem
{item}
Expand All @@ -126,7 +126,7 @@
</div>

<div class="flex w-full flex-col gap-y-1.5 pt-6" class:hidden={!inLast30Days.length}>
<div class="px-2 text-sm font-medium">Last month</div>
<div class="px-2 text-sm font-semibold">Last month</div>
{#each inLast30Days as item (item.sessionId)}
<SidebarItem
{item}
Expand Down

0 comments on commit bcabb28

Please sign in to comment.