mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
proper handling of deleted notes
This commit is contained in:
parent
978575498c
commit
cb168218fb
@ -70,6 +70,10 @@ function mouseLeaveHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function renderTooltip(note, noteComplement) {
|
async function renderTooltip(note, noteComplement) {
|
||||||
|
if (note.isDeleted) {
|
||||||
|
return '<div>Note has been deleted.</div>';
|
||||||
|
}
|
||||||
|
|
||||||
const attributes = await note.getAttributes();
|
const attributes = await note.getAttributes();
|
||||||
|
|
||||||
let content = '';
|
let content = '';
|
||||||
|
@ -25,19 +25,28 @@ class TabContext extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setNote(inputNotePath, triggerSwitchEvent = true) {
|
async setNote(inputNotePath, triggerSwitchEvent = true) {
|
||||||
const notePath = await treeService.resolveNotePath(inputNotePath);
|
const noteId = treeService.getNoteIdFromNotePath(inputNotePath);
|
||||||
|
let notePath;
|
||||||
|
|
||||||
if (!notePath) {
|
if ((await treeCache.getNote(noteId)).isDeleted) {
|
||||||
console.error(`Cannot resolve note path ${inputNotePath}`);
|
// no point in trying to resolve canonical notePath
|
||||||
return;
|
notePath = inputNotePath;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
notePath = await treeService.resolveNotePath(inputNotePath);
|
||||||
|
|
||||||
if (notePath === this.notePath) {
|
if (!notePath) {
|
||||||
return;
|
console.error(`Cannot resolve note path ${inputNotePath}`);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (await hoistedNoteService.checkNoteAccess(notePath) === false) {
|
if (notePath === this.notePath) {
|
||||||
return; // note is outside of hoisted subtree and user chose not to unhoist
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await hoistedNoteService.checkNoteAccess(notePath) === false) {
|
||||||
|
return; // note is outside of hoisted subtree and user chose not to unhoist
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.triggerEvent('beforeNoteSwitch', {tabContext: this});
|
await this.triggerEvent('beforeNoteSwitch', {tabContext: this});
|
||||||
@ -45,7 +54,7 @@ class TabContext extends Component {
|
|||||||
utils.closeActiveDialog();
|
utils.closeActiveDialog();
|
||||||
|
|
||||||
this.notePath = notePath;
|
this.notePath = notePath;
|
||||||
this.noteId = treeService.getNoteIdFromNotePath(notePath);
|
this.noteId = noteId;
|
||||||
|
|
||||||
this.autoBookDisabled = false;
|
this.autoBookDisabled = false;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import BookTypeWidget from "./type_widgets/book.js";
|
|||||||
import appContext from "../services/app_context.js";
|
import appContext from "../services/app_context.js";
|
||||||
import keyboardActionsService from "../services/keyboard_actions.js";
|
import keyboardActionsService from "../services/keyboard_actions.js";
|
||||||
import noteCreateService from "../services/note_create.js";
|
import noteCreateService from "../services/note_create.js";
|
||||||
|
import DeletedTypeWidget from "./type_widgets/deleted.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="note-detail">
|
<div class="note-detail">
|
||||||
@ -33,6 +34,7 @@ const TPL = `
|
|||||||
|
|
||||||
const typeWidgetClasses = {
|
const typeWidgetClasses = {
|
||||||
'empty': EmptyTypeWidget,
|
'empty': EmptyTypeWidget,
|
||||||
|
'deleted': DeletedTypeWidget,
|
||||||
'text': TextTypeWidget,
|
'text': TextTypeWidget,
|
||||||
'code': CodeTypeWidget,
|
'code': CodeTypeWidget,
|
||||||
'file': FileTypeWidget,
|
'file': FileTypeWidget,
|
||||||
@ -157,6 +159,8 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
return "empty";
|
return "empty";
|
||||||
|
} else if (note.isDeleted) {
|
||||||
|
return "deleted";
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = note.type;
|
let type = note.type;
|
||||||
|
@ -7,7 +7,7 @@ export default class ScreenContainer extends FlexContainer {
|
|||||||
this.screenName = screenName;
|
this.screenName = screenName;
|
||||||
}
|
}
|
||||||
|
|
||||||
activeScreenChangedEvent({activeScreen}) {console.log("Active screen", activeScreen);
|
activeScreenChangedEvent({activeScreen}) {
|
||||||
if (activeScreen === this.screenName) {
|
if (activeScreen === this.screenName) {
|
||||||
this.$widget.removeClass('d-none');
|
this.$widget.removeClass('d-none');
|
||||||
}
|
}
|
||||||
|
20
src/public/javascripts/widgets/type_widgets/deleted.js
Normal file
20
src/public/javascripts/widgets/type_widgets/deleted.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import TypeWidget from "./type_widget.js";
|
||||||
|
|
||||||
|
const TPL = `
|
||||||
|
<div class="note-detail-deleted note-detail-printable">
|
||||||
|
<div style="padding: 100px;">
|
||||||
|
<div class="alert alert-warning" style="padding: 20px;">
|
||||||
|
This note has been deleted.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
export default class DeletedTypeWidget extends TypeWidget {
|
||||||
|
static getType() { return "deleted"; }
|
||||||
|
|
||||||
|
doRender() {
|
||||||
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
|
return this.$widget;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user