mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 16:25:51 +01:00
chore(monorepo): relocate client files
This commit is contained in:
39
apps/client/src/widgets/protected_note_switch.ts
Normal file
39
apps/client/src/widgets/protected_note_switch.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { EventData } from "../components/app_context.js";
|
||||
import type FNote from "../entities/fnote.js";
|
||||
import { t } from "../services/i18n.js";
|
||||
import protectedSessionService from "../services/protected_session.js";
|
||||
import SwitchWidget from "./switch.js";
|
||||
|
||||
export default class ProtectedNoteSwitchWidget extends SwitchWidget {
|
||||
doRender() {
|
||||
super.doRender();
|
||||
|
||||
this.switchOnName = t("protect_note.toggle-on");
|
||||
this.switchOnTooltip = t("protect_note.toggle-on-hint");
|
||||
|
||||
this.switchOffName = t("protect_note.toggle-off");
|
||||
this.switchOffTooltip = t("protect_note.toggle-off-hint");
|
||||
}
|
||||
|
||||
switchOn() {
|
||||
if (this.noteId) {
|
||||
protectedSessionService.protectNote(this.noteId, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
switchOff() {
|
||||
if (this.noteId) {
|
||||
protectedSessionService.protectNote(this.noteId, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
async refreshWithNote(note: FNote) {
|
||||
this.isToggled = note.isProtected;
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
||||
if (loadResults.isNoteReloaded(this.noteId)) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user