chore: upgrade deps

This commit is contained in:
Mo
2022-03-21 12:13:10 -05:00
parent bd9a6e2ae5
commit cd243f39c6
21 changed files with 214 additions and 271 deletions

View File

@@ -663,7 +663,7 @@ export class NoteView extends PureComponent<Props, State> {
}
performNoteDeletion(note: SNNote) {
this.application.deleteItem(note);
this.application.mutator.deleteItem(note);
}
onPanelResizeFinish = async (
@@ -801,13 +801,13 @@ export class NoteView extends PureComponent<Props, State> {
};
async disassociateComponentWithCurrentNote(component: SNComponent) {
return this.application.runTransactionalMutation(
return this.application.mutator.runTransactionalMutation(
transactionForDisassociateComponentWithCurrentNote(component, this.note)
);
}
async associateComponentWithCurrentNote(component: SNComponent) {
return this.application.runTransactionalMutation(
return this.application.mutator.runTransactionalMutation(
transactionForAssociateComponentWithCurrentNote(component, this.note)
);
}

View File

@@ -274,7 +274,7 @@ export const NotesOptions = observer(
const duplicateSelectedItems = () => {
notes.forEach((note) => {
application.duplicateItem(note);
application.mutator.duplicateItem(note);
});
};

View File

@@ -86,7 +86,7 @@ export const ChangeEditorMenu: FunctionComponent<ChangeEditorMenuProps> = ({
) => {
if (component) {
if (component.conflictOf) {
application.changeAndSaveItem(component.uuid, (mutator) => {
application.mutator.changeAndSaveItem(component.uuid, (mutator) => {
mutator.conflictOf = undefined;
});
}
@@ -151,7 +151,7 @@ export const ChangeEditorMenu: FunctionComponent<ChangeEditorMenuProps> = ({
);
}
await application.runTransactionalMutations(transactions);
await application.mutator.runTransactionalMutations(transactions);
/** Dirtying can happen above */
application.sync.sync();

View File

@@ -57,7 +57,7 @@ export const ExtensionPane: FunctionComponent<IProps> = observer(
extension={extension}
first={false}
uninstall={() =>
application
application.mutator
.deleteItem(extension)
.then(() => preferencesMenu.loadExtensionsPanes())
}

View File

@@ -48,7 +48,7 @@ export const Extensions: FunctionComponent<{
)
.then(async (shouldRemove: boolean) => {
if (shouldRemove) {
await application.deleteItem(extension);
await application.mutator.deleteItem(extension);
setExtensions(loadExtensions(application));
}
})
@@ -73,7 +73,7 @@ export const Extensions: FunctionComponent<{
};
const confirmExtension = async () => {
await application.insertItem(confirmableExtension as SNComponent);
await application.mutator.insertItem(confirmableExtension as SNComponent);
application.sync.sync();
setExtensions(loadExtensions(application));
};

View File

@@ -95,7 +95,7 @@ export const DataBackups = observer(({ application, appState }: Props) => {
const performImport = async (data: BackupFile) => {
setIsImportDataLoading(true);
const result = await application.importData(data);
const result = await application.mutator.importData(data);
setIsImportDataLoading(false);

View File

@@ -46,7 +46,7 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> = ({
const toggleOffllineOnly = () => {
const newOfflineOnly = !offlineOnly;
setOfflineOnly(newOfflineOnly);
application
application.mutator
.changeAndSaveItem(extension.uuid, (m: any) => {
if (m.content == undefined) m.content = {};
m.content.offlineOnly = newOfflineOnly;
@@ -62,7 +62,7 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> = ({
const changeExtensionName = (newName: string) => {
setExtensionName(newName);
application
application.mutator
.changeAndSaveItem(extension.uuid, (m: any) => {
if (m.content == undefined) m.content = {};
m.content.name = newName;

View File

@@ -34,7 +34,7 @@ const makeEditorDefault = (
if (currentDefault) {
removeEditorDefault(application, currentDefault);
}
application.changeAndSaveItem(component.uuid, (m) => {
application.mutator.changeAndSaveItem(component.uuid, (m) => {
const mutator = m as ComponentMutator;
mutator.defaultEditor = true;
});
@@ -44,7 +44,7 @@ const removeEditorDefault = (
application: WebApplication,
component: SNComponent
) => {
application.changeAndSaveItem(component.uuid, (m) => {
application.mutator.changeAndSaveItem(component.uuid, (m) => {
const mutator = m as ComponentMutator;
mutator.defaultEditor = false;
});

View File

@@ -218,9 +218,9 @@ export const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
const toggleComponent = (component: SNComponent) => {
if (component.isTheme()) {
application.toggleTheme(component);
application.mutator.toggleTheme(component);
} else {
application.toggleComponent(component);
application.mutator.toggleComponent(component);
}
};
@@ -265,7 +265,7 @@ export const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
const activeTheme = themes
.map((item) => item.component)
.find((theme) => theme?.active && !theme.isLayerable());
if (activeTheme) application.toggleTheme(activeTheme);
if (activeTheme) application.mutator.toggleTheme(activeTheme);
};
return (

View File

@@ -44,7 +44,7 @@ export const ThemesMenuButton: FunctionComponent<Props> = ({
item.component.isLayerable() || !item.component.active;
if (themeIsLayerableOrNotActive) {
application.toggleTheme(item.component);
application.mutator.toggleTheme(item.component);
}
} else {
premiumModal.activate(`${item.name} theme`);

View File

@@ -153,7 +153,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
confirmButtonStyle: 'danger',
}).then((confirmed) => {
if (confirmed) {
application.changeAndSaveItem(
application.mutator.changeAndSaveItem(
selectedRevision.payload.uuid,
(mutator) => {
mutator.unsafe_setCustomContent(
@@ -175,12 +175,15 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
selectedRevision.payload.uuid
) as SNNote;
const duplicatedItem = await application.duplicateItem(originalNote, {
...(selectedRevision.payload.content as PayloadContent),
title: selectedRevision.payload.content.title
? selectedRevision.payload.content.title + ' (copy)'
: undefined,
});
const duplicatedItem = await application.mutator.duplicateItem(
originalNote,
{
...(selectedRevision.payload.content as PayloadContent),
title: selectedRevision.payload.content.title
? selectedRevision.payload.content.title + ' (copy)'
: undefined,
}
);
appState.notes.selectNote(duplicatedItem.uuid);
@@ -191,7 +194,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
useEffect(() => {
const fetchTemplateNote = async () => {
if (selectedRevision) {
const newTemplateNote = (await application.createTemplateItem(
const newTemplateNote = (await application.mutator.createTemplateItem(
ContentType.Note,
selectedRevision.payload.content
)) as SNNote;

View File

@@ -28,7 +28,7 @@ export class RevisionPreviewModal extends PureComponent<Props, State> {
async componentDidMount(): Promise<void> {
super.componentDidMount();
const templateNote = (await this.application.createTemplateItem(
const templateNote = (await this.application.mutator.createTemplateItem(
ContentType.Note,
this.props.content
)) as SNNote;
@@ -60,14 +60,14 @@ export class RevisionPreviewModal extends PureComponent<Props, State> {
restore = (asCopy: boolean) => {
const run = async () => {
if (asCopy) {
await this.application.duplicateItem(this.originalNote, {
await this.application.mutator.duplicateItem(this.originalNote, {
...this.props.content,
title: this.props.content.title
? this.props.content.title + ' (copy)'
: undefined,
});
} else {
this.application.changeAndSaveItem(
this.application.mutator.changeAndSaveItem(
this.props.uuid,
(mutator) => {
mutator.unsafe_setCustomContent(this.props.content);

View File

@@ -43,7 +43,7 @@ export const TagsSection: FunctionComponent<Props> = observer(
'Run Migration'
)
) {
appState.application.migrateTagsToFolders().then(() => {
appState.application.mutator.migrateTagsToFolders().then(() => {
checkIfMigrationNeeded();
});
}

View File

@@ -136,7 +136,7 @@ export class DesktopManager
if (!component) {
return;
}
const updatedComponent = await this.application.changeAndSaveItem(
const updatedComponent = await this.application.mutator.changeAndSaveItem(
component.uuid,
(m) => {
const mutator = m as ComponentMutator;

View File

@@ -48,7 +48,7 @@ export class ThemeManager extends ApplicationService {
const activeTheme = themes.find(
(theme) => theme.active && !theme.isLayerable()
);
if (activeTheme) this.application.toggleTheme(activeTheme);
if (activeTheme) this.application.mutator.toggleTheme(activeTheme);
};
const themeIdentifier = this.application.getPreference(
@@ -62,7 +62,7 @@ export class ThemeManager extends ApplicationService {
(theme) => theme.package_info.identifier === themeIdentifier
);
if (theme && !theme.active) {
this.application.toggleTheme(theme);
this.application.mutator.toggleTheme(theme);
}
}
}
@@ -133,7 +133,7 @@ export class ThemeManager extends ApplicationService {
);
if (status !== FeatureStatus.Entitled) {
if (theme.active) {
this.application.toggleTheme(theme);
this.application.mutator.toggleTheme(theme);
} else {
this.deactivateTheme(theme.uuid);
}

View File

@@ -121,7 +121,7 @@ export class NoteTagsState {
}
async createAndAddNewTag(): Promise<void> {
const newTag = await this.application.findOrCreateTag(
const newTag = await this.application.mutator.findOrCreateTag(
this.autocompleteSearchQuery
);
await this.addTagToActiveNote(newTag);
@@ -215,7 +215,7 @@ export class NoteTagsState {
async removeTagFromActiveNote(tag: SNTag): Promise<void> {
const { activeNote } = this;
if (activeNote) {
await this.application.changeItem(tag.uuid, (mutator) => {
await this.application.mutator.changeItem(tag.uuid, (mutator) => {
mutator.removeItemAsRelationship(activeNote);
});
this.application.sync.sync();

View File

@@ -260,7 +260,7 @@ export class NotesState {
async changeSelectedNotes(
mutate: (mutator: NoteMutator) => void
): Promise<void> {
await this.application.changeItems(
await this.application.mutator.changeItems(
Object.keys(this.selectedNotes),
mutate,
false
@@ -336,7 +336,7 @@ export class NotesState {
) {
if (permanently) {
for (const note of Object.values(this.selectedNotes)) {
await this.application.deleteItem(note);
await this.application.mutator.deleteItem(note);
delete this.selectedNotes[note.uuid];
}
} else {
@@ -377,10 +377,10 @@ export class NotesState {
async setProtectSelectedNotes(protect: boolean): Promise<void> {
const selectedNotes = Object.values(this.selectedNotes);
if (protect) {
await this.application.protectNotes(selectedNotes);
await this.application.mutator.protectNotes(selectedNotes);
this.setShowProtectedWarning(true);
} else {
await this.application.unprotectNotes(selectedNotes);
await this.application.mutator.unprotectNotes(selectedNotes);
this.setShowProtectedWarning(false);
}
}
@@ -396,7 +396,7 @@ export class NotesState {
}
async toggleGlobalSpellcheckForNote(note: SNNote) {
await this.application.changeItem<NoteMutator>(
await this.application.mutator.changeItem<NoteMutator>(
note.uuid,
(mutator) => {
mutator.toggleSpellcheck();
@@ -412,7 +412,7 @@ export class NotesState {
const tagsToAdd = [...parentChainTags, tag];
await Promise.all(
tagsToAdd.map(async (tag) => {
await this.application.changeItem(tag.uuid, (mutator) => {
await this.application.mutator.changeItem(tag.uuid, (mutator) => {
for (const note of selectedNotes) {
mutator.addItemAsRelationship(note);
}
@@ -424,7 +424,7 @@ export class NotesState {
async removeTagFromSelectedNotes(tag: SNTag): Promise<void> {
const selectedNotes = Object.values(this.selectedNotes);
await this.application.changeItem(tag.uuid, (mutator) => {
await this.application.mutator.changeItem(tag.uuid, (mutator) => {
for (const note of selectedNotes) {
mutator.removeItemAsRelationship(note);
}
@@ -452,7 +452,7 @@ export class NotesState {
confirmButtonStyle: 'danger',
})
) {
this.application.emptyTrash();
this.application.mutator.emptyTrash();
this.application.sync.sync();
}
}

View File

@@ -498,7 +498,7 @@ export class NotesViewState {
handleEditorChange = async () => {
const activeNote = this.appState.getActiveNoteController()?.note;
if (activeNote && activeNote.conflictOf) {
this.application.changeAndSaveItem(activeNote.uuid, (mutator) => {
this.application.mutator.changeAndSaveItem(activeNote.uuid, (mutator) => {
mutator.conflictOf = undefined;
});
}

View File

@@ -194,7 +194,7 @@ export class TagsState {
return;
}
const createdTag = (await this.application.createTagOrSmartView(
const createdTag = (await this.application.mutator.createTagOrSmartView(
title
)) as SNTag;
@@ -355,13 +355,13 @@ export class TagsState {
if (!isValidFutureSiblings(this.application, futureSiblings, tag)) {
return;
}
await this.application.unsetTagParent(tag);
await this.application.mutator.unsetTagParent(tag);
} else {
const futureSiblings = this.application.getTagChildren(futureParent);
if (!isValidFutureSiblings(this.application, futureSiblings, tag)) {
return;
}
await this.application.setTagParent(futureParent, tag);
await this.application.mutator.setTagParent(futureParent, tag);
}
await this.application.sync.sync();
@@ -393,7 +393,7 @@ export class TagsState {
public set selected(tag: AnyTag | undefined) {
if (tag && tag.conflictOf) {
this.application.changeAndSaveItem(tag.uuid, (mutator) => {
this.application.mutator.changeAndSaveItem(tag.uuid, (mutator) => {
mutator.conflictOf = undefined;
});
}
@@ -409,9 +409,12 @@ export class TagsState {
}
public setExpanded(tag: SNTag, expanded: boolean) {
this.application.changeAndSaveItem<TagMutator>(tag.uuid, (mutator) => {
mutator.expanded = expanded;
});
this.application.mutator.changeAndSaveItem<TagMutator>(
tag.uuid,
(mutator) => {
mutator.expanded = expanded;
}
);
}
public get selectedUuid(): UuidString | undefined {
@@ -435,7 +438,7 @@ export class TagsState {
return;
}
const newTag = (await this.application.createTemplateItem(
const newTag = (await this.application.mutator.createTemplateItem(
ContentType.Tag
)) as SNTag;
@@ -459,7 +462,7 @@ export class TagsState {
});
}
if (shouldDelete) {
this.application.deleteItem(tag);
this.application.mutator.deleteItem(tag);
this.selected = this.smartViews[0];
}
}
@@ -506,13 +509,15 @@ export class TagsState {
}
}
const insertedTag = await this.application.createTagOrSmartView(newTitle);
const insertedTag = await this.application.mutator.createTagOrSmartView(
newTitle
);
this.application.sync.sync();
runInAction(() => {
this.selected = insertedTag as SNTag;
});
} else {
await this.application.changeAndSaveItem<TagMutator>(
await this.application.mutator.changeAndSaveItem<TagMutator>(
tag.uuid,
(mutator) => {
mutator.title = newTitle;