(note: NoteUpdate)
| 9 | } from 'lib/noteContent'; |
| 10 | |
| 11 | export type NoteUpdate = PickPartial< |
| 12 | Note, |
| 13 | 'user_id' | 'content' | 'title' | 'created_at' | 'updated_at' | 'visibility' |
| 14 | >; |
| 15 | |
| 16 | export default async function updateNote(note: NoteUpdate) { |
| 17 | // The size limit is deliberately left to the database trigger, which allows |
| 18 | // grandfathered oversized notes to shrink back under the limit |
| 19 | if (note.content && hasInlineImageData(note.content)) { |
| 20 | return { |
| 21 | data: null, |
| 22 | error: { code: NOTE_SIZE_ERROR_CODE, message: INLINE_IMAGE_DB_ERROR }, |
| 23 | }; |
| 24 | } |
| 25 | const response = await supabase |
| 26 | .from('notes') |
| 27 | .update({ ...note, updated_at: new Date().toISOString() }) |
| 28 | .eq('id', note.id) |
| 29 | .select('id, updated_at, visibility') |
| 30 | .single(); |
| 31 | |
| 32 | if (response.data) { |
no outgoing calls
no test coverage detected