internal: incomplete vault systems behind feature flag (#2340)

This commit is contained in:
Mo
2023-06-30 09:01:56 -05:00
committed by GitHub
parent d16e401bb9
commit b032eb9c9b
638 changed files with 20321 additions and 4813 deletions

View File

@@ -13,11 +13,11 @@ import {
assert,
DesktopClientRequiresWebMethods,
DesktopDeviceInterface,
WebApplicationInterface,
WebAppEvent,
BackupServiceInterface,
DesktopWatchedDirectoriesChanges,
} from '@standardnotes/snjs'
import { WebApplicationInterface } from '@standardnotes/ui-services'
export class DesktopManager
extends ApplicationService
@@ -175,7 +175,7 @@ export class DesktopManager
return
}
const updatedComponent = await this.application.mutator.changeAndSaveItem(
const updatedComponent = await this.application.changeAndSaveItem(
component,
(m) => {
const mutator = m as ComponentMutator

View File

@@ -108,29 +108,46 @@ export abstract class WebOrDesktopDevice implements WebOrDesktopDeviceInterface
identifier: string,
): Promise<DatabaseFullEntryLoadChunkResponse> {
const entries = await this.getAllDatabaseEntries(identifier)
const sorted = GetSortedPayloadsByPriority(entries, options)
const {
itemsKeyPayloads,
keySystemRootKeyPayloads,
keySystemItemsKeyPayloads,
contentTypePriorityPayloads,
remainingPayloads,
} = GetSortedPayloadsByPriority(entries, options)
const itemsKeysChunk: DatabaseFullEntryLoadChunk = {
entries: sorted.itemsKeyPayloads,
entries: itemsKeyPayloads,
}
const keySystemRootKeysChunk: DatabaseFullEntryLoadChunk = {
entries: keySystemRootKeyPayloads,
}
const keySystemItemsKeysChunk: DatabaseFullEntryLoadChunk = {
entries: keySystemItemsKeyPayloads,
}
const contentTypePriorityChunk: DatabaseFullEntryLoadChunk = {
entries: sorted.contentTypePriorityPayloads,
entries: contentTypePriorityPayloads,
}
const remainingPayloadsChunks: DatabaseFullEntryLoadChunk[] = []
for (let i = 0; i < sorted.remainingPayloads.length; i += options.batchSize) {
for (let i = 0; i < remainingPayloads.length; i += options.batchSize) {
remainingPayloadsChunks.push({
entries: sorted.remainingPayloads.slice(i, i + options.batchSize),
entries: remainingPayloads.slice(i, i + options.batchSize),
})
}
const result: DatabaseFullEntryLoadChunkResponse = {
fullEntries: {
itemsKeys: itemsKeysChunk,
keySystemRootKeys: keySystemRootKeysChunk,
keySystemItemsKeys: keySystemItemsKeysChunk,
remainingChunks: [contentTypePriorityChunk, ...remainingPayloadsChunks],
},
remainingChunksItemCount: sorted.contentTypePriorityPayloads.length + sorted.remainingPayloads.length,
remainingChunksItemCount: contentTypePriorityPayloads.length + remainingPayloads.length,
}
return result

View File

@@ -14,7 +14,6 @@ import {
ContentType,
DecryptedItemInterface,
WebAppEvent,
WebApplicationInterface,
MobileDeviceInterface,
MobileUnlockTiming,
DecryptedItem,
@@ -27,7 +26,7 @@ import {
import { makeObservable, observable } from 'mobx'
import { startAuthentication, startRegistration } from '@simplewebauthn/browser'
import { PanelResizedData } from '@/Types/PanelResizedData'
import { isAndroid, isDesktopApplication, isIOS } from '@/Utils'
import { isAndroid, isDesktopApplication, isDev, isIOS } from '@/Utils'
import { DesktopManager } from './Device/DesktopManager'
import {
ArchiveManager,
@@ -38,7 +37,10 @@ import {
RouteService,
RouteServiceInterface,
ThemeManager,
VaultDisplayService,
VaultDisplayServiceInterface,
WebAlertService,
WebApplicationInterface,
} from '@standardnotes/ui-services'
import { MobileWebReceiver, NativeMobileEventListener } from '../NativeMobileWeb/MobileWebReceiver'
import { AndroidBackHandler } from '@/NativeMobileWeb/AndroidBackHandler'
@@ -49,6 +51,7 @@ import { FeatureName } from '@/Controllers/FeatureName'
import { ItemGroupController } from '@/Components/NoteView/Controller/ItemGroupController'
import { VisibilityObserver } from './VisibilityObserver'
import { MomentsService } from '@/Controllers/Moments/MomentsService'
import { purchaseMockSubscription } from '@/Utils/Dev/PurchaseMockSubscription'
export type WebEventObserver = (event: WebAppEvent, data?: unknown) => void
@@ -114,6 +117,7 @@ export class WebApplication extends SNApplication implements WebApplicationInter
this.webServices.viewControllerManager.filesController,
this.internalEventBus,
)
this.webServices.vaultDisplayService = new VaultDisplayService(this, this.internalEventBus)
if (this.isNativeMobileWeb()) {
this.mobileWebReceiver = new MobileWebReceiver(this)
@@ -194,6 +198,10 @@ export class WebApplication extends SNApplication implements WebApplicationInter
this.notifyWebEvent(WebAppEvent.PanelResized, data)
}
public get vaultDisplayService(): VaultDisplayServiceInterface {
return this.webServices.vaultDisplayService
}
public getViewControllerManager(): ViewControllerManager {
return this.webServices.viewControllerManager
}
@@ -450,4 +458,12 @@ export class WebApplication extends SNApplication implements WebApplicationInter
generateUUID(): string {
return this.options.crypto.generateUUID()
}
dev__purchaseMockSubscription() {
if (!isDev) {
throw new Error('This method is only available in dev mode')
}
void purchaseMockSubscription(this.getUser()?.email as string, 2000)
}
}

View File

@@ -6,6 +6,7 @@ import {
ChangelogServiceInterface,
KeyboardService,
ThemeManager,
VaultDisplayServiceInterface,
} from '@standardnotes/ui-services'
import { MomentsService } from '@/Controllers/Moments/MomentsService'
@@ -18,4 +19,5 @@ export type WebServices = {
keyboardService: KeyboardService
changelogService: ChangelogServiceInterface
momentsService: MomentsService
vaultDisplayService: VaultDisplayServiceInterface
}