mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
git-subtree-dir: apps/web git-subtree-mainline:eaa6d2276agit-subtree-split:459af9d46a
20 lines
632 B
Plaintext
20 lines
632 B
Plaintext
@val external localStorage: {..} = "localStorage"
|
|
|
|
let storageKey = (courseId: string, lessonId: string) =>
|
|
`annotation:${courseId}:${lessonId}`
|
|
|
|
let saveNote = (courseId: string, lessonId: string, note: string) => {
|
|
let key = storageKey(courseId, lessonId)
|
|
localStorage["setItem"](key, note)
|
|
}
|
|
|
|
let loadNote = (courseId: string, lessonId: string) => {
|
|
let key = storageKey(courseId, lessonId)
|
|
let value: Nullable.t<string> = localStorage["getItem"](key)
|
|
Nullable.toOption(value)
|
|
}
|
|
|
|
let deleteNote = (courseId: string, lessonId: string) => {
|
|
let key = storageKey(courseId, lessonId)
|
|
localStorage["removeItem"](key)
|
|
} |