refactor: application dependency management (#2363)

This commit is contained in:
Mo
2023-07-23 15:54:31 -05:00
committed by GitHub
parent e698b1c990
commit a77535456c
299 changed files with 7415 additions and 4890 deletions

View File

@@ -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

View File

@@ -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
}

View File

@@ -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.`,
)

View File

@@ -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',

View File

@@ -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
}

View File

@@ -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

View File

@@ -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.',
)
}

View File

@@ -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)