-
Notifications
You must be signed in to change notification settings - Fork 1
/
view.ts
46 lines (36 loc) · 896 Bytes
/
view.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { ItemView, WorkspaceLeaf } from "obsidian";
import Store from './store';
export default class DynasyncView extends ItemView {
status: HTMLElement;
store: Store;
constructor(leaf: WorkspaceLeaf, store: Store) {
super(leaf);
this.store = store;
}
getViewType(): string {
return 'dynasync';
}
getDisplayText(): string {
return "DynaSync";
}
async onOpen(): Promise<void> {
const dom = (this as any).contentEl as HTMLElement;
const button = dom.createEl('button', {
text: 'Sync',
});
button.onClickEvent(() => {
this.store.trigger('sync');
});
this.status = dom.createEl('div', {
text: '-',
});
this.store.on('status.changed', () => {
this.redraw();
});
this.redraw();
}
async redraw(): Promise<void> {
console.log('redraw');
this.status.setText(this.store.status);
}
}