feat: Editing large notes (greater than 1.5MB) will result in more optimized syncing, in which changes are saved locally immediately, but sync with the server less frequently (roughly every 30 seconds rather than after every change). (#2768)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { MILLISECONDS_IN_A_SECOND } from '@/Constants/Constants'
|
||||
|
||||
export const EditorSaveTimeoutDebounce = {
|
||||
Desktop: 350,
|
||||
ImmediateChange: 100,
|
||||
NativeMobileWeb: 700,
|
||||
LargeNote: 60 * MILLISECONDS_IN_A_SECOND,
|
||||
}
|
||||
|
||||
@@ -104,6 +104,9 @@ export class ItemGroupController {
|
||||
controller: NoteViewController | FileViewController,
|
||||
{ notify = true }: { notify: boolean } = { notify: true },
|
||||
): void {
|
||||
if (controller instanceof NoteViewController) {
|
||||
controller.syncOnlyIfLargeNote()
|
||||
}
|
||||
controller.deinit()
|
||||
|
||||
removeFromArray(this.itemControllers, controller)
|
||||
|
||||
@@ -28,6 +28,9 @@ describe('note view controller', () => {
|
||||
createTemplateItem: jest.fn().mockReturnValue({} as SNNote),
|
||||
} as unknown as jest.Mocked<ItemManagerInterface>,
|
||||
mutator: {} as jest.Mocked<MutatorClientInterface>,
|
||||
sessions: {
|
||||
isSignedIn: jest.fn().mockReturnValue(true),
|
||||
},
|
||||
} as unknown as jest.Mocked<WebApplication>
|
||||
|
||||
application.isNativeMobileWeb = jest.fn().mockReturnValue(false)
|
||||
|
||||
@@ -25,6 +25,7 @@ import { TemplateNoteViewControllerOptions } from './TemplateNoteViewControllerO
|
||||
import { log, LoggingDomain } from '@/Logging'
|
||||
import { NoteSaveFunctionParams, NoteSyncController } from '../../../Controllers/NoteSyncController'
|
||||
import { IsNativeMobileWeb } from '@standardnotes/ui-services'
|
||||
import { NoteStatus } from '../NoteStatusIndicator'
|
||||
|
||||
export type EditorValues = {
|
||||
title: string
|
||||
@@ -219,4 +220,28 @@ export class NoteViewController implements ItemViewControllerInterface {
|
||||
|
||||
await this.syncController.saveAndAwaitLocalPropagation(params)
|
||||
}
|
||||
|
||||
public get syncStatus(): NoteStatus | undefined {
|
||||
return this.syncController.status
|
||||
}
|
||||
|
||||
public showSavingStatus(): void {
|
||||
this.syncController.showSavingStatus()
|
||||
}
|
||||
|
||||
public showAllChangesSavedStatus(): void {
|
||||
this.syncController.showAllChangesSavedStatus()
|
||||
}
|
||||
|
||||
public showErrorSyncStatus(error?: NoteStatus): void {
|
||||
this.syncController.showErrorStatus(error)
|
||||
}
|
||||
|
||||
public syncNow(): void {
|
||||
this.sync.sync().catch(console.error)
|
||||
}
|
||||
|
||||
public syncOnlyIfLargeNote(): void {
|
||||
this.syncController.syncOnlyIfLargeNote()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user