diff --git a/frontend/main.js b/frontend/main.js index ad29a55..5ded296 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -4,7 +4,7 @@ import "lineicons/web-font/lineicons.css" import { slider_attach } from "./slider.js" import { init_titlebar } from "./titlebar.js" import { init_settings } from "./settings.js" -import { FakeNoteProvider } from "./fakenoteprovider.js" +import { TauriNoteProvider } from "./taurinoteprovider.js" import { NoteList } from "./notelist.js" import { Editor } from "./editor.js" import { TagList } from "./taglist.js" @@ -30,7 +30,7 @@ document.querySelector("#toggle-mode").addEventListener("click", () => { }); -const noteProvider = new FakeNoteProvider(); +const noteProvider = new TauriNoteProvider(); const taglist_elemnt = document.querySelector("#taglist"); const taglist = new TagList(taglist_elemnt, noteProvider); diff --git a/frontend/taurinoteprovider.js b/frontend/taurinoteprovider.js new file mode 100644 index 0000000..8384454 --- /dev/null +++ b/frontend/taurinoteprovider.js @@ -0,0 +1,47 @@ +import { tauri } from "@tauri-apps/api"; +import { NoteProvider } from "./noteprovider"; + +class TauriNoteProvider extends NoteProvider { + async list() { + return await tauri.invoke("list"); + } + + async read(name) { + return await tauri.invoke("read", { name: name }); + } + + async create() { + return await tauri.invoke("create"); + } + + async rename(old_name, new_name) { + return await tauri.invoke("read", { + old_name: old_name, + new_name: new_name + }); + } + + async write(name, content) { + await tauri.invoke("write", { + name: name, + content: content + }); + } + + async remove(name) { + await tauri.invoke("remove", { name: name}); + } + + async read_tags(name) { + return await tauri.invoke("read_tags", { name: name}); + } + + async write_tags(name, tags) { + await tauri.invoke("write_tags", { + name: name, + tags: tags + }); + } +} + +export { TauriNoteProvider } \ No newline at end of file