MCPcopy Create free account
hub / github.com/churichard/notabase / deleteNote

Function deleteNote

lib/api/deleteNote.ts:4–16  ·  view source on GitHub ↗
(userId: string, noteId: string)

Source from the content-addressed store, hash-verified

2import { store } from 'lib/store';
3import supabase from 'lib/supabase';
4import { getUserAssetPaths } from 'lib/storage/userAssets';
5
6export default async function deleteNote(userId: string, noteId: string) {
7 const noteAssetPaths = await getNoteAssetPaths(userId, noteId);
8
9 // Update note titles in sidebar
10 store.getState().deleteNote(noteId);
11
12 const response = await supabase.from('notes').delete().eq('id', noteId);
13
14 if (!response.error && noteAssetPaths.length > 0) {
15 const referencedAssetPaths = await getReferencedAssetPaths(userId);
16 if (referencedAssetPaths) {
17 const assetPathsToDelete = noteAssetPaths.filter(
18 (path) => !referencedAssetPaths.has(path)
19 );

Callers 2

AppLayoutFunction · 0.85
useDeleteNoteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected