fix: use SNJS duplicateItem for restoring as copy
This commit is contained in:
@@ -27,6 +27,7 @@ class RevisionPreviewModalCtrl extends PureViewCtrl implements RevisionPreviewSc
|
|||||||
application!: WebApplication
|
application!: WebApplication
|
||||||
unregisterComponent?: any
|
unregisterComponent?: any
|
||||||
note!: SNNote
|
note!: SNNote
|
||||||
|
private originalNote!: SNNote;
|
||||||
|
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
constructor(
|
constructor(
|
||||||
@@ -58,8 +59,8 @@ class RevisionPreviewModalCtrl extends PureViewCtrl implements RevisionPreviewSc
|
|||||||
ContentType.Note,
|
ContentType.Note,
|
||||||
this.content
|
this.content
|
||||||
) as SNNote;
|
) as SNNote;
|
||||||
const originalNote = this.application.findItem(this.uuid) as SNNote;
|
this.originalNote = this.application.findItem(this.uuid) as SNNote;
|
||||||
const editorForNote = this.componentManager.editorForNote(originalNote);
|
const editorForNote = this.componentManager.editorForNote(this.originalNote);
|
||||||
if (editorForNote) {
|
if (editorForNote) {
|
||||||
/**
|
/**
|
||||||
* Create temporary copy, as a lot of componentManager is uuid based, so might
|
* Create temporary copy, as a lot of componentManager is uuid based, so might
|
||||||
@@ -93,15 +94,10 @@ class RevisionPreviewModalCtrl extends PureViewCtrl implements RevisionPreviewSc
|
|||||||
restore(asCopy: boolean) {
|
restore(asCopy: boolean) {
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
if (asCopy) {
|
if (asCopy) {
|
||||||
const contentCopy = Object.assign({}, this.content);
|
await this.application.duplicateItem(this.originalNote, {
|
||||||
if (contentCopy.title) {
|
...this.content,
|
||||||
contentCopy.title += " (copy)";
|
title: this.content.title ? this.content.title + ' (copy)' : undefined
|
||||||
}
|
});
|
||||||
await this.application.createManagedItem(
|
|
||||||
ContentType.Note,
|
|
||||||
contentCopy,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
this.application.changeAndSaveItem(this.uuid, (mutator) => {
|
this.application.changeAndSaveItem(this.uuid, (mutator) => {
|
||||||
mutator.setContent(this.content);
|
mutator.setContent(this.content);
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
import { FooterStatus } from '@/types';
|
|
||||||
declare type StatusCallback = (string: string) => void;
|
declare type StatusCallback = (string: string) => void;
|
||||||
export declare class StatusManager {
|
export declare class StatusManager {
|
||||||
private statuses;
|
private _message;
|
||||||
private observers;
|
private observers;
|
||||||
replaceStatusWithString(status: FooterStatus, string: string): {
|
get message(): string;
|
||||||
string: string;
|
setMessage(message: string): void;
|
||||||
};
|
onStatusChange(callback: StatusCallback): () => void;
|
||||||
addStatusFromString(string: string): {
|
|
||||||
string: string;
|
|
||||||
};
|
|
||||||
removeStatus(status: FooterStatus): undefined;
|
|
||||||
addStatusObserver(callback: StatusCallback): () => void;
|
|
||||||
private notifyObservers;
|
private notifyObservers;
|
||||||
private getStatusString;
|
|
||||||
}
|
}
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { WebApplication } from '@/ui_models/application';
|
|||||||
import { ApplicationService, ApplicationEvent } from 'snjs';
|
import { ApplicationService, ApplicationEvent } from 'snjs';
|
||||||
export declare class ThemeManager extends ApplicationService {
|
export declare class ThemeManager extends ApplicationService {
|
||||||
private activeThemes;
|
private activeThemes;
|
||||||
private unsubState?;
|
|
||||||
private unregisterDesktop;
|
private unregisterDesktop;
|
||||||
private unregisterStream;
|
private unregisterStream;
|
||||||
onAppEvent(event: ApplicationEvent): Promise<void>;
|
onAppEvent(event: ApplicationEvent): Promise<void>;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ declare type WebServices = {
|
|||||||
autolockService: AutolockService;
|
autolockService: AutolockService;
|
||||||
archiveService: ArchiveManager;
|
archiveService: ArchiveManager;
|
||||||
nativeExtService: NativeExtManager;
|
nativeExtService: NativeExtManager;
|
||||||
statusService: StatusManager;
|
statusManager: StatusManager;
|
||||||
themeService: ThemeManager;
|
themeService: ThemeManager;
|
||||||
prefsService: PreferencesManager;
|
prefsService: PreferencesManager;
|
||||||
keyboardService: KeyboardManager;
|
keyboardService: KeyboardManager;
|
||||||
@@ -37,7 +37,7 @@ export declare class WebApplication extends SNApplication {
|
|||||||
getAutolockService(): AutolockService;
|
getAutolockService(): AutolockService;
|
||||||
getArchiveService(): ArchiveManager;
|
getArchiveService(): ArchiveManager;
|
||||||
getNativeExtService(): NativeExtManager;
|
getNativeExtService(): NativeExtManager;
|
||||||
getStatusService(): StatusManager;
|
getStatusManager(): StatusManager;
|
||||||
getThemeService(): ThemeManager;
|
getThemeService(): ThemeManager;
|
||||||
getPrefsService(): PreferencesManager;
|
getPrefsService(): PreferencesManager;
|
||||||
getKeyboardService(): KeyboardManager;
|
getKeyboardService(): KeyboardManager;
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -10956,8 +10956,8 @@
|
|||||||
"from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad"
|
"from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad"
|
||||||
},
|
},
|
||||||
"snjs": {
|
"snjs": {
|
||||||
"version": "github:standardnotes/snjs#3ed1e58670cf1e5b554e18a88f0ea9a28668a376",
|
"version": "github:standardnotes/snjs#3f2136d3c58c04ae2de24b3d0a85cffebcb816f5",
|
||||||
"from": "github:standardnotes/snjs#3ed1e58670cf1e5b554e18a88f0ea9a28668a376"
|
"from": "github:standardnotes/snjs#3f2136d3c58c04ae2de24b3d0a85cffebcb816f5"
|
||||||
},
|
},
|
||||||
"sockjs": {
|
"sockjs": {
|
||||||
"version": "0.3.20",
|
"version": "0.3.20",
|
||||||
|
|||||||
@@ -70,6 +70,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad",
|
"sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad",
|
||||||
"snjs": "github:standardnotes/snjs#3ed1e58670cf1e5b554e18a88f0ea9a28668a376"
|
"snjs": "github:standardnotes/snjs#3f2136d3c58c04ae2de24b3d0a85cffebcb816f5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user