rename previous hook
This commit is contained in:
23
src/modules/note/cache/prepareNoteCache.ts
vendored
Normal file
23
src/modules/note/cache/prepareNoteCache.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { data } from '@/data/data'
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { Note } from '@/modules/note/models/Note'
|
||||
|
||||
export const prepareNoteCache = (sha: string) => {
|
||||
const noteId = data.generateId(DataType.Note, sha)
|
||||
const getCachedNote = async () => data.get<DataType.Note, Note>(noteId)
|
||||
|
||||
const saveCacheNote = async (content: string) => {
|
||||
const newNote: Note = {
|
||||
_id: noteId,
|
||||
$type: DataType.Note,
|
||||
content
|
||||
}
|
||||
|
||||
await data.update(newNote)
|
||||
}
|
||||
|
||||
return {
|
||||
getCachedNote,
|
||||
saveCacheNote
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user