feat: Automatic plaintext backup option in Preferences > Backups will backup your notes and tags into plaintext, unencrypted folders on your computer. In addition, automatic encrypted text backups preference management has moved from the top-level menu in the desktop app to Preferences > Backups. (#2322)

This commit is contained in:
Mo
2023-05-02 11:05:10 -05:00
committed by GitHub
parent 3df23cdb5c
commit 7e3db49322
76 changed files with 1526 additions and 1013 deletions

View File

@@ -5,7 +5,12 @@ import { DiskStorageService } from '@Lib/Services/Storage/DiskStorageService'
import { UuidString } from '../../Types/UuidString'
import * as Models from '@standardnotes/models'
import { SNNote } from '@standardnotes/models'
import { AbstractService, DeviceInterface, InternalEventBusInterface } from '@standardnotes/services'
import {
AbstractService,
DeviceInterface,
HistoryServiceInterface,
InternalEventBusInterface,
} from '@standardnotes/services'
/** The amount of revisions per item above which should call for an optimization. */
const DefaultItemRevisionsThreshold = 20
@@ -25,7 +30,7 @@ const LargeEntryDeltaThreshold = 25
* 2. Remote server history. Entries are automatically added by the server and must be
* retrieved per item via an API call.
*/
export class SNHistoryManager extends AbstractService {
export class SNHistoryManager extends AbstractService implements HistoryServiceInterface {
private removeChangeObserver: () => void
/**

View File

@@ -343,13 +343,13 @@ export class ItemManager
/**
* Returns all items that an item directly references
*/
public referencesForItem(
public referencesForItem<I extends Models.DecryptedItemInterface = Models.DecryptedItemInterface>(
itemToLookupUuidFor: Models.DecryptedItemInterface,
contentType?: ContentType,
): Models.DecryptedItemInterface[] {
const item = this.findSureItem(itemToLookupUuidFor.uuid)
): I[] {
const item = this.findSureItem<I>(itemToLookupUuidFor.uuid)
const uuids = item.references.map((ref) => ref.uuid)
let references = this.findItems(uuids)
let references = this.findItems<I>(uuids)
if (contentType) {
references = references.filter((ref) => {
return ref?.content_type === contentType

View File

@@ -54,10 +54,7 @@ export class SNMigrationService extends AbstractService {
await this.markMigrationsAsDone()
})
} else {
await this.services.deviceInterface.setRawStorageValue(
namespacedKey(this.services.identifier, RawStorageKey.SnjsVersion),
SnjsVersion,
)
await this.markMigrationsAsDone()
}
}

View File

@@ -101,6 +101,7 @@ export class SNSessionManager
private httpService: HttpServiceInterface,
private sessionStorageMapper: MapperInterface<Session, Record<string, unknown>>,
private legacySessionStorageMapper: MapperInterface<LegacySession, Record<string, unknown>>,
private workspaceIdentifier: string,
protected override internalEventBus: InternalEventBusInterface,
) {
super(internalEventBus)
@@ -130,6 +131,14 @@ export class SNSessionManager
super.deinit()
}
public getWorkspaceDisplayIdentifier(): string {
if (this.user) {
return this.user.email
} else {
return this.workspaceIdentifier
}
}
private setUser(user?: User) {
this.user = user
this.apiService.setUser(user)