Skip to content

Commit

Permalink
use TauriNoteProvider in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
falk-werner committed Jan 28, 2024
1 parent d52fe2e commit bb1e94e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down
47 changes: 47 additions & 0 deletions frontend/taurinoteprovider.js
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit bb1e94e

Please sign in to comment.