refactor: application dependency management (#2363)
This commit is contained in:
@@ -28,7 +28,7 @@ export abstract class WebOrDesktopDevice implements WebOrDesktopDeviceInterface
|
||||
abstract environment: Environment
|
||||
|
||||
setApplication(application: SNApplication): void {
|
||||
const database = new Database(application.identifier, application.alertService)
|
||||
const database = new Database(application.identifier, application.alerts)
|
||||
|
||||
this.databases.push(database)
|
||||
}
|
||||
|
||||
@@ -115,20 +115,13 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
}
|
||||
|
||||
this.itemControllerGroup = new ItemGroupController(this)
|
||||
this.routeService = new RouteService(this, this.internalEventBus)
|
||||
this.routeService = new RouteService(this, this.events)
|
||||
|
||||
this.webServices = {} as WebServices
|
||||
this.webServices.keyboardService = new KeyboardService(platform, this.environment)
|
||||
this.webServices.archiveService = new ArchiveManager(this)
|
||||
this.webServices.themeService = new ThemeManager(
|
||||
this,
|
||||
this.preferences,
|
||||
this.componentManager,
|
||||
this.internalEventBus,
|
||||
)
|
||||
this.webServices.autolockService = this.isNativeMobileWeb()
|
||||
? undefined
|
||||
: new AutolockService(this, this.internalEventBus)
|
||||
this.webServices.themeService = new ThemeManager(this, this.preferences, this.componentManager, this.events)
|
||||
this.webServices.autolockService = this.isNativeMobileWeb() ? undefined : new AutolockService(this, this.events)
|
||||
this.webServices.desktopService = isDesktopDevice(deviceInterface)
|
||||
? new DesktopManager(this, deviceInterface, this.fileBackups as BackupServiceInterface)
|
||||
: undefined
|
||||
@@ -137,9 +130,9 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
this.webServices.momentsService = new MomentsService(
|
||||
this,
|
||||
this.webServices.viewControllerManager.filesController,
|
||||
this.internalEventBus,
|
||||
this.events,
|
||||
)
|
||||
this.webServices.vaultDisplayService = new VaultDisplayService(this, this.internalEventBus)
|
||||
this.webServices.vaultDisplayService = new VaultDisplayService(this, this.events)
|
||||
|
||||
if (this.isNativeMobileWeb()) {
|
||||
this.mobileWebReceiver = new MobileWebReceiver(this)
|
||||
@@ -219,7 +212,7 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
observer(event, data)
|
||||
}
|
||||
|
||||
this.internalEventBus.publish({ type: event, payload: data })
|
||||
this.events.publish({ type: event, payload: data })
|
||||
}
|
||||
|
||||
publishPanelDidResizeEvent(name: string, width: number, collapsed: boolean) {
|
||||
@@ -273,8 +266,8 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
}
|
||||
|
||||
public get desktopDevice(): DesktopDeviceInterface | undefined {
|
||||
if (isDesktopDevice(this.deviceInterface)) {
|
||||
return this.deviceInterface
|
||||
if (isDesktopDevice(this.device)) {
|
||||
return this.device
|
||||
}
|
||||
|
||||
return undefined
|
||||
@@ -300,11 +293,11 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
if (!this.isNativeMobileWeb()) {
|
||||
throw Error('Attempting to access device as mobile device on non mobile platform')
|
||||
}
|
||||
return this.deviceInterface as MobileDeviceInterface
|
||||
return this.device as MobileDeviceInterface
|
||||
}
|
||||
|
||||
webOrDesktopDevice(): WebOrDesktopDevice {
|
||||
return this.deviceInterface as WebOrDesktopDevice
|
||||
return this.device as WebOrDesktopDevice
|
||||
}
|
||||
|
||||
public getThemeService() {
|
||||
@@ -334,7 +327,7 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
}
|
||||
|
||||
public get version(): string {
|
||||
return (this.deviceInterface as WebOrDesktopDevice).appVersion
|
||||
return (this.device as WebOrDesktopDevice).appVersion
|
||||
}
|
||||
|
||||
async toggleGlobalSpellcheck() {
|
||||
|
||||
@@ -42,7 +42,7 @@ const AdvancedOptions: FunctionComponent<Props> = ({
|
||||
|
||||
if (!identifier) {
|
||||
if (privateUsername?.length > 0) {
|
||||
application.alertService.alert('Unable to compute private username.').catch(console.error)
|
||||
application.alerts.alert('Unable to compute private username.').catch(console.error)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ const GeneralAccountMenu: FunctionComponent<Props> = ({
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
application.alertService.alert(STRING_GENERIC_SYNC_ERROR).catch(console.error)
|
||||
application.alerts.alert(STRING_GENERIC_SYNC_ERROR).catch(console.error)
|
||||
})
|
||||
.finally(() => {
|
||||
setIsSyncingInProgress(false)
|
||||
|
||||
@@ -43,7 +43,7 @@ const WorkspaceSwitcherMenu: FunctionComponent<Props> = ({
|
||||
}, [mainApplicationGroup])
|
||||
|
||||
const signoutAll = useCallback(async () => {
|
||||
const confirmed = await viewControllerManager.application.alertService.confirm(
|
||||
const confirmed = await viewControllerManager.application.alerts.confirm(
|
||||
'Are you sure you want to sign out of all workspaces on this device?',
|
||||
undefined,
|
||||
'Sign out all',
|
||||
|
||||
@@ -322,7 +322,7 @@ const ChallengeModal: FunctionComponent<Props> = ({
|
||||
<Button
|
||||
className="flex min-w-76 items-center justify-center"
|
||||
onClick={() => {
|
||||
application.alertService
|
||||
application.alerts
|
||||
.confirm(
|
||||
'If you forgot your local passcode, your only option is to clear your local data from this device and sign back in to your account.',
|
||||
'Forgot passcode?',
|
||||
|
||||
@@ -119,7 +119,7 @@ const ChangeEditorMenu: FunctionComponent<ChangeEditorMenuProps> = ({
|
||||
}
|
||||
|
||||
if (note.locked) {
|
||||
application.alertService.alert(STRING_EDIT_LOCKED_ATTEMPT).catch(console.error)
|
||||
application.alerts.alert(STRING_EDIT_LOCKED_ATTEMPT).catch(console.error)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ const ChangeEditorMenu: FunctionComponent<ChangeEditorMenuProps> = ({
|
||||
closeMenu,
|
||||
onSelect,
|
||||
premiumModal,
|
||||
application.alertService,
|
||||
application.alerts,
|
||||
application.componentManager,
|
||||
setDisableClickOutside,
|
||||
currentFeature,
|
||||
|
||||
@@ -64,7 +64,7 @@ const ChangeEditorMultipleMenu = ({ application, notes, setDisableClickOutside }
|
||||
}
|
||||
|
||||
if (hasSelectedLockedNotes) {
|
||||
void application.alertService.alert(STRING_EDIT_LOCKED_ATTEMPT)
|
||||
void application.alerts.alert(STRING_EDIT_LOCKED_ATTEMPT)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ const ChangeEditorMultipleMenu = ({ application, notes, setDisableClickOutside }
|
||||
}
|
||||
},
|
||||
[
|
||||
application.alertService,
|
||||
application.alerts,
|
||||
application.componentManager,
|
||||
hasSelectedLockedNotes,
|
||||
notes,
|
||||
|
||||
@@ -329,7 +329,7 @@ class Footer extends AbstractComponent<Props, State> {
|
||||
this.setState({
|
||||
newUpdateAvailable: false,
|
||||
})
|
||||
this.application.alertService.alert(STRING_NEW_UPDATE_READY).catch(console.error)
|
||||
this.application.alerts.alert(STRING_NEW_UPDATE_READY).catch(console.error)
|
||||
}
|
||||
|
||||
betaMessageClickHandler = () => {
|
||||
|
||||
@@ -543,7 +543,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
}
|
||||
|
||||
hasAvailableExtensions() {
|
||||
return this.application.actionsManager.extensionsInContextOfItem(this.note).length > 0
|
||||
return this.application.actions.extensionsInContextOfItem(this.note).length > 0
|
||||
}
|
||||
|
||||
showSavingStatus() {
|
||||
@@ -636,12 +636,12 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
|
||||
async deleteNote(permanently: boolean) {
|
||||
if (this.controller.isTemplateNote) {
|
||||
this.application.alertService.alert(STRING_DELETE_PLACEHOLDER_ATTEMPT).catch(console.error)
|
||||
this.application.alerts.alert(STRING_DELETE_PLACEHOLDER_ATTEMPT).catch(console.error)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.note.locked) {
|
||||
this.application.alertService.alert(STRING_DELETE_LOCKED_ATTEMPT).catch(console.error)
|
||||
this.application.alerts.alert(STRING_DELETE_LOCKED_ATTEMPT).catch(console.error)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ const ListedMenuItem: FunctionComponent<ListedMenuItemProps> = ({
|
||||
|
||||
setIsRunning(true)
|
||||
|
||||
await application.actionsManager.runAction(action, note)
|
||||
await application.actions.runAction(action, note)
|
||||
|
||||
setIsRunning(false)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ const ConfirmOtherSessionsSignOut = observer(({ application, viewControllerManag
|
||||
const confirm = useCallback(() => {
|
||||
application.revokeAllOtherSessions().catch(console.error)
|
||||
closeDialog()
|
||||
application.alertService
|
||||
application.alerts
|
||||
.alert('You have successfully revoked your sessions from other devices.', undefined, 'Finish')
|
||||
.catch(console.error)
|
||||
}, [application, closeDialog])
|
||||
|
||||
@@ -137,16 +137,16 @@ class PasswordWizard extends AbstractComponent<Props, State> {
|
||||
const currentPassword = this.state.formData.currentPassword
|
||||
const newPass = this.state.formData.newPassword
|
||||
if (!currentPassword || currentPassword.length === 0) {
|
||||
this.application.alertService.alert('Please enter your current password.').catch(console.error)
|
||||
this.application.alerts.alert('Please enter your current password.').catch(console.error)
|
||||
return false
|
||||
}
|
||||
|
||||
if (!newPass || newPass.length === 0) {
|
||||
this.application.alertService.alert('Please enter a new password.').catch(console.error)
|
||||
this.application.alerts.alert('Please enter a new password.').catch(console.error)
|
||||
return false
|
||||
}
|
||||
if (newPass !== this.state.formData.newPasswordConfirmation) {
|
||||
this.application.alertService.alert('Your new password does not match its confirmation.').catch(console.error)
|
||||
this.application.alerts.alert('Your new password does not match its confirmation.').catch(console.error)
|
||||
this.setFormDataState({
|
||||
status: undefined,
|
||||
}).catch(console.error)
|
||||
@@ -154,7 +154,7 @@ class PasswordWizard extends AbstractComponent<Props, State> {
|
||||
}
|
||||
|
||||
if (!this.application.getUser()?.email) {
|
||||
this.application.alertService
|
||||
this.application.alerts
|
||||
.alert("We don't have your email stored. Please sign out then log back in to fix this issue.")
|
||||
.catch(console.error)
|
||||
this.setFormDataState({
|
||||
@@ -165,7 +165,7 @@ class PasswordWizard extends AbstractComponent<Props, State> {
|
||||
|
||||
const success = await this.application.validateAccountPassword(this.state.formData.currentPassword as string)
|
||||
if (!success) {
|
||||
this.application.alertService
|
||||
this.application.alerts
|
||||
.alert('The current password you entered is not correct. Please try again.')
|
||||
.catch(console.error)
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class PasswordWizard extends AbstractComponent<Props, State> {
|
||||
|
||||
dismiss = () => {
|
||||
if (this.state.processing) {
|
||||
this.application.alertService.alert('Cannot close window until pending tasks are complete.').catch(console.error)
|
||||
this.application.alerts.alert('Cannot close window until pending tasks are complete.').catch(console.error)
|
||||
} else {
|
||||
this.props.dismissModal()
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const ChangeEmail: FunctionComponent<Props> = ({ onCloseDialog, application }) =
|
||||
|
||||
useBeforeUnload()
|
||||
|
||||
const applicationAlertService = application.alertService
|
||||
const applicationAlertService = application.alerts
|
||||
|
||||
const validateCurrentPassword = useCallback(async () => {
|
||||
if (!currentPassword || currentPassword.length === 0) {
|
||||
|
||||
@@ -35,7 +35,7 @@ const Email: FunctionComponent<Props> = ({ application }: Props) => {
|
||||
await application.settings.updateSetting(settingName, payload, false)
|
||||
return true
|
||||
} catch (e) {
|
||||
application.alertService.alert(STRING_FAILED_TO_UPDATE_USER_SETTING).catch(console.error)
|
||||
application.alerts.alert(STRING_FAILED_TO_UPDATE_USER_SETTING).catch(console.error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ const InvitationsList = ({ subscriptionState, application }: Props) => {
|
||||
|
||||
const handleCancel = async (invitationUuid: string) => {
|
||||
if (lockContinue) {
|
||||
application.alertService.alert('Cancelation already in progress.').catch(console.error)
|
||||
application.alerts.alert('Cancelation already in progress.').catch(console.error)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -36,7 +36,7 @@ const InvitationsList = ({ subscriptionState, application }: Props) => {
|
||||
setLockContinue(false)
|
||||
|
||||
if (!success) {
|
||||
application.alertService
|
||||
application.alerts
|
||||
.alert('Could not cancel invitation. Please try again or contact support if the issue persists.')
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ const Invite: FunctionComponent<Props> = ({ onCloseDialog, application, subscrip
|
||||
|
||||
const validateInviteeEmail = useCallback(async () => {
|
||||
if (!isEmailValid(inviteeEmail)) {
|
||||
application.alertService
|
||||
application.alerts
|
||||
.alert('The email you entered has an invalid format. Please review your input and try again.')
|
||||
.catch(console.error)
|
||||
|
||||
@@ -42,15 +42,15 @@ const Invite: FunctionComponent<Props> = ({ onCloseDialog, application, subscrip
|
||||
}
|
||||
|
||||
return true
|
||||
}, [application.alertService, inviteeEmail])
|
||||
}, [application.alerts, inviteeEmail])
|
||||
|
||||
const handleDialogClose = useCallback(() => {
|
||||
if (lockContinue) {
|
||||
application.alertService.alert('Cannot close window until pending tasks are complete.').catch(console.error)
|
||||
application.alerts.alert('Cannot close window until pending tasks are complete.').catch(console.error)
|
||||
} else {
|
||||
onCloseDialog()
|
||||
}
|
||||
}, [application.alertService, lockContinue, onCloseDialog])
|
||||
}, [application.alerts, lockContinue, onCloseDialog])
|
||||
|
||||
const resetProgressState = () => {
|
||||
setSubmitButtonTitle(SubmitButtonTitles.Default)
|
||||
@@ -91,7 +91,7 @@ const Invite: FunctionComponent<Props> = ({ onCloseDialog, application, subscrip
|
||||
|
||||
const success = await processInvite()
|
||||
if (!success) {
|
||||
application.alertService
|
||||
application.alerts
|
||||
.alert('An error occurred while sending the invite. Please try again or contact support if the issue persists.')
|
||||
.catch(console.error)
|
||||
|
||||
@@ -104,7 +104,7 @@ const Invite: FunctionComponent<Props> = ({ onCloseDialog, application, subscrip
|
||||
setSubmitButtonTitle(SubmitButtonTitles.Finish)
|
||||
setCurrentStep(Steps.FinishStep)
|
||||
}, [
|
||||
application.alertService,
|
||||
application.alerts,
|
||||
currentStep,
|
||||
handleDialogClose,
|
||||
isContinuing,
|
||||
|
||||
@@ -26,7 +26,7 @@ const Sync: FunctionComponent<Props> = ({ application }: Props) => {
|
||||
})
|
||||
setIsSyncingInProgress(false)
|
||||
if (response && (response as any).error) {
|
||||
application.alertService.alert(STRING_GENERIC_SYNC_ERROR).catch(console.error)
|
||||
application.alerts.alert(STRING_GENERIC_SYNC_ERROR).catch(console.error)
|
||||
} else {
|
||||
setLastSyncDate(formatLastSyncDate(application.sync.getLastSyncDate() as Date))
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ const DataBackups = ({ application, viewControllerManager }: Props) => {
|
||||
|
||||
const readFile = async (file: File): Promise<any> => {
|
||||
if (file.type === 'application/zip') {
|
||||
application.alertService.alert(STRING_IMPORTING_ZIP_FILE).catch(console.error)
|
||||
application.alerts.alert(STRING_IMPORTING_ZIP_FILE).catch(console.error)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ const DataBackups = ({ application, viewControllerManager }: Props) => {
|
||||
const data = JSON.parse(e.target?.result as string)
|
||||
resolve(data)
|
||||
} catch (e) {
|
||||
application.alertService.alert(STRING_INVALID_IMPORT_FILE).catch(console.error)
|
||||
application.alerts.alert(STRING_INVALID_IMPORT_FILE).catch(console.error)
|
||||
}
|
||||
}
|
||||
reader.readAsText(file)
|
||||
@@ -146,7 +146,7 @@ const DataBackups = ({ application, viewControllerManager }: Props) => {
|
||||
return
|
||||
}
|
||||
|
||||
if (application.encryptionService.supportedVersions().includes(version)) {
|
||||
if (application.encryption.supportedVersions().includes(version)) {
|
||||
await performImport(data)
|
||||
} else {
|
||||
setIsImportDataLoading(false)
|
||||
|
||||
@@ -72,7 +72,7 @@ const EmailBackups = ({ application }: Props) => {
|
||||
await application.settings.updateSetting(settingName, payload, false)
|
||||
return true
|
||||
} catch (e) {
|
||||
application.alertService.alert(STRING_FAILED_TO_UPDATE_USER_SETTING).catch(console.error)
|
||||
application.alerts.alert(STRING_FAILED_TO_UPDATE_USER_SETTING).catch(console.error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ const BackupsDropZone: FunctionComponent<Props> = ({ application }) => {
|
||||
const result = await application.files.readBackupFileAndSaveDecrypted(binaryFile, decryptedFileItem, fileSystem)
|
||||
|
||||
if (result === 'success') {
|
||||
void application.alertService.alert(
|
||||
void application.alerts.alert(
|
||||
`<strong>${decryptedFileItem.name}</strong> has been successfully decrypted and saved to your chosen directory.`,
|
||||
)
|
||||
setBinaryFile(undefined)
|
||||
setDecryptedFileItem(undefined)
|
||||
setDroppedFile(undefined)
|
||||
} else if (result === 'failed') {
|
||||
void application.alertService.alert(
|
||||
void application.alerts.alert(
|
||||
'Unable to save file to local directory. This may be caused by failure to decrypt, or failure to save the file locally.',
|
||||
)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ const BackupsDropZone: FunctionComponent<Props> = ({ application }) => {
|
||||
}
|
||||
|
||||
if (type === 'binary') {
|
||||
void application.alertService.alert('Please drag the metadata file instead of the encrypted data file.')
|
||||
void application.alerts.alert('Please drag the metadata file instead of the encrypted data file.')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ const BackupsDropZone: FunctionComponent<Props> = ({ application }) => {
|
||||
console.error(error)
|
||||
}
|
||||
},
|
||||
[application.alertService, application.files],
|
||||
[application.alerts, application.files],
|
||||
)
|
||||
|
||||
const handleDragOver = useCallback((event: DragEvent) => {
|
||||
|
||||
@@ -41,7 +41,7 @@ const OfflineSubscription: FunctionComponent<Props> = ({ application, onSuccess
|
||||
|
||||
if (homeServerEnabled) {
|
||||
if (!homeServerIsRunning) {
|
||||
await application.alertService.alert('Please start your home server before activating offline features.')
|
||||
await application.alerts.alert('Please start your home server before activating offline features.')
|
||||
|
||||
return
|
||||
}
|
||||
@@ -53,7 +53,7 @@ const OfflineSubscription: FunctionComponent<Props> = ({ application, onSuccess
|
||||
|
||||
const serverActivationResult = await homeServer.activatePremiumFeatures(signedInUser.email)
|
||||
if (serverActivationResult.isFailed()) {
|
||||
await application.alertService.alert(serverActivationResult.getError())
|
||||
await application.alerts.alert(serverActivationResult.getError())
|
||||
|
||||
return
|
||||
}
|
||||
@@ -62,7 +62,7 @@ const OfflineSubscription: FunctionComponent<Props> = ({ application, onSuccess
|
||||
const result = await application.features.setOfflineFeaturesCode(activationCode)
|
||||
|
||||
if (result instanceof ClientDisplayableError) {
|
||||
await application.alertService.alert(result.text)
|
||||
await application.alerts.alert(result.text)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -85,7 +85,7 @@ const OfflineSubscription: FunctionComponent<Props> = ({ application, onSuccess
|
||||
}
|
||||
|
||||
const handleRemoveClick = async () => {
|
||||
application.alertService
|
||||
application.alerts
|
||||
.confirm(
|
||||
STRING_REMOVE_OFFLINE_KEY_CONFIRMATION,
|
||||
'Remove offline key?',
|
||||
@@ -99,7 +99,7 @@ const OfflineSubscription: FunctionComponent<Props> = ({ application, onSuccess
|
||||
}
|
||||
})
|
||||
.catch((err: string) => {
|
||||
application.alertService.alert(err).catch(console.error)
|
||||
application.alerts.alert(err).catch(console.error)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ const PackagesPreferencesSection: FunctionComponent<Props> = ({
|
||||
}, [confirmableExtension, confirmableEnd])
|
||||
|
||||
const uninstallExtension = async (extension: AnyPackageType) => {
|
||||
application.alertService
|
||||
application.alerts
|
||||
.confirm(
|
||||
'Are you sure you want to uninstall this plugin? Note that plugins managed by your subscription will automatically be re-installed on application restart.',
|
||||
'Uninstall Extension?',
|
||||
@@ -58,7 +58,7 @@ const PackagesPreferencesSection: FunctionComponent<Props> = ({
|
||||
}
|
||||
})
|
||||
.catch((err: string) => {
|
||||
application.alertService.alert(err).catch(console.error)
|
||||
application.alerts.alert(err).catch(console.error)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ const Listed = ({ application }: Props) => {
|
||||
const requestAccount = async () => {
|
||||
const account = await application.listed.requestNewListedAccount()
|
||||
if (account) {
|
||||
const openSettings = await application.alertService.confirm(
|
||||
const openSettings = await application.alerts.confirm(
|
||||
'Your new Listed blog has been successfully created!' +
|
||||
' You can publish a new post to your blog from Standard Notes via the' +
|
||||
' <i>Actions</i> menu in the editor pane. Open your blog settings to begin setting it up.',
|
||||
@@ -47,7 +47,7 @@ const Listed = ({ application }: Props) => {
|
||||
if (openSettings) {
|
||||
const info = await application.listed.getListedAccountInfo(account)
|
||||
if (info) {
|
||||
application.deviceInterface.openUrl(info?.settings_url)
|
||||
application.device.openUrl(info?.settings_url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ const BiometricsLock = ({ application }: Props) => {
|
||||
|
||||
const hasBiometricsSupport = async () => {
|
||||
const hasBiometricsAvailable = await (
|
||||
application.deviceInterface as MobileDeviceInterface
|
||||
application.device as MobileDeviceInterface
|
||||
).getDeviceBiometricsAvailability?.()
|
||||
setSupportsBiometrics(hasBiometricsAvailable)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ const ErroredItems: FunctionComponent = () => {
|
||||
}
|
||||
|
||||
const deleteItems = async (items: EncryptedItemInterface[]): Promise<void> => {
|
||||
const confirmed = await application.alertService.confirm(
|
||||
const confirmed = await application.alerts.confirm(
|
||||
`Are you sure you want to permanently delete ${items.length} item(s)?`,
|
||||
undefined,
|
||||
'Delete',
|
||||
@@ -58,7 +58,7 @@ const ErroredItems: FunctionComponent = () => {
|
||||
const errorOrTrue = application.canAttemptDecryptionOfItem(item)
|
||||
|
||||
if (errorOrTrue instanceof ClientDisplayableError) {
|
||||
void application.alertService.showErrorAlert(errorOrTrue)
|
||||
void application.alerts.showErrorAlert(errorOrTrue)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const MultitaskingPrivacy = ({ application }: Props) => {
|
||||
setHasScreenshotPrivacy(enable)
|
||||
|
||||
application.protections.setMobileScreenshotPrivacyEnabled(enable)
|
||||
;(application.deviceInterface as MobileDeviceInterface).setAndroidScreenshotPrivacy(enable)
|
||||
;(application.device as MobileDeviceInterface).setAndroidScreenshotPrivacy(enable)
|
||||
}
|
||||
|
||||
const screenshotPrivacyFeatureText = isIOS() ? 'Multitasking Privacy' : 'Multitasking/Screenshot Privacy'
|
||||
|
||||
@@ -24,7 +24,7 @@ const Privacy: FunctionComponent<Props> = ({ application }: Props) => {
|
||||
await application.settings.updateSetting(settingName, payload, false)
|
||||
return true
|
||||
} catch (e) {
|
||||
application.alertService.alert(STRING_FAILED_TO_UPDATE_USER_SETTING).catch(console.error)
|
||||
application.alerts.alert(STRING_FAILED_TO_UPDATE_USER_SETTING).catch(console.error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,18 +51,10 @@ const EditContactModal: FunctionComponent<Props> = ({ onCloseDialog, fromInvite,
|
||||
onAddContact?.(contact)
|
||||
handleDialogClose()
|
||||
} else {
|
||||
void application.alertService.alert('Unable to create contact. Please try again.')
|
||||
void application.alerts.alert('Unable to create contact. Please try again.')
|
||||
}
|
||||
}
|
||||
}, [
|
||||
editingContact,
|
||||
application.contacts,
|
||||
application.alertService,
|
||||
name,
|
||||
collaborationID,
|
||||
handleDialogClose,
|
||||
onAddContact,
|
||||
])
|
||||
}, [editingContact, application.contacts, application.alerts, name, collaborationID, handleDialogClose, onAddContact])
|
||||
|
||||
const modalActions = useMemo(
|
||||
(): ModalAction[] => [
|
||||
|
||||
@@ -92,7 +92,7 @@ const CreateAccount: FunctionComponent<Props> = ({ viewControllerManager, applic
|
||||
void viewControllerManager.purchaseFlowController.openPurchaseFlow()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
application.alertService.alert(err as string).catch(console.error)
|
||||
application.alerts.alert(err as string).catch(console.error)
|
||||
} finally {
|
||||
setIsCreatingAccount(false)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ const SignIn: FunctionComponent<Props> = ({ viewControllerManager, application }
|
||||
setOtherErrorMessage('Invalid email or password.')
|
||||
setPassword('')
|
||||
} else {
|
||||
application.alertService.alert(err as string).catch(console.error)
|
||||
application.alerts.alert(err as string).catch(console.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ const SuperNoteConverter = ({
|
||||
}, [isSeamlessConvert, confirmConvert])
|
||||
|
||||
const convertAsIs = useCallback(async () => {
|
||||
const confirmed = await application.alertService.confirm(
|
||||
const confirmed = await application.alerts.confirm(
|
||||
spaceSeparatedStrings(
|
||||
"This option is useful if you want to edit the note's content which is in Super's JSON format directly.",
|
||||
'This format is not human-readable. If you want to convert the note to a human-readable format, please use the "Convert" option instead.',
|
||||
|
||||
@@ -60,7 +60,7 @@ export const SuperNoteImporter: FunctionComponent<Props> = ({ note, application,
|
||||
}, [isSeamlessConvert, confirmConvert])
|
||||
|
||||
const convertAsIs = useCallback(async () => {
|
||||
const confirmed = await application.alertService.confirm(
|
||||
const confirmed = await application.alerts.confirm(
|
||||
spaceSeparatedStrings(
|
||||
"This option is useful if you switched this note's type from Super to another plaintext-based format, and want to return to Super.",
|
||||
'To use this option, the preview in the convert window should display a language format known as JSON.',
|
||||
|
||||
@@ -32,7 +32,7 @@ const TagsSection: FunctionComponent<Props> = ({ viewControllerManager }) => {
|
||||
|
||||
const runMigration = useCallback(async () => {
|
||||
if (
|
||||
await viewControllerManager.application.alertService.confirm(
|
||||
await viewControllerManager.application.alerts.confirm(
|
||||
'<i>Introducing native, built-in nested tags without requiring the legacy Folders extension.</i><br/></br> ' +
|
||||
" To get started, we'll need to migrate any tags containing a dot character to the new system.<br/></br> " +
|
||||
' This migration will convert any tags with dots appearing in their name into a natural' +
|
||||
|
||||
@@ -123,7 +123,7 @@ export const StringUtils = {
|
||||
if (!application.hasAccount()) {
|
||||
return null
|
||||
}
|
||||
const platform = getPlatform(application.deviceInterface)
|
||||
const platform = getPlatform(application.device)
|
||||
const keychainName =
|
||||
platform === Platform.WindowsDesktop
|
||||
? 'credential manager'
|
||||
|
||||
@@ -326,7 +326,7 @@ export class FilesController extends AbstractViewController<FilesControllerEvent
|
||||
|
||||
alertIfFileExceedsSizeLimit = (file: File): boolean => {
|
||||
if (!this.shouldUseStreamingReader && this.maxFileSize && file.size >= this.maxFileSize) {
|
||||
this.application.alertService
|
||||
this.application.alerts
|
||||
.alert(
|
||||
`This file exceeds the limits supported in this browser. To upload files greater than ${
|
||||
this.maxFileSize / BYTES_IN_ONE_MEGABYTE
|
||||
|
||||
@@ -653,7 +653,7 @@ export class NavigationController
|
||||
if (isTemplateChange) {
|
||||
this.undoCreateNewTag()
|
||||
}
|
||||
this.application.alertService?.alert('A tag with this name already exists.').catch(console.error)
|
||||
this.application.alerts?.alert('A tag with this name already exists.').catch(console.error)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export const isValidFutureSiblings = (application: SNApplication, futureSiblings
|
||||
const siblingWithSameName = futureSiblings.find((otherTag) => otherTag.title === tag.title)
|
||||
|
||||
if (siblingWithSameName) {
|
||||
application.alertService
|
||||
application.alerts
|
||||
?.alert(
|
||||
`A tag with the name ${tag.title} already exists at this destination. Please rename this tag before moving and try again.`,
|
||||
)
|
||||
|
||||
@@ -162,7 +162,7 @@ export class NoteHistoryController {
|
||||
|
||||
this.setSelectedEntry(entry)
|
||||
|
||||
const response = await this.application.actionsManager.runAction(entry.subactions[0], this.note)
|
||||
const response = await this.application.actions.runAction(entry.subactions[0], this.note)
|
||||
|
||||
if (!response) {
|
||||
throw new Error('Could not fetch revision')
|
||||
@@ -261,14 +261,14 @@ export class NoteHistoryController {
|
||||
}
|
||||
|
||||
fetchLegacyHistory = async () => {
|
||||
const actionExtensions = this.application.actionsManager.getExtensions()
|
||||
const actionExtensions = this.application.actions.getExtensions()
|
||||
|
||||
actionExtensions.forEach(async (ext) => {
|
||||
if (!this.note) {
|
||||
return
|
||||
}
|
||||
|
||||
const actionExtension = await this.application.actionsManager.loadExtensionInContextOfItem(ext, this.note)
|
||||
const actionExtension = await this.application.actions.loadExtensionInContextOfItem(ext, this.note)
|
||||
|
||||
if (!actionExtension) {
|
||||
return
|
||||
@@ -297,7 +297,7 @@ export class NoteHistoryController {
|
||||
|
||||
this.setSessionHistory(
|
||||
sortRevisionListIntoGroups<NoteHistoryEntry>(
|
||||
this.application.historyManager.sessionHistoryForItem(this.note) as NoteHistoryEntry[],
|
||||
this.application.history.sessionHistoryForItem(this.note) as NoteHistoryEntry[],
|
||||
),
|
||||
)
|
||||
await this.fetchRemoteHistory()
|
||||
@@ -316,7 +316,7 @@ export class NoteHistoryController {
|
||||
const originalNote = this.application.items.findItem<SNNote>(revision.payload.uuid)
|
||||
|
||||
if (originalNote?.locked) {
|
||||
this.application.alertService.alert(STRING_RESTORE_LOCKED_ATTEMPT).catch(console.error)
|
||||
this.application.alerts.alert(STRING_RESTORE_LOCKED_ATTEMPT).catch(console.error)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ export class NoteHistoryController {
|
||||
}
|
||||
|
||||
deleteRemoteRevision = async (revisionEntry: RevisionMetadata) => {
|
||||
const shouldDelete = await this.application.alertService.confirm(
|
||||
const shouldDelete = await this.application.alerts.confirm(
|
||||
'Are you sure you want to delete this revision?',
|
||||
'Delete revision?',
|
||||
'Delete revision',
|
||||
|
||||
@@ -74,7 +74,7 @@ export class NoteSyncController {
|
||||
|
||||
private async undebouncedSave(params: NoteSaveFunctionParams): Promise<void> {
|
||||
if (!this.application.items.findItem(this.item.uuid)) {
|
||||
void this.application.alertService.alert(InfoStrings.InvalidNote)
|
||||
void this.application.alerts.alert(InfoStrings.InvalidNote)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ export class NotesController extends AbstractViewController implements NotesCont
|
||||
async deleteNotes(permanently: boolean): Promise<boolean> {
|
||||
if (this.getSelectedNotesList().some((note) => note.locked)) {
|
||||
const text = StringUtils.deleteLockedNotesAttempt(this.selectedNotesCount)
|
||||
this.application.alertService.alert(text).catch(console.error)
|
||||
this.application.alerts.alert(text).catch(console.error)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ export class NotesController extends AbstractViewController implements NotesCont
|
||||
|
||||
async setArchiveSelectedNotes(archived: boolean): Promise<void> {
|
||||
if (this.getSelectedNotesList().some((note) => note.locked)) {
|
||||
this.application.alertService
|
||||
this.application.alerts
|
||||
.alert(StringUtils.archiveLockedNotesAttempt(archived, this.selectedNotesCount))
|
||||
.catch(console.error)
|
||||
return
|
||||
|
||||
@@ -44,7 +44,7 @@ export class PurchaseFlowController extends AbstractViewController {
|
||||
openPurchaseWebpage = () => {
|
||||
loadPurchaseFlowUrl(this.application).catch((err) => {
|
||||
console.error(err)
|
||||
this.application.alertService.alert(err).catch(console.error)
|
||||
this.application.alerts.alert(err).catch(console.error)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ export class PurchaseFlowController extends AbstractViewController {
|
||||
log(LoggingDomain.Purchasing, 'BeginIosIapPurchaseFlow result', result)
|
||||
|
||||
if (!result) {
|
||||
void this.application.alertService.alert('Your purchase was canceled or failed. Please try again.')
|
||||
void this.application.alerts.alert('Your purchase was canceled or failed. Please try again.')
|
||||
return
|
||||
}
|
||||
|
||||
const showGenericError = () => {
|
||||
void this.application.alertService.alert(
|
||||
void this.application.alerts.alert(
|
||||
'There was an error confirming your purchase. Please contact support at help@standardnotes.com.',
|
||||
)
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export class ViewControllerManager implements InternalEventHandlerInterface {
|
||||
private toastService: ToastServiceInterface
|
||||
|
||||
constructor(public application: WebApplication, private device: WebOrDesktopDeviceInterface) {
|
||||
const eventBus = application.internalEventBus
|
||||
const eventBus = application.events
|
||||
|
||||
this.persistenceService = new PersistenceService(application, eventBus)
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import {
|
||||
ApplicationEvent,
|
||||
SessionsClientInterface,
|
||||
SubscriptionManagerInterface,
|
||||
SyncClientInterface,
|
||||
SyncOpStatus,
|
||||
SyncServiceInterface,
|
||||
User,
|
||||
UserClientInterface,
|
||||
UserRequestType,
|
||||
@@ -37,7 +37,7 @@ describe('ApplicationEventObserver', () => {
|
||||
let accountMenuController: AccountMenuController
|
||||
let preferencesController: PreferencesController
|
||||
let syncStatusController: SyncStatusController
|
||||
let syncClient: SyncClientInterface
|
||||
let syncClient: SyncServiceInterface
|
||||
let sessionManager: SessionsClientInterface
|
||||
let subscriptionManager: SubscriptionManagerInterface
|
||||
let toastService: ToastServiceInterface
|
||||
@@ -81,7 +81,7 @@ describe('ApplicationEventObserver', () => {
|
||||
syncStatusController = {} as jest.Mocked<SyncStatusController>
|
||||
syncStatusController.update = jest.fn()
|
||||
|
||||
syncClient = {} as jest.Mocked<SyncClientInterface>
|
||||
syncClient = {} as jest.Mocked<SyncServiceInterface>
|
||||
syncClient.getSyncStatus = jest.fn().mockReturnValue({} as jest.Mocked<SyncOpStatus>)
|
||||
|
||||
sessionManager = {} as jest.Mocked<SessionsClientInterface>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
ApplicationEvent,
|
||||
SessionsClientInterface,
|
||||
SubscriptionManagerInterface,
|
||||
SyncClientInterface,
|
||||
SyncServiceInterface,
|
||||
UserClientInterface,
|
||||
} from '@standardnotes/snjs'
|
||||
import { ToastType } from '@standardnotes/toast'
|
||||
@@ -33,7 +33,7 @@ export class ApplicationEventObserver implements EventObserverInterface {
|
||||
private accountMenuController: AccountMenuController,
|
||||
private preferencesController: PreferencesController,
|
||||
private syncStatusController: SyncStatusController,
|
||||
private syncClient: SyncClientInterface,
|
||||
private syncClient: SyncServiceInterface,
|
||||
private sessionManager: SessionsClientInterface,
|
||||
private subscriptionManager: SubscriptionManagerInterface,
|
||||
private toastService: ToastServiceInterface,
|
||||
|
||||
@@ -9,12 +9,12 @@ export async function openSubscriptionDashboard(application: WebApplicationInter
|
||||
|
||||
const url = `${window.dashboardUrl}?subscription_token=${token}`
|
||||
|
||||
if (application.deviceInterface.environment === Environment.Mobile) {
|
||||
application.deviceInterface.openUrl(url)
|
||||
if (application.device.environment === Environment.Mobile) {
|
||||
application.device.openUrl(url)
|
||||
return
|
||||
}
|
||||
|
||||
if (application.deviceInterface.environment === Environment.Desktop) {
|
||||
if (application.device.environment === Environment.Desktop) {
|
||||
window.open(url, '_blank')
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user