refactor: new snjs support (#967)

This commit is contained in:
Mo
2022-04-11 12:48:19 -05:00
committed by GitHub
parent 3126d97dca
commit 3a2ff2f440
44 changed files with 569 additions and 799 deletions

View File

@@ -1,3 +1,3 @@
{
"singleQuote": true
"singleQuote": true,
}

View File

@@ -1,7 +1,7 @@
import { observer } from 'mobx-react-lite';
import { AppState } from '@/ui_models/app_state';
import { WebApplication } from '@/ui_models/application';
import { User as UserType } from '@standardnotes/responses';
import { User as UserType } from '@standardnotes/snjs';
type Props = {
appState: AppState;

View File

@@ -169,9 +169,7 @@ export const AttachedFilesPopover: FunctionComponent<Props> = observer(
</div>
) : null}
{filteredList.length > 0 ? (
filteredList
.filter((file) => !file.deleted)
.map((file: SNFile) => {
filteredList.map((file: SNFile) => {
return (
<PopoverFileItem
key={file.uuid}

View File

@@ -226,10 +226,7 @@ export class Footer extends PureComponent<Props, State> {
this.application.items.setDisplayOptions(
ContentType.Theme,
CollectionSort.Title,
'asc',
(theme: ItemInterface) => {
return !theme.errorDecrypting;
}
'asc'
);
}

View File

@@ -281,7 +281,7 @@ export class NoteView extends PureComponent<Props, State> {
});
}
if (!note.deleted && note.locked !== this.state.noteLocked) {
if (note.locked !== this.state.noteLocked) {
this.setState({
noteLocked: note.locked,
});
@@ -421,7 +421,7 @@ export class NoteView extends PureComponent<Props, State> {
streamItems() {
this.removeComponentStreamObserver = this.application.streamItems(
ContentType.Component,
async (_items, source) => {
async ({ source }) => {
if (
isPayloadSourceInternalChange(source) ||
source === PayloadSource.InitialObserverRegistrationPush
@@ -1003,7 +1003,7 @@ export class NoteView extends PureComponent<Props, State> {
)}
</div>
{this.note && !this.note.errorDecrypting && (
{this.note && (
<div id="editor-title-bar" className="section-title-bar w-full">
<div className="flex items-center justify-between h-8">
<div
@@ -1089,7 +1089,6 @@ export class NoteView extends PureComponent<Props, State> {
</div>
)}
{!this.note.errorDecrypting && (
<div
id={ElementIds.EditorContent}
className={ElementIds.EditorContent}
@@ -1154,43 +1153,7 @@ export class NoteView extends PureComponent<Props, State> {
/>
) : null}
</div>
)}
{this.note.errorDecrypting && (
<div className="section">
<div id="error-decrypting-container" className="sn-component">
<div id="error-decrypting-panel" className="sk-panel">
<div className="sk-panel-header">
<div className="sk-panel-header-title">
{this.note.waitingForKey
? 'Waiting for Key'
: 'Unable to Decrypt'}
</div>
</div>
<div className="sk-panel-content">
<div className="sk-panel-section">
{this.note.waitingForKey && (
<p className="sk-p">
This note is awaiting its encryption key to be ready.
Please wait for syncing to complete for this note to
be decrypted.
</p>
)}
{!this.note.waitingForKey && (
<p className="sk-p">
There was an error decrypting this item. Ensure you
are running the latest version of this app, then sign
out and sign back in to try again.
</p>
)}
</div>
</div>
</div>
</div>
</div>
)}
{!this.note.errorDecrypting && (
<div id="editor-pane-component-stack">
{this.state.availableStackComponents.length > 0 && (
<div
@@ -1247,7 +1210,6 @@ export class NoteView extends PureComponent<Props, State> {
})}
</div>
</div>
)}
</div>
</div>
);

View File

@@ -1,6 +1,7 @@
import { WebApplication } from '@/ui_models/application';
import {
CollectionSort,
CollectionSortProperty,
sanitizeHtmlString,
SNNote,
} from '@standardnotes/snjs';
@@ -18,7 +19,7 @@ type Props = {
onClick: () => void;
onContextMenu: (e: MouseEvent) => void;
selected: boolean;
sortedBy?: CollectionSort;
sortedBy?: CollectionSortProperty;
};
type NoteFlag = {
@@ -34,25 +35,7 @@ const flagsForNote = (note: SNNote) => {
class: 'danger',
});
}
if (note.errorDecrypting) {
if (note.waitingForKey) {
flags.push({
text: 'Waiting For Keys',
class: 'info',
});
} else {
flags.push({
text: 'Missing Keys',
class: 'danger',
});
}
}
if (note.deleted) {
flags.push({
text: 'Deletion Pending Sync',
class: 'danger',
});
}
return flags;
};

View File

@@ -1,5 +1,9 @@
import { WebApplication } from '@/ui_models/application';
import { CollectionSort, PrefKey } from '@standardnotes/snjs';
import {
CollectionSort,
CollectionSortProperty,
PrefKey,
} from '@standardnotes/snjs';
import { observer } from 'mobx-react-lite';
import { FunctionComponent } from 'preact';
import { useState } from 'preact/hooks';
@@ -52,7 +56,7 @@ export const NotesListOptionsMenu: FunctionComponent<Props> = observer(
setSortReverse(!sortReverse);
};
const toggleSortBy = (sort: CollectionSort) => {
const toggleSortBy = (sort: CollectionSortProperty) => {
if (sortBy === sort) {
toggleSortReverse();
} else {

View File

@@ -104,7 +104,7 @@ const ListedActionsMenu: FunctionComponent<ListedActionsMenuProps> = ({
const updatedGroup: ListedMenuGroup = {
name: updatedAccountInfo.display_name,
account: group.account,
actions: updatedAccountInfo.actions,
actions: updatedAccountInfo.actions as Action[],
};
const updatedGroups = menuGroups.map((group) => {
@@ -145,7 +145,7 @@ const ListedActionsMenu: FunctionComponent<ListedActionsMenuProps> = ({
menuGroups.push({
name: accountInfo.display_name,
account,
actions: accountInfo.actions,
actions: accountInfo.actions as Action[],
});
} else {
menuGroups.push({

View File

@@ -219,7 +219,6 @@ export const NotesOptions = observer(
const notTrashed = notes.some((note) => !note.trashed);
const pinned = notes.some((note) => note.pinned);
const unpinned = notes.some((note) => !note.pinned);
const errored = notes.some((note) => note.errorDecrypting);
useEffect(() => {
const removeAltKeyObserver = application.io.addKeyObserver({
@@ -278,26 +277,6 @@ export const NotesOptions = observer(
});
};
if (errored) {
return (
<>
{notes.length === 1 ? (
<div className="px-3 pt-1.5 pb-1 text-xs color-neutral font-medium">
<div>
<span className="font-semibold">Note ID:</span> {notes[0].uuid}
</div>
</div>
) : null}
<DeletePermanentlyButton
closeOnBlur={closeOnBlur}
onClick={async () => {
await appState.notes.deleteNotesPermanently();
}}
/>
</>
);
}
const openRevisionHistoryModal = () => {
appState.notes.setShowRevisionHistoryModal(true);
};

View File

@@ -86,7 +86,7 @@ export const ChangeEditorMenu: FunctionComponent<ChangeEditorMenuProps> = ({
) => {
if (component) {
if (component.conflictOf) {
application.mutator.changeAndSaveItem(component.uuid, (mutator) => {
application.mutator.changeAndSaveItem(component, (mutator) => {
mutator.conflictOf = undefined;
});
}

View File

@@ -1,11 +1,13 @@
import { WebApplication } from '@/ui_models/application';
import {
ContentType,
FeatureStatus,
SNComponent,
ComponentArea,
FeatureDescription,
GetFeatures,
NoteType,
} from '@standardnotes/features';
import { ContentType, FeatureStatus, SNComponent } from '@standardnotes/snjs';
} from '@standardnotes/snjs';
import { EditorMenuItem, EditorMenuGroup } from '../ChangeEditorOption';
export const PLAIN_EDITOR_NAME = 'Plain Editor';

View File

@@ -1,12 +1,6 @@
import { action, makeAutoObservable, observable } from 'mobx';
import { ExtensionsLatestVersions } from '@/components/Preferences/panes/extensions-segments';
import {
ComponentArea,
ContentType,
FeatureIdentifier,
SNComponent,
IconType,
} from '@standardnotes/snjs';
import { FeatureIdentifier, IconType } from '@standardnotes/snjs';
import { WebApplication } from '@/ui_models/application';
const PREFERENCE_IDS = [
@@ -61,7 +55,6 @@ const READY_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
export class PreferencesMenu {
private _selectedPane: PreferenceId | FeatureIdentifier = 'account';
private _extensionPanes: SNComponent[] = [];
private _menu: PreferencesMenuItem[];
private _extensionLatestVersions: ExtensionsLatestVersions =
new ExtensionsLatestVersions(new Map());
@@ -74,7 +67,6 @@ export class PreferencesMenu {
? PREFERENCES_MENU_ITEMS
: READY_PREFERENCES_MENU_ITEMS;
this.loadExtensionsPanes();
this.loadLatestVersions();
makeAutoObservable<
@@ -105,64 +97,24 @@ export class PreferencesMenu {
return this._extensionLatestVersions;
}
loadExtensionsPanes(): void {
const excludedComponents = [
FeatureIdentifier.TwoFactorAuthManager,
'org.standardnotes.batch-manager',
'org.standardnotes.extensions-manager',
FeatureIdentifier.CloudLink,
];
this._extensionPanes = (
this.application.items.getItems([
ContentType.ActionsExtension,
ContentType.Component,
ContentType.Theme,
]) as SNComponent[]
).filter(
(extension) =>
extension.area === ComponentArea.Modal &&
!excludedComponents.includes(extension.package_info.identifier)
);
}
get menuItems(): SelectableMenuItem[] {
const menuItems = this._menu.map((preference) => ({
...preference,
selected: preference.id === this._selectedPane,
}));
const extensionsMenuItems: SelectableMenuItem[] = this._extensionPanes.map(
(extension) => {
return {
icon: 'window',
id: extension.package_info.identifier,
label: extension.name,
selected: extension.package_info.identifier === this._selectedPane,
};
}
);
return menuItems.concat(extensionsMenuItems);
return menuItems;
}
get selectedMenuItem(): PreferencesMenuItem | undefined {
return this._menu.find((item) => item.id === this._selectedPane);
}
get selectedExtension(): SNComponent | undefined {
return this._extensionPanes.find(
(extension) => extension.package_info.identifier === this._selectedPane
);
}
get selectedPaneId(): PreferenceId | FeatureIdentifier {
if (this.selectedMenuItem != undefined) {
return this.selectedMenuItem.id;
}
if (this.selectedExtension != undefined) {
return this.selectedExtension.package_info.identifier;
}
return 'account';
}

View File

@@ -1,6 +1,8 @@
import { RoundIconButton } from '@/components/RoundIconButton';
import { TitleBar, Title } from '@/components/TitleBar';
import { FunctionComponent } from 'preact';
import { observer } from 'mobx-react-lite';
import {
AccountPreferences,
HelpAndFeedback,
@@ -8,15 +10,12 @@ import {
General,
Security,
} from './panes';
import { observer } from 'mobx-react-lite';
import { PreferencesMenu } from './PreferencesMenu';
import { PreferencesMenuView } from './PreferencesMenuView';
import { WebApplication } from '@/ui_models/application';
import { MfaProps } from './panes/two-factor-auth/MfaProps';
import { AppState } from '@/ui_models/app_state';
import { useEffect, useMemo } from 'preact/hooks';
import { ExtensionPane } from './panes/ExtensionPane';
import { Backups } from '@/components/Preferences/panes/Backups';
import { Appearance } from './panes/Appearance';
@@ -66,16 +65,6 @@ const PaneSelector: FunctionComponent<
case 'help-feedback':
return <HelpAndFeedback />;
default:
if (menu.selectedExtension != undefined) {
return (
<ExtensionPane
application={application}
appState={appState}
extension={menu.selectedExtension}
preferencesMenu={menu}
/>
);
} else {
return (
<General
appState={appState}
@@ -84,7 +73,6 @@ const PaneSelector: FunctionComponent<
/>
);
}
}
});
const PreferencesCanvas: FunctionComponent<

View File

@@ -4,12 +4,12 @@ import { sortThemes } from '@/components/QuickSettingsMenu/QuickSettingsMenu';
import { HorizontalSeparator } from '@/components/Shared/HorizontalSeparator';
import { Switch } from '@/components/Switch';
import { WebApplication } from '@/ui_models/application';
import { GetFeatures } from '@standardnotes/features';
import {
ContentType,
FeatureIdentifier,
FeatureStatus,
PrefKey,
GetFeatures,
SNTheme,
} from '@standardnotes/snjs';
import { observer } from 'mobx-react-lite';
@@ -61,9 +61,8 @@ export const Appearance: FunctionComponent<Props> = observer(
);
useEffect(() => {
const themesAsItems: DropdownItem[] = (
application.items.getDisplayableItems(ContentType.Theme) as SNTheme[]
)
const themesAsItems: DropdownItem[] = application.items
.getDisplayableItems<SNTheme>(ContentType.Theme)
.filter((theme) => !theme.isLayerable())
.sort(sortThemes)
.map((theme) => {

View File

@@ -1,79 +0,0 @@
import {
PreferencesGroup,
PreferencesSegment,
} from '@/components/Preferences/components';
import { WebApplication } from '@/ui_models/application';
import { ComponentViewer, SNComponent } from '@standardnotes/snjs';
import { FeatureIdentifier } from '@standardnotes/features';
import { observer } from 'mobx-react-lite';
import { FunctionComponent } from 'preact';
import { ExtensionItem } from './extensions-segments';
import { ComponentView } from '@/components/ComponentView';
import { AppState } from '@/ui_models/app_state';
import { PreferencesMenu } from '@/components/Preferences/PreferencesMenu';
import { useEffect, useState } from 'preact/hooks';
interface IProps {
application: WebApplication;
appState: AppState;
extension: SNComponent;
preferencesMenu: PreferencesMenu;
}
const urlOverrideForExtension = (extension: SNComponent) => {
if (extension.identifier === FeatureIdentifier.CloudLink) {
return 'https://extensions.standardnotes.org/components/cloudlink';
} else {
return undefined;
}
};
export const ExtensionPane: FunctionComponent<IProps> = observer(
({ extension, application, appState, preferencesMenu }) => {
const [componentViewer] = useState<ComponentViewer>(
application.componentManager.createComponentViewer(
extension,
undefined,
undefined,
urlOverrideForExtension(extension)
)
);
const latestVersion =
preferencesMenu.extensionsLatestVersions.getVersion(extension);
useEffect(() => {
return () => {
application.componentManager.destroyComponentViewer(componentViewer);
};
}, [application, componentViewer]);
return (
<div className="preferences-extension-pane color-foreground flex-grow flex flex-row overflow-y-auto min-h-0">
<div className="flex-grow flex flex-col py-6 items-center">
<div className="w-200 max-w-200 flex flex-col">
<PreferencesGroup>
<ExtensionItem
application={application}
extension={extension}
first={false}
uninstall={() =>
application.mutator
.deleteItem(extension)
.then(() => preferencesMenu.loadExtensionsPanes())
}
latestVersion={latestVersion}
/>
<PreferencesSegment>
<ComponentView
application={application}
appState={appState}
componentViewer={componentViewer}
/>
</PreferencesSegment>
</PreferencesGroup>
</div>
</div>
</div>
);
}
);

View File

@@ -13,10 +13,11 @@ import { useEffect, useRef, useState } from 'preact/hooks';
import { observer } from 'mobx-react-lite';
const loadExtensions = (application: WebApplication) =>
application.items.getItems(
[ContentType.ActionsExtension, ContentType.Component, ContentType.Theme],
true
) as SNComponent[];
application.items.getItems([
ContentType.ActionsExtension,
ContentType.Component,
ContentType.Theme,
]) as SNComponent[];
export const Extensions: FunctionComponent<{
application: WebApplication;

View File

@@ -13,16 +13,16 @@ import {
Text,
Title,
} from '../../components';
import {
EmailBackupFrequency,
MuteFailedBackupsEmailsOption,
SettingName,
} from '@standardnotes/settings';
import { Dropdown, DropdownItem } from '@/components/Dropdown';
import { Switch } from '@/components/Switch';
import { HorizontalSeparator } from '@/components/Shared/HorizontalSeparator';
import { FeatureIdentifier } from '@standardnotes/features';
import { FeatureStatus } from '@standardnotes/snjs';
import {
FeatureStatus,
FeatureIdentifier,
EmailBackupFrequency,
MuteFailedBackupsEmailsOption,
SettingName,
} from '@standardnotes/snjs';
type Props = {
application: WebApplication;

View File

@@ -1,11 +1,12 @@
import { useCallback, useEffect, useState } from 'preact/hooks';
import { ButtonType, SettingName } from '@standardnotes/snjs';
import {
ButtonType,
SettingName,
CloudProvider,
DropboxBackupFrequency,
GoogleDriveBackupFrequency,
OneDriveBackupFrequency,
} from '@standardnotes/settings';
} from '@standardnotes/snjs';
import { WebApplication } from '@/ui_models/application';
import { Button } from '@/components/Button';
import { isDev, openInNewTab } from '@/utils';

View File

@@ -9,14 +9,15 @@ import {
Title,
} from '@/components/Preferences/components';
import { HorizontalSeparator } from '@/components/Shared/HorizontalSeparator';
import { FeatureIdentifier } from '@standardnotes/features';
import { FeatureStatus } from '@standardnotes/snjs';
import { FunctionComponent } from 'preact';
import {
FeatureStatus,
FeatureIdentifier,
CloudProvider,
MuteFailedCloudBackupsEmailsOption,
SettingName,
} from '@standardnotes/settings';
} from '@standardnotes/snjs';
import { FunctionComponent } from 'preact';
import { Switch } from '@/components/Switch';
import { convertStringifiedBooleanToBoolean } from '@/utils';
import { STRING_FAILED_TO_UPDATE_USER_SETTING } from '@/strings';

View File

@@ -1,4 +1,4 @@
import { displayStringForContentType, SNComponent } from '@standardnotes/snjs';
import { DisplayStringForContentType, SNComponent } from '@standardnotes/snjs';
import { Button } from '@/components/Button';
import { FunctionComponent } from 'preact';
import { Title, Text, Subtitle, PreferencesSegment } from '../../components';
@@ -30,7 +30,7 @@ export const ConfirmCustomExtension: FunctionComponent<{
},
{
label: 'Extension Type',
value: displayStringForContentType(component.content_type),
value: DisplayStringForContentType(component.content_type),
},
];

View File

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

View File

@@ -1,6 +1,9 @@
import { WebApplication } from '@/ui_models/application';
import { FeatureDescription } from '@standardnotes/features';
import { SNComponent, ClientDisplayableError } from '@standardnotes/snjs';
import {
SNComponent,
ClientDisplayableError,
FeatureDescription,
} from '@standardnotes/snjs';
import { makeAutoObservable, observable } from 'mobx';
export class ExtensionsLatestVersions {

View File

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

View File

@@ -1,4 +1,3 @@
import { FindNativeFeature } from '@standardnotes/features';
import { Switch } from '@/components/Switch';
import {
PreferencesGroup,
@@ -8,7 +7,11 @@ import {
Title,
} from '@/components/Preferences/components';
import { WebApplication } from '@/ui_models/application';
import { FeatureIdentifier, FeatureStatus } from '@standardnotes/snjs';
import {
FeatureIdentifier,
FeatureStatus,
FindNativeFeature,
} from '@standardnotes/snjs';
import { FunctionComponent } from 'preact';
import { useCallback, useEffect, useState } from 'preact/hooks';
import { usePremiumModal } from '@/components/Premium';

View File

@@ -12,7 +12,7 @@ import {
MuteSignInEmailsOption,
LogSessionUserAgentOption,
SettingName,
} from '@standardnotes/settings';
} from '@standardnotes/snjs';
import { observer } from 'mobx-react-lite';
import { FunctionalComponent } from 'preact';
import { useCallback, useEffect, useState } from 'preact/hooks';

View File

@@ -103,9 +103,9 @@ export const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
}, [focusModeEnabled]);
const reloadThemes = useCallback(() => {
const themes = (
application.items.getDisplayableItems(ContentType.Theme) as SNTheme[]
).map((item) => {
const themes = application.items
.getDisplayableItems<SNTheme>(ContentType.Theme)
.map((item) => {
return {
name: item.name,
identifier: item.identifier,
@@ -140,17 +140,15 @@ export const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
}, [application]);
const reloadToggleableComponents = useCallback(() => {
const toggleableComponents = (
application.items.getDisplayableItems(
ContentType.Component
) as SNComponent[]
).filter(
const toggleableComponents = application.items
.getDisplayableItems<SNComponent>(ContentType.Component)
.filter(
(component) =>
[ComponentArea.EditorStack, ComponentArea.TagsList].includes(
component.area
) &&
component.identifier !== FeatureIdentifier.DeprecatedFoldersComponent
[ComponentArea.EditorStack].includes(component.area) &&
component.identifier !==
FeatureIdentifier.DeprecatedFoldersComponent
);
setToggleableComponents(toggleableComponents);
}, [application]);

View File

@@ -134,7 +134,7 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
throw new Error('Could not fetch revision');
}
setSelectedRevision(response.item as HistoryEntry);
setSelectedRevision(response.item as unknown as HistoryEntry);
} catch (error) {
console.error(error);
setSelectedRevision(undefined);
@@ -165,7 +165,7 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
try {
const remoteRevision =
await application.historyManager.fetchRemoteRevision(
note.uuid,
note,
revisionListEntry
);
setSelectedRevision(remoteRevision);
@@ -182,7 +182,7 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
},
[
application,
note.uuid,
note,
setIsFetchingSelectedRevision,
setSelectedRemoteEntry,
setSelectedRevision,

View File

@@ -8,7 +8,6 @@ import {
ButtonType,
ContentType,
HistoryEntry,
PayloadContent,
PayloadSource,
RevisionListEntry,
SNNote,
@@ -148,7 +147,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
}).then((confirmed) => {
if (confirmed) {
application.mutator.changeAndSaveItem(
selectedRevision.payload.uuid,
originalNote,
(mutator) => {
mutator.unsafe_setCustomContent(
selectedRevision.payload.content
@@ -165,14 +164,14 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
const restoreAsCopy = async () => {
if (selectedRevision) {
const originalNote = application.items.findItem(
const originalNote = application.items.findSureItem<SNNote>(
selectedRevision.payload.uuid
) as SNNote;
);
const duplicatedItem = await application.mutator.duplicateItem(
originalNote,
{
...(selectedRevision.payload.content as PayloadContent),
...selectedRevision.payload.content,
title: selectedRevision.payload.content.title
? selectedRevision.payload.content.title + ' (copy)'
: undefined,
@@ -188,10 +187,10 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
useEffect(() => {
const fetchTemplateNote = async () => {
if (selectedRevision) {
const newTemplateNote = (await application.mutator.createTemplateItem(
const newTemplateNote = application.mutator.createTemplateItem(
ContentType.Note,
selectedRevision.payload.content
)) as SNNote;
) as SNNote;
setTemplateNoteForRevision(newTemplateNote);
}
@@ -218,7 +217,7 @@ export const RevisionHistoryModal: FunctionComponent<RevisionHistoryModalProps>
setIsDeletingRevision(true);
application.historyManager
.deleteRemoteRevision(note.uuid, selectedRemoteEntry)
.deleteRemoteRevision(note, selectedRemoteEntry)
.then((res) => {
if (res.error?.message) {
throw new Error(res.error.message);

View File

@@ -4,7 +4,7 @@ import {
PayloadSource,
SNNote,
ComponentViewer,
PayloadContent,
NoteContent,
} from '@standardnotes/snjs';
import { confirmDialog } from '@/services/alertService';
import { STRING_RESTORE_LOCKED_ATTEMPT } from '@/strings';
@@ -13,7 +13,7 @@ import { ComponentView } from './ComponentView';
interface Props {
application: WebApplication;
content: PayloadContent;
content: NoteContent;
title?: string;
uuid: string;
}
@@ -74,7 +74,7 @@ export class RevisionPreviewModal extends PureComponent<Props, State> {
});
} else {
this.application.mutator.changeAndSaveItem(
this.props.uuid,
this.originalNote,
(mutator) => {
mutator.unsafe_setCustomContent(this.props.content);
},

View File

@@ -110,7 +110,6 @@ export const SmartViewsListItem: FunctionComponent<Props> = observer(
paddingLeft: `${level * PADDING_PER_LEVEL_PX + PADDING_BASE_PX}px`,
}}
>
{!view.errorDecrypting ? (
<div className="tag-info">
<div className={`tag-icon mr-1`}>
<Icon
@@ -133,7 +132,7 @@ export const SmartViewsListItem: FunctionComponent<Props> = observer(
{view.uuid === SystemViewId.AllNotes && tagsState.allNotesCount}
</div>
</div>
) : null}
{!isSystemView(view) && (
<div className="meta">
{view.conflictOf && (
@@ -141,14 +140,7 @@ export const SmartViewsListItem: FunctionComponent<Props> = observer(
Conflicted Copy {view.conflictOf}
</div>
)}
{view.errorDecrypting && !view.waitingForKey && (
<div className="danger small-text font-bold">Missing Keys</div>
)}
{view.errorDecrypting && view.waitingForKey && (
<div className="info small-text font-bold">
Waiting For Keys
</div>
)}
{isSelected && (
<div className="menu">
{!isEditing && (

View File

@@ -152,7 +152,7 @@ export const TagsListItem: FunctionComponent<Props> = observer(
() => ({
accept: ItemTypes.TAG,
canDrop: (item) => {
return tagsState.isValidTagParent(tag.uuid, item.uuid);
return tagsState.isValidTagParent(tag, item as SNTag);
},
drop: (item) => {
if (!hasFolders) {
@@ -202,7 +202,6 @@ export const TagsListItem: FunctionComponent<Props> = observer(
onContextMenu(tag, e.clientX, e.clientY);
}}
>
{!tag.errorDecrypting ? (
<div className="tag-info" title={title} ref={dropRef}>
{hasAtLeastOneFolder && (
<div className="tag-fold-container">
@@ -215,9 +214,7 @@ export const TagsListItem: FunctionComponent<Props> = observer(
<Icon
className={`color-neutral`}
type={
showChildren
? 'menu-arrow-down-alt'
: 'menu-arrow-right'
showChildren ? 'menu-arrow-down-alt' : 'menu-arrow-right'
}
/>
</button>
@@ -253,19 +250,13 @@ export const TagsListItem: FunctionComponent<Props> = observer(
<div className="count">{noteCounts.get()}</div>
</div>
</div>
) : null}
<div className={`meta ${hasAtLeastOneFolder ? 'with-folders' : ''}`}>
{tag.conflictOf && (
<div className="danger small-text font-bold">
Conflicted Copy {tag.conflictOf}
</div>
)}
{tag.errorDecrypting && !tag.waitingForKey && (
<div className="danger small-text font-bold">Missing Keys</div>
)}
{tag.errorDecrypting && tag.waitingForKey && (
<div className="info small-text font-bold">Waiting For Keys</div>
)}
</div>
</button>
{isAddingSubtag && (

View File

@@ -1,11 +1,10 @@
import { WebApplication } from '@/ui_models/application';
import { parseFileName } from '@standardnotes/filepicker';
import {
EncryptionIntent,
ContentType,
SNNote,
BackupFile,
PayloadContent,
BackupFileDecryptedContextualPayload,
NoteContent,
} from '@standardnotes/snjs';
function sanitizeFileName(name: string): string {
@@ -79,6 +78,7 @@ export class ArchiveManager {
const blob = new Blob([JSON.stringify(data, null, 2)], {
type: 'text/plain',
});
const fileName = zippableFileName('Standard Notes Backup and Import File');
await zipWriter.add(fileName, new zip.BlobReader(blob));
@@ -88,9 +88,9 @@ export class ArchiveManager {
let name, contents;
if (item.content_type === ContentType.Note) {
const note = item as SNNote;
name = (note.content as PayloadContent).title;
contents = (note.content as PayloadContent).text;
const note = item as BackupFileDecryptedContextualPayload<NoteContent>;
name = note.content.title;
contents = note.content.text;
} else {
name = item.content_type;
contents = JSON.stringify(item.content, null, 2);

View File

@@ -8,13 +8,11 @@ import {
removeFromArray,
DesktopManagerInterface,
PayloadSource,
EncryptionIntent,
CreateIntentPayloadFromObject,
InternalEventBus,
} from '@standardnotes/snjs';
import { WebAppEvent, WebApplication } from '@/ui_models/application';
import { isDesktopApplication } from '@/utils';
import { Bridge, ElectronDesktopCallbacks } from './bridge';
import { InternalEventBus } from '@standardnotes/services';
/**
* An interface used by the Desktop application to interact with SN
@@ -68,10 +66,7 @@ export class DesktopManager
* Keys are not passed into ItemParams, so the result is not encrypted
*/
convertComponentForTransmission(component: SNComponent) {
return CreateIntentPayloadFromObject(
component.payloadRepresentation(),
EncryptionIntent.FileDecrypted
);
return component.payloadRepresentation().ejected();
}
// All `components` should be installed
@@ -84,11 +79,7 @@ export class DesktopManager
return this.convertComponentForTransmission(component);
})
).then((payloads) => {
this.bridge.syncComponents(
payloads.filter(
(payload) => !payload.errorDecrypting && !payload.waitingForKey
)
);
this.bridge.syncComponents(payloads);
});
}
@@ -137,7 +128,7 @@ export class DesktopManager
return;
}
const updatedComponent = await this.application.mutator.changeAndSaveItem(
component.uuid,
component,
(m) => {
const mutator = m as ComponentMutator;
if (error) {

View File

@@ -1,7 +1,6 @@
import { WebApplication } from '@/ui_models/application';
import {
StorageValueModes,
EncryptionIntent,
ApplicationService,
SNTheme,
removeFromArray,
@@ -11,9 +10,9 @@ import {
FeatureStatus,
PayloadSource,
PrefKey,
CreateIntentPayloadFromObject,
CreateDecryptedLocalStorageContextPayload,
InternalEventBus,
} from '@standardnotes/snjs';
import { InternalEventBus } from '@standardnotes/services';
const CACHED_THEMES_KEY = 'cachedThemes';
@@ -156,9 +155,9 @@ export class ThemeManager extends ApplicationService {
const preference = prefersDarkColorScheme
? PrefKey.AutoDarkThemeIdentifier
: PrefKey.AutoLightThemeIdentifier;
const themes = this.application.items.getDisplayableItems(
const themes = this.application.items.getDisplayableItems<SNTheme>(
ContentType.Theme
) as SNTheme[];
);
const enableDefaultTheme = () => {
const activeTheme = themes.find(
@@ -206,7 +205,8 @@ export class ThemeManager extends ApplicationService {
this.unregisterStream = this.application.streamItems(
ContentType.Theme,
(items, source) => {
({ changed, inserted, source }) => {
const items = changed.concat(inserted);
const themes = items as SNTheme[];
for (const theme of themes) {
if (theme.active) {
@@ -275,10 +275,7 @@ export class ThemeManager extends ApplicationService {
const mapped = themes.map((theme) => {
const payload = theme.payloadRepresentation();
return CreateIntentPayloadFromObject(
payload,
EncryptionIntent.LocalStorageDecrypted
);
return CreateDecryptedLocalStorageContextPayload(payload);
});
return this.application.setValue(

View File

@@ -6,7 +6,12 @@ import {
observable,
runInAction,
} from 'mobx';
import { ApplicationEvent, ContentType, SNItem } from '@standardnotes/snjs';
import {
ApplicationEvent,
ContentType,
SNNote,
SNTag,
} from '@standardnotes/snjs';
import { WebApplication } from '@/ui_models/application';
import { AccountMenuPane } from '@/components/AccountMenu';
@@ -23,7 +28,7 @@ export class AccountMenuState {
otherSessionsSignOut = false;
server: string | undefined = undefined;
enableServerOption = false;
notesAndTags: SNItem[] = [];
notesAndTags: (SNNote | SNTag)[] = [];
isEncryptionEnabled = false;
encryptionStatusString = '';
isBackupEncrypted = false;

View File

@@ -8,13 +8,14 @@ import {
ContentType,
DeinitSource,
NoteViewController,
PayloadSource,
PrefKey,
SNNote,
SmartView,
SNTag,
SystemViewId,
removeFromArray,
PayloadSource,
Uuid,
} from '@standardnotes/snjs';
import {
action,
@@ -276,9 +277,9 @@ export class AppState {
this.application.noteControllerGroup.closeAllNoteViews();
}
noteControllerForNote(note: SNNote) {
noteControllerForNote(uuid: Uuid) {
for (const controller of this.getNoteControllers()) {
if (controller.note.uuid === note.uuid) {
if (controller.note.uuid === uuid) {
return controller;
}
}
@@ -328,38 +329,57 @@ export class AppState {
}
streamNotesAndTags() {
this.application.streamItems(
this.application.streamItems<SNNote | SNTag>(
[ContentType.Note, ContentType.Tag],
async (items, source) => {
async ({ changed, inserted, removed, source }) => {
if (
![PayloadSource.PreSyncSave, PayloadSource.RemoteRetrieved].includes(
source
)
) {
return;
}
const removedNotes = removed.filter(
(i) => i.content_type === ContentType.Note
);
for (const removedNote of removedNotes) {
const noteController = this.noteControllerForNote(removedNote.uuid);
if (noteController) {
this.closeNoteController(noteController);
}
}
const changedOrInserted = [...changed, ...inserted].filter(
(i) => i.content_type === ContentType.Note
);
const selectedTag = this.tags.selected;
/** Close any note controllers for deleted/trashed/archived notes */
if (source === PayloadSource.PreSyncSave) {
const notes = items.filter(
(candidate) => candidate.content_type === ContentType.Note
) as SNNote[];
for (const note of notes) {
const noteController = this.noteControllerForNote(note);
for (const note of changedOrInserted) {
const noteController = this.noteControllerForNote(note.uuid);
if (!noteController) {
continue;
}
if (note.deleted) {
this.closeNoteController(noteController);
} else if (
note.trashed &&
!(
const isBrowswingTrashedNotes =
selectedTag instanceof SmartView &&
selectedTag.uuid === SystemViewId.TrashedNotes
) &&
selectedTag.uuid === SystemViewId.TrashedNotes;
const isBrowsingArchivedNotes =
selectedTag instanceof SmartView &&
selectedTag.uuid === SystemViewId.ArchivedNotes;
if (
note.trashed &&
!isBrowswingTrashedNotes &&
!this.searchOptions.includeTrashed
) {
this.closeNoteController(noteController);
} else if (
note.archived &&
!(
selectedTag instanceof SmartView &&
selectedTag.uuid === SystemViewId.ArchivedNotes
) &&
!isBrowsingArchivedNotes &&
!this.searchOptions.includeArchived &&
!this.application.getPreference(PrefKey.NotesShowArchived, false)
) {
@@ -367,7 +387,6 @@ export class AppState {
}
}
}
}
);
}
@@ -436,9 +455,7 @@ export class AppState {
/** Returns the tags that are referncing this note */
public getNoteTags(note: SNNote) {
return this.application.items
.itemsReferencingItem(note.uuid)
.filter((ref) => {
return this.application.items.itemsReferencingItem(note).filter((ref) => {
return ref.content_type === ContentType.Tag;
}) as SNTag[];
}

View File

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

View File

@@ -60,15 +60,22 @@ export class NotesState {
});
appEventListeners.push(
application.streamItems(ContentType.Note, (notes) => {
application.streamItems<SNNote>(
ContentType.Note,
({ changed, inserted, removed }) => {
runInAction(() => {
for (const note of notes) {
for (const removedNote of removed) {
delete this.selectedNotes[removedNote.uuid];
}
for (const note of [...changed, ...inserted]) {
if (this.selectedNotes[note.uuid]) {
this.selectedNotes[note.uuid] = note as SNNote;
this.selectedNotes[note.uuid] = note;
}
}
});
})
}
)
);
}
@@ -85,9 +92,8 @@ export class NotesState {
}
private async selectNotesRange(selectedNote: SNNote): Promise<void> {
const notes = this.application.items.getDisplayableItems(
ContentType.Note
) as SNNote[];
const notes = this.application.items.getDisplayableNotes();
const lastSelectedNoteIndex = notes.findIndex(
(note) => note.uuid == this.lastSelectedNote?.uuid
);
@@ -179,10 +185,6 @@ export class NotesState {
this.appState.noteTags.reloadTags();
await this.onActiveEditorChanged();
if (note.waitingForKey) {
this.application.presentKeyRecoveryWizard();
}
}
setContextMenuOpen(open: boolean): void {
@@ -263,7 +265,7 @@ export class NotesState {
mutate: (mutator: NoteMutator) => void
): Promise<void> {
await this.application.mutator.changeItems(
Object.keys(this.selectedNotes),
Object.values(this.selectedNotes),
mutate,
false
);
@@ -399,7 +401,7 @@ export class NotesState {
async toggleGlobalSpellcheckForNote(note: SNNote) {
await this.application.mutator.changeItem<NoteMutator>(
note.uuid,
note,
(mutator) => {
mutator.toggleSpellcheck();
},
@@ -410,11 +412,11 @@ export class NotesState {
async addTagToSelectedNotes(tag: SNTag): Promise<void> {
const selectedNotes = Object.values(this.selectedNotes);
const parentChainTags = this.application.items.getTagParentChain(tag.uuid);
const parentChainTags = this.application.items.getTagParentChain(tag);
const tagsToAdd = [...parentChainTags, tag];
await Promise.all(
tagsToAdd.map(async (tag) => {
await this.application.mutator.changeItem(tag.uuid, (mutator) => {
await this.application.mutator.changeItem(tag, (mutator) => {
for (const note of selectedNotes) {
mutator.addItemAsRelationship(note);
}
@@ -426,7 +428,7 @@ export class NotesState {
async removeTagFromSelectedNotes(tag: SNTag): Promise<void> {
const selectedNotes = Object.values(this.selectedNotes);
await this.application.mutator.changeItem(tag.uuid, (mutator) => {
await this.application.mutator.changeItem(tag, (mutator) => {
for (const note of selectedNotes) {
mutator.removeItemAsRelationship(note);
}

View File

@@ -1,6 +1,7 @@
import {
ApplicationEvent,
CollectionSort,
CollectionSortProperty,
ContentType,
findInArray,
NotesDisplayCriteria,
@@ -28,7 +29,7 @@ const ELEMENT_ID_SEARCH_BAR = 'search-bar';
const ELEMENT_ID_SCROLL_CONTAINER = 'notes-scrollable';
export type DisplayOptions = {
sortBy: CollectionSort;
sortBy: CollectionSortProperty;
sortReverse: boolean;
hidePinned: boolean;
showArchived: boolean;
@@ -73,18 +74,20 @@ export class NotesViewState {
this.resetPagination();
appObservers.push(
application.streamItems(ContentType.Note, () => {
application.streamItems<SNNote>(ContentType.Note, () => {
this.reloadNotes();
const activeNote = this.appState.notes.activeNoteController?.note;
if (this.application.getAppState().notes.selectedNotesCount < 2) {
if (activeNote) {
const discarded = activeNote.deleted || activeNote.trashed;
if (
discarded &&
!(
const browsingTrashedNotes =
this.appState.selectedTag instanceof SmartView &&
this.appState.selectedTag?.uuid === SystemViewId.TrashedNotes
) &&
this.appState.selectedTag?.uuid === SystemViewId.TrashedNotes;
if (
activeNote.trashed &&
!browsingTrashedNotes &&
!this.appState?.searchOptions.includeTrashed
) {
this.selectNextOrCreateNew();
@@ -96,11 +99,15 @@ export class NotesViewState {
}
}
}),
application.streamItems([ContentType.Tag], async (items) => {
const tags = items as SNTag[];
application.streamItems<SNTag>(
[ContentType.Tag],
async ({ changed, inserted }) => {
const tags = [...changed, ...inserted];
/** A tag could have changed its relationships, so we need to reload the filter */
this.reloadNotesDisplayOptions();
this.reloadNotes();
if (
this.appState.selectedTag &&
findInArray(tags, 'uuid', this.appState.selectedTag.uuid)
@@ -108,7 +115,8 @@ export class NotesViewState {
/** Tag title could have changed */
this.reloadPanelTitle();
}
}),
}
),
application.addEventObserver(async () => {
this.reloadPreferences();
}, ApplicationEvent.PreferencesChanged),
@@ -223,9 +231,7 @@ export class NotesViewState {
if (!tag) {
return;
}
const notes = this.application.items.getDisplayableItems(
ContentType.Note
) as SNNote[];
const notes = this.application.items.getDisplayableNotes();
const renderedNotes = notes.slice(0, this.notesToDisplay);
this.notes = notes;
@@ -250,7 +256,7 @@ export class NotesViewState {
}
const criteria = NotesDisplayCriteria.Create({
sortProperty: this.displayOptions.sortBy as CollectionSort,
sortProperty: this.displayOptions.sortBy,
sortDirection: this.displayOptions.sortReverse ? 'asc' : 'dsc',
tags: tag instanceof SNTag ? [tag] : [],
views: tag instanceof SmartView ? [tag] : [],
@@ -498,7 +504,7 @@ export class NotesViewState {
handleEditorChange = async () => {
const activeNote = this.appState.getActiveNoteController()?.note;
if (activeNote && activeNote.conflictOf) {
this.application.mutator.changeAndSaveItem(activeNote.uuid, (mutator) => {
this.application.mutator.changeAndSaveItem(activeNote, (mutator) => {
mutator.conflictOf = undefined;
});
}

View File

@@ -14,6 +14,7 @@ import {
TagMutator,
UuidString,
isSystemView,
FindItem,
} from '@standardnotes/snjs';
import {
action,
@@ -29,11 +30,9 @@ import { FeaturesState, SMART_TAGS_FEATURE_NAME } from './features_state';
type AnyTag = SNTag | SmartView;
const rootTags = (application: SNApplication): SNTag[] => {
const hasNoParent = (tag: SNTag) => !application.items.getTagParent(tag.uuid);
const hasNoParent = (tag: SNTag) => !application.items.getTagParent(tag);
const allTags = application.items.getDisplayableItems(
ContentType.Tag
) as SNTag[];
const allTags = application.items.getDisplayableItems<SNTag>(ContentType.Tag);
const rootTags = allTags.filter(hasNoParent);
return rootTags;
@@ -44,10 +43,10 @@ const tagSiblings = (application: SNApplication, tag: SNTag): SNTag[] => {
tags.filter((other) => other.uuid !== tag.uuid);
const isTemplateTag = application.items.isTemplateItem(tag);
const parentTag = !isTemplateTag && application.items.getTagParent(tag.uuid);
const parentTag = !isTemplateTag && application.items.getTagParent(tag);
if (parentTag) {
const siblingsAndTag = application.items.getTagChildren(parentTag.uuid);
const siblingsAndTag = application.items.getTagChildren(parentTag);
return withoutCurrentTag(siblingsAndTag);
}
@@ -148,24 +147,24 @@ export class TagsState {
appEventListeners.push(
this.application.streamItems(
[ContentType.Tag, ContentType.SmartView],
(items) => {
({ changed, removed }) => {
runInAction(() => {
this.tags = this.application.items.getDisplayableItems<SNTag>(
ContentType.Tag
);
this.smartViews = this.application.items.getSmartViews();
const selectedTag = this.selected_;
if (selectedTag && !isSystemView(selectedTag as SmartView)) {
const matchingTag = items.find(
(candidate) => candidate.uuid === selectedTag.uuid
) as AnyTag;
if (matchingTag) {
if (matchingTag.deleted) {
if (FindItem(removed, selectedTag.uuid)) {
this.selected_ = this.smartViews[0];
} else {
this.selected_ = matchingTag;
}
const updated = FindItem(changed, selectedTag.uuid);
if (updated) {
this.selected_ = updated as AnyTag;
}
} else {
this.selected_ = this.smartViews[0];
@@ -202,7 +201,7 @@ export class TagsState {
title
)) as SNTag;
const futureSiblings = this.application.items.getTagChildren(parent.uuid);
const futureSiblings = this.application.items.getTagChildren(parent);
if (!isValidFutureSiblings(this.application, futureSiblings, createdTag)) {
this.setAddingSubtagTo(undefined);
@@ -319,7 +318,7 @@ export class TagsState {
return [];
}
const children = this.application.items.getTagChildren(tag.uuid);
const children = this.application.items.getTagChildren(tag);
const childrenUuids = children.map((childTag) => childTag.uuid);
const childrenTags = this.tags.filter((tag) =>
@@ -328,8 +327,8 @@ export class TagsState {
return childrenTags;
}
isValidTagParent(parentUuid: UuidString, tagUuid: UuidString): boolean {
return this.application.items.isValidTagParent(parentUuid, tagUuid);
isValidTagParent(parent: SNTag, tag: SNTag): boolean {
return this.application.items.isValidTagParent(parent, tag);
}
public hasParent(tagUuid: UuidString): boolean {
@@ -343,7 +342,7 @@ export class TagsState {
): Promise<void> {
const tag = this.application.items.findItem(tagUuid) as SNTag;
const currentParent = this.application.items.getTagParent(tag.uuid);
const currentParent = this.application.items.getTagParent(tag);
const currentParentUuid = currentParent?.uuid;
if (currentParentUuid === futureParentUuid) {
@@ -361,9 +360,8 @@ export class TagsState {
}
await this.application.mutator.unsetTagParent(tag);
} else {
const futureSiblings = this.application.items.getTagChildren(
futureParent.uuid
);
const futureSiblings =
this.application.items.getTagChildren(futureParent);
if (!isValidFutureSiblings(this.application, futureSiblings, tag)) {
return;
}
@@ -374,9 +372,7 @@ export class TagsState {
}
get rootTags(): SNTag[] {
return this.tags.filter(
(tag) => !this.application.items.getTagParent(tag.uuid)
);
return this.tags.filter((tag) => !this.application.items.getTagParent(tag));
}
get tagsCount(): number {
@@ -401,7 +397,7 @@ export class TagsState {
public set selected(tag: AnyTag | undefined) {
if (tag && tag.conflictOf) {
this.application.mutator.changeAndSaveItem(tag.uuid, (mutator) => {
this.application.mutator.changeAndSaveItem(tag, (mutator) => {
mutator.conflictOf = undefined;
});
}
@@ -417,12 +413,9 @@ export class TagsState {
}
public setExpanded(tag: SNTag, expanded: boolean) {
this.application.mutator.changeAndSaveItem<TagMutator>(
tag.uuid,
(mutator) => {
this.application.mutator.changeAndSaveItem<TagMutator>(tag, (mutator) => {
mutator.expanded = expanded;
}
);
});
}
public get selectedUuid(): UuidString | undefined {
@@ -527,7 +520,7 @@ export class TagsState {
});
} else {
await this.application.mutator.changeAndSaveItem<TagMutator>(
tag.uuid,
tag,
(mutator) => {
mutator.title = newTitle;
}
@@ -563,9 +556,7 @@ export class TagsState {
}
public get hasAtLeastOneFolder(): boolean {
return this.tags.some(
(tag) => !!this.application.items.getTagParent(tag.uuid)
);
return this.tags.some((tag) => !!this.application.items.getTagParent(tag));
}
}

View File

@@ -75,15 +75,16 @@ export class WebApplication extends SNApplication {
if (source === DeinitSource.AppGroupUnload) {
this.getThemeService().deactivateAllThemes();
}
for (const service of Object.values(this.webServices)) {
if ('deinit' in service) {
service.deinit?.(source);
}
(service as any).application = undefined;
}
this.webServices = {} as WebServices;
this.noteControllerGroup.deinit();
this.iconsController.deinit();
this.webEventObservers.length = 0;
if (source === DeinitSource.SignOut) {

View File

@@ -6,6 +6,7 @@ import {
DeviceInterface,
Platform,
Runtime,
InternalEventBus,
} from '@standardnotes/snjs';
import { AppState } from '@/ui_models/app_state';
import { Bridge } from '@/services/bridge';
@@ -16,7 +17,6 @@ import { IOService } from '@/services/ioService';
import { AutolockService } from '@/services/autolock_service';
import { StatusManager } from '@/services/statusManager';
import { ThemeManager } from '@/services/themeManager';
import { InternalEventBus } from '@standardnotes/services';
export class ApplicationGroup extends SNApplicationGroup {
constructor(

View File

@@ -1,6 +1,6 @@
{
"name": "standard-notes-web",
"version": "3.14.0",
"version": "3.15.0",
"license": "AGPL-3.0-or-later",
"repository": {
"type": "git",
@@ -26,11 +26,6 @@
"@babel/plugin-transform-react-jsx": "^7.17.3",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@reach/disclosure": "^0.16.2",
"@reach/visually-hidden": "^0.16.0",
"@standardnotes/responses": "1.5.1",
"@standardnotes/services": "1.7.1",
"@standardnotes/stylekit": "5.20.0",
"@svgr/webpack": "^6.2.1",
"@types/jest": "^27.4.1",
"@types/react": "^17.0.42",
@@ -65,26 +60,27 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@reach/alert": "^0.16.0",
"@reach/alert-dialog": "^0.16.2",
"@reach/alert": "^0.16.0",
"@reach/checkbox": "^0.16.0",
"@reach/dialog": "^0.16.2",
"@reach/disclosure": "^0.16.2",
"@reach/listbox": "^0.16.2",
"@reach/tooltip": "^0.16.2",
"@reach/visually-hidden": "^0.16.0",
"@standardnotes/components": "1.7.14",
"@standardnotes/features": "1.36.3",
"@standardnotes/filepicker": "1.10.4",
"@standardnotes/settings": "1.13.2",
"@standardnotes/sncrypto-web": "1.8.1",
"@standardnotes/snjs": "2.93.3",
"@standardnotes/filepicker": "1.10.5",
"@standardnotes/sncrypto-web": "1.8.2",
"@standardnotes/snjs": "2.94.3",
"@standardnotes/stylekit": "5.21.3",
"@zip.js/zip.js": "^2.4.7",
"mobx": "^6.5.0",
"mobx-react-lite": "^3.3.0",
"mobx": "^6.5.0",
"preact": "^10.6.6",
"qrcode.react": "^2.0.0",
"react-dnd": "^15.1.1",
"react-dnd-html5-backend": "^15.1.2",
"react-dnd-touch-backend": "^15.1.1"
"react-dnd-touch-backend": "^15.1.1",
"react-dnd": "^15.1.1"
},
"lint-staged": {
"app/**/*.{js,ts,jsx,tsx}": "eslint --cache --fix",

196
yarn.lock
View File

@@ -2388,132 +2388,122 @@
dependencies:
"@sinonjs/commons" "^1.7.0"
"@standardnotes/auth@^3.18.3":
version "3.18.3"
resolved "https://registry.yarnpkg.com/@standardnotes/auth/-/auth-3.18.3.tgz#2c2aa19ad56fc5f3f286dbef56bd8496d1e5380f"
integrity sha512-crdpVHJpnY574IIwBM1QcqNMULyvQ8nOnkH4DhFNcfWF7R+A+S4lMg2KxN9bR+j2gM/WWhbfcU8owJrz1+vsqA==
"@standardnotes/auth@^3.18.5":
version "3.18.5"
resolved "https://registry.yarnpkg.com/@standardnotes/auth/-/auth-3.18.5.tgz#11087e0bc31c42e489a7f546d317bbbcbd48d573"
integrity sha512-NSeU3A9iDyZFLLfv6jOyaweykMbjUUe0XoZo6lVifQucsRW0VJ4R6m3aeXqx6/zDwmHIBqVVzrX2bqQ7r2s9SA==
dependencies:
"@standardnotes/common" "^1.19.1"
"@standardnotes/common" "^1.19.3"
jsonwebtoken "^8.5.1"
"@standardnotes/common@^1.19.1":
version "1.19.1"
resolved "https://registry.yarnpkg.com/@standardnotes/common/-/common-1.19.1.tgz#45f0837b40bc1c583c22552a53429fe26c5ef498"
integrity sha512-O114ZdOvur6U1mmiPfvEo/TZjKRxHWBsAAAn+XTtS70E+2VqgvCwgiYT6bG1oUcoyrIiCdRPPyiTC/UPF4gkXg==
"@standardnotes/common@^1.19.3":
version "1.19.3"
resolved "https://registry.yarnpkg.com/@standardnotes/common/-/common-1.19.3.tgz#ae2ca493492eb5e0d9663abf736a9d7a26365c52"
integrity sha512-nMqH+grkIgnODr5EncbG9yHqIxSBHLVTiAb+NZ2EvkhLBiuVhP2UEDNs8KcZKfgNVGGDIHQbjEXZKGog9J6gZw==
"@standardnotes/components@1.7.14":
version "1.7.14"
resolved "https://registry.yarnpkg.com/@standardnotes/components/-/components-1.7.14.tgz#ddd5b4d5787d3f90a4e1a88cfd95995f9267b1d1"
integrity sha512-NDzP8/lmzgFBjxfmaE3OSOjPfozs3vednFfrjmjri5kCXlfClEISL6b/kh6B6wv/x9DIFveOsRj2Lrov+5IXdw==
"@standardnotes/domain-events@^2.26.6":
version "2.26.6"
resolved "https://registry.yarnpkg.com/@standardnotes/domain-events/-/domain-events-2.26.6.tgz#6d19099b147f60dfe69a458463aa81759846507a"
integrity sha512-CiF7MlFlZgwzMbOkcHGOy8FL1iGlSff9s7eUOlgOcYoidolFOF8HHJJn+d8+iwEvwANDwMJmrrGcFf5X9f0wzA==
"@standardnotes/domain-events@^2.26.9":
version "2.26.9"
resolved "https://registry.yarnpkg.com/@standardnotes/domain-events/-/domain-events-2.26.9.tgz#09d3ac547e263ff957a9a645a6c1f0039aa85ccd"
integrity sha512-iQCiCdLpMw3Yp3Z9q7GU9Z48tK2jAMI32VjsQtbyqOmjR+aVmo4e2oGyshm/2+5ymKUiG7xlx3Hl63RlQbGf1A==
dependencies:
"@standardnotes/auth" "^3.18.3"
"@standardnotes/features" "^1.36.3"
"@standardnotes/auth" "^3.18.5"
"@standardnotes/features" "^1.37.2"
"@standardnotes/encryption@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@standardnotes/encryption/-/encryption-1.1.3.tgz#7554a6268d8f274c59bb9dd55117ba7dffefb5cd"
integrity sha512-0oelxlDMCR8I6l33R/CsdU9z25R+kCvYLt0FbypPCRaDOMTcjITR1R+VsnKznw/GbcMxcD1TTnDGRRQyLVmDmw==
"@standardnotes/encryption@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@standardnotes/encryption/-/encryption-1.2.2.tgz#27325dff46875871c26e208d77651532573a7afc"
integrity sha512-B9RjWltLuURg6qUdFTQZeQRKX2DoP6VL/6kS2Ay3ZkrEEcCNvxeuqr9yvXbZn2kKS0dUDfzfbYWOvoVxyyUwYA==
dependencies:
"@standardnotes/models" "^1.1.1"
"@standardnotes/payloads" "^1.5.1"
"@standardnotes/responses" "^1.5.1"
"@standardnotes/services" "^1.7.1"
"@standardnotes/models" "^1.2.2"
"@standardnotes/responses" "^1.6.2"
"@standardnotes/services" "^1.8.2"
"@standardnotes/features@1.36.3", "@standardnotes/features@^1.36.3":
version "1.36.3"
resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.36.3.tgz#c3a2c2451fe2f036c5c94e51e86c804872028763"
integrity sha512-/38iTb22NULjtL8MitUeqsZdGwZgyP6t8p2LPc5sLFmeyU/CgZ22sh55GKAW5P/fm/oWyBqK6zjsVvtIH6AQug==
"@standardnotes/features@^1.37.2":
version "1.37.2"
resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.37.2.tgz#bedae2935a5659aa1fd30849e47ed167d45a7d3a"
integrity sha512-kNUCRMuLPmjjxWvE/OjHAewGZzv5/NAsqw/cHj+O4sbhRBWSv1dq+UzLzUxnj2kUsKObPjKqYeqo6WrXOnl3BQ==
dependencies:
"@standardnotes/auth" "^3.18.3"
"@standardnotes/common" "^1.19.1"
"@standardnotes/auth" "^3.18.5"
"@standardnotes/common" "^1.19.3"
"@standardnotes/filepicker@1.10.4":
version "1.10.4"
resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.10.4.tgz#a69822381dcb7910ce7ce9040bb0466b3b950985"
integrity sha512-BnfKi+HFXX1e/fprZ2awvcrBSQkVZs1VN/hk7e9hH8qhQtbktfURKEEyOZoQnDu14BMa1tSdAVTjhXpxlbRRcA==
"@standardnotes/filepicker@1.10.5":
version "1.10.5"
resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.10.5.tgz#28c7cc68cb3337940a52e19b1dea76af343f2852"
integrity sha512-Tl9mCW/qAzupOtQAYlbPHgZU16ljtRGV0awOHT7+uulPYoyKJJ4cqlKRzFaaONTAN6GpICEeSqidcB/lb5e5uQ==
"@standardnotes/models@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@standardnotes/models/-/models-1.1.1.tgz#1a54253ded5c759ac8eeb1cb2878da73da2bd8a3"
integrity sha512-tl6Yjv/hlPd1xARF4o8vHNPyfoV0d5V/IkdlPA0I2GQh7pLPxHirwD5E2+rRnv59HPiV4ws+XwLtnnPZaZ38bg==
"@standardnotes/models@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@standardnotes/models/-/models-1.2.2.tgz#d67086319ad12ec5f6d267f77d353a0bd3740983"
integrity sha512-o762wf4pOobk4GcHJR0+lFVJeP/TifiP4OCM9ko23wkE6d6tWpM5SyvOUyZga2NNp5He8Pkm06Oo1ObxBYaWIw==
dependencies:
"@standardnotes/payloads" "^1.5.1"
"@standardnotes/features" "^1.37.2"
"@standardnotes/responses" "^1.6.2"
"@standardnotes/utils" "^1.4.8"
"@standardnotes/payloads@^1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@standardnotes/payloads/-/payloads-1.5.1.tgz#f0cbe309721a14811d4b11cfce9a66d6fb9c2171"
integrity sha512-wqL31WPGFAQPMXICCf5Kxh3UOiaGbMu6ZE8cYmuZsMhti2h8FgIE04rcrzAh0/dSYtufrfHUnjhMmkPXZQAV2g==
"@standardnotes/responses@^1.6.2":
version "1.6.2"
resolved "https://registry.yarnpkg.com/@standardnotes/responses/-/responses-1.6.2.tgz#665702c01bd25f10763ef0230fe9df775996c424"
integrity sha512-w/SNFITk7aipmN1nahH456xe/xKGPp+/dqpKF+LDoSl6C+UZ17NOtSVP/Q4nVIvGy57QOD8OvN7inCpSrLCEyw==
dependencies:
"@standardnotes/common" "^1.19.1"
"@standardnotes/features" "^1.36.3"
"@standardnotes/utils" "^1.4.6"
"@standardnotes/auth" "^3.18.5"
"@standardnotes/common" "^1.19.3"
"@standardnotes/features" "^1.37.2"
"@standardnotes/responses@1.5.1", "@standardnotes/responses@^1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@standardnotes/responses/-/responses-1.5.1.tgz#a88171e0834ad363ce2284256f8630f8adee4ae3"
integrity sha512-8BodIxtIfSG9IEzCSQy2dmB9RR1FeoKYBwOrO4MKyX1TpvVPlr0dtGUxWtbt20kI49FSLU9QDeWeexNiXcDSrA==
"@standardnotes/services@^1.8.2":
version "1.8.2"
resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.8.2.tgz#3a95af1573636dc288dc4efd52de8568c2cd68fe"
integrity sha512-+iLVngtw0avyoUM4Sn0Kpmh99KTWYbhX/HiJLbnFoW5LJrqA2FarZRPUqYpiKuEcfcdZ4brmm5ipts45n1DXXw==
dependencies:
"@standardnotes/auth" "^3.18.3"
"@standardnotes/common" "^1.19.1"
"@standardnotes/features" "^1.36.3"
"@standardnotes/payloads" "^1.5.1"
"@standardnotes/common" "^1.19.3"
"@standardnotes/models" "^1.2.2"
"@standardnotes/responses" "^1.6.2"
"@standardnotes/utils" "^1.4.8"
"@standardnotes/services@1.7.1", "@standardnotes/services@^1.7.1":
version "1.7.1"
resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.7.1.tgz#7c3f8f379478dfeeec3b9c87868a380213947533"
integrity sha512-xW5C/nqUomwxnN2zSS22t845PPRceevUNqtwFtPzodeaDNZpCMwLvHPqJhbXW6cYuPeVbPGn4ify8EnrGqu+/w==
"@standardnotes/settings@^1.13.3":
version "1.13.3"
resolved "https://registry.yarnpkg.com/@standardnotes/settings/-/settings-1.13.3.tgz#6f46927f5cb85e3070ccd2bc6a91deadf1b9ef9f"
integrity sha512-hLb5ba8qFgKdhSYqJLX+7L5K2ZPwoqGlMrDDQTph+rQe08FnDoupCzz+uFOO1EJITI3XzrbvSW79GQYV0/5AkA==
"@standardnotes/sncrypto-common@^1.7.5":
version "1.7.5"
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.7.5.tgz#2c4ca3923970f5360f8ae01d40e2eaa957b75c12"
integrity sha512-VfGNDAlju4h7Ai7Z7shds41Lvl7JQruYc4pemkAzcmYgrXLHy/wHMUA0kanGTW7fVr3AYmbYCqO6lycldAmrwQ==
"@standardnotes/sncrypto-web@1.8.2":
version "1.8.2"
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-web/-/sncrypto-web-1.8.2.tgz#cf60a2ad85240e3ef56ccd5d1b45c29d16300966"
integrity sha512-C/2EkZrYBKTgnW4uluhJ3+GOnbbOL6ixg/c9pa2LZ9zT1vBRaS3vFIHC5hIMwrOsPE1QmIaJyiGtdzMA7A3VMw==
dependencies:
"@standardnotes/common" "^1.19.1"
"@standardnotes/models" "^1.1.1"
"@standardnotes/responses" "^1.5.1"
"@standardnotes/utils" "^1.4.6"
"@standardnotes/settings@1.13.2", "@standardnotes/settings@^1.13.2":
version "1.13.2"
resolved "https://registry.yarnpkg.com/@standardnotes/settings/-/settings-1.13.2.tgz#32509823e9f1b885282d5f6e82a6fed5178e5ec2"
integrity sha512-kA2K2/xfS3dlPF//yy2GitH6bfFf4EmvNQ77OWMn1qZdLlTl4HTGps1Q5mX/BrLfC9HNutxqnLFr1N94vxdWlQ==
"@standardnotes/sncrypto-common@^1.7.4":
version "1.7.4"
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.7.4.tgz#970fbe84edbdc9d632c8774ec201f1e140f693d6"
integrity sha512-6O4RjyfNyCFV32sYCO7jxDt/UelPfbvaMQXYPJ3F58r5gyFdc9K/PxjWmKhzRVxTprNLr+4uWbf1FUERTdTuhg==
"@standardnotes/sncrypto-web@1.8.1":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-web/-/sncrypto-web-1.8.1.tgz#4e8192be81c2b6da2d39d4119ea95ceeb24c49a0"
integrity sha512-lTuFu8WNmUh/9+OApgBj0IU55svXEK5gQRpE9Wdn49mzPZUQx7FrrkQ8piKDBrkpxFoaeQXXgNNWk3CwGQ8WCQ==
dependencies:
"@standardnotes/sncrypto-common" "^1.7.4"
"@standardnotes/sncrypto-common" "^1.7.5"
buffer "^6.0.3"
libsodium-wrappers "^0.7.9"
"@standardnotes/snjs@2.93.3":
version "2.93.3"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.93.3.tgz#528c257994b8602666af0d80930e55421d9d5946"
integrity sha512-XZS8vBDqc80lEYKndyNIiyZSPme1DU7H6XNCUBH5mt41CF8qvxv76eTFSxmi2oZNrNNujl/Ez1jb23F7oUEMrw==
"@standardnotes/snjs@2.94.3":
version "2.94.3"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.94.3.tgz#93918769025f4883f80555df61c88a838de1c4c3"
integrity sha512-wfJg8n/p1QisPlxWSyW9dYqN79/Zr16lugryHG0Tc1vXRyLcDNbaYxvo5XR3gGjsml8zARn5NdXJEkBBdPN2xA==
dependencies:
"@standardnotes/auth" "^3.18.3"
"@standardnotes/common" "^1.19.1"
"@standardnotes/domain-events" "^2.26.6"
"@standardnotes/encryption" "^1.1.3"
"@standardnotes/features" "^1.36.3"
"@standardnotes/models" "^1.1.1"
"@standardnotes/payloads" "^1.5.1"
"@standardnotes/responses" "^1.5.1"
"@standardnotes/services" "^1.7.1"
"@standardnotes/settings" "^1.13.2"
"@standardnotes/sncrypto-common" "^1.7.4"
"@standardnotes/utils" "^1.4.6"
"@standardnotes/auth" "^3.18.5"
"@standardnotes/common" "^1.19.3"
"@standardnotes/domain-events" "^2.26.9"
"@standardnotes/encryption" "^1.2.2"
"@standardnotes/features" "^1.37.2"
"@standardnotes/models" "^1.2.2"
"@standardnotes/responses" "^1.6.2"
"@standardnotes/services" "^1.8.2"
"@standardnotes/settings" "^1.13.3"
"@standardnotes/sncrypto-common" "^1.7.5"
"@standardnotes/utils" "^1.4.8"
"@standardnotes/stylekit@5.20.0":
version "5.20.0"
resolved "https://registry.yarnpkg.com/@standardnotes/stylekit/-/stylekit-5.20.0.tgz#84ad262b39cbe307a9e06ffa8eb05119db8a7adb"
integrity sha512-R926S0NlzB97wq6PyX978s1g21KSymX3CjQCmbM3tfV7KFXfNjjDdWSTVetC8exZj/BPvsudfOtNA5bVsJ8RkA==
"@standardnotes/stylekit@5.21.3":
version "5.21.3"
resolved "https://registry.yarnpkg.com/@standardnotes/stylekit/-/stylekit-5.21.3.tgz#32d136328e7ec04f983fe635ec507a05084f3aac"
integrity sha512-0ILhE/xtuGBbBuMRurdWDuHrtMvIoJoMwu/2wp+2WNlYzWbSzq/TQ3MYYBUUS76K/nerxJwr7kBtZeJpCdWccg==
dependencies:
"@nanostores/preact" "^0.1.3"
"@reach/listbox" "^0.16.2"
@@ -2524,12 +2514,12 @@
nanostores "^0.5.10"
prop-types "^15.8.1"
"@standardnotes/utils@^1.4.6":
version "1.4.6"
resolved "https://registry.yarnpkg.com/@standardnotes/utils/-/utils-1.4.6.tgz#19fadae46b594e301731989a836e1e9025ec4749"
integrity sha512-8k/ucqtfZd/tl7zBA5E988Kbo+9RiGq70ZNiXjvGhud8hX2JUfUtVqnpjTCIEChKyJhOJR3uVQZBHq9H9S0+lg==
"@standardnotes/utils@^1.4.8":
version "1.4.8"
resolved "https://registry.yarnpkg.com/@standardnotes/utils/-/utils-1.4.8.tgz#4c984220903bf64733961c50633de6adf62cb78f"
integrity sha512-sGROUIUdDncSyAb4w1O+qadJOTp18+9XO8MX08jOEPEMTfmVNFV1xYu6ZWe/0Ae4wCghBr8XeCCfVeE1XNyjTg==
dependencies:
"@standardnotes/common" "^1.19.1"
"@standardnotes/common" "^1.19.3"
dompurify "^2.3.6"
lodash "^4.17.21"