feat: add empty trash option
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { confirmDialog } from '@/services/alertService';
|
||||
import { KeyboardModifier } from '@/services/ioService';
|
||||
import { Strings, StringUtils } from '@/strings';
|
||||
import { StringEmptyTrash, Strings, StringUtils } from '@/strings';
|
||||
import {
|
||||
UuidString,
|
||||
SNNote,
|
||||
@@ -40,6 +40,7 @@ export class NotesState {
|
||||
showProtectedWarning: observable,
|
||||
|
||||
selectedNotesCount: computed,
|
||||
trashedNotesCount: computed,
|
||||
|
||||
deleteNotesPermanently: action,
|
||||
selectNote: action,
|
||||
@@ -55,6 +56,7 @@ export class NotesState {
|
||||
removeTagFromSelectedNotes: action,
|
||||
isTagInSelectedNotes: action,
|
||||
setShowProtectedWarning: action,
|
||||
emptyTrash: action,
|
||||
});
|
||||
|
||||
appEventListeners.push(
|
||||
@@ -78,6 +80,10 @@ export class NotesState {
|
||||
return Object.keys(this.selectedNotes).length;
|
||||
}
|
||||
|
||||
get trashedNotesCount(): number {
|
||||
return this.application.getTrashedItems().length;
|
||||
}
|
||||
|
||||
async runProtectedAction(action: (note: SNNote) => void, notes: SNNote[]): Promise<void> {
|
||||
let protectedNotesAccessRequest: Promise<boolean>;
|
||||
await Promise.all(
|
||||
@@ -358,6 +364,18 @@ export class NotesState {
|
||||
this.showProtectedWarning = show;
|
||||
}
|
||||
|
||||
async emptyTrash() {
|
||||
if (
|
||||
await confirmDialog({
|
||||
text: StringEmptyTrash(this.trashedNotesCount),
|
||||
confirmButtonStyle: 'danger',
|
||||
})
|
||||
) {
|
||||
this.application.emptyTrash();
|
||||
this.application.sync();
|
||||
}
|
||||
}
|
||||
|
||||
private get io() {
|
||||
return this.application.io;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user