fix: workspace signout all

This commit is contained in:
Mo
2022-05-17 13:47:23 -05:00
parent b3f6888683
commit abe9b70525
6 changed files with 60 additions and 39 deletions

View File

@@ -104,7 +104,7 @@ export const ConfirmSignoutModal = observer(({ application, appState, applicatio
closeDialog()
}}
>
{application.hasAccount() ? 'Sign Out' : 'Clear Session Data'}
{application.hasAccount() ? 'Sign Out' : 'Delete Workspace'}
</button>
</div>
</div>

View File

@@ -19,10 +19,10 @@ export class Database {
private locked = true
private db?: IDBDatabase
constructor(public databaseName: string, private alertService: AlertService) {}
constructor(public databaseName: string, private alertService?: AlertService) {}
public deinit(): void {
;(this.alertService as any) = undefined
;(this.alertService as unknown) = undefined
this.db = undefined
}
@@ -33,6 +33,19 @@ export class Database {
this.locked = false
}
static async deleteAll(): Promise<void> {
const rawDatabases = await window.indexedDB.databases()
for (const rawDb of rawDatabases) {
if (!rawDb.name) {
continue
}
const db = new Database(rawDb.name)
await db.clearAllPayloads()
db.deinit()
}
}
/**
* Opens the database natively, or returns the existing database object if already opened.
* @param onNewDatabase - Callback to invoke when a database has been created
@@ -208,13 +221,18 @@ export class Database {
}
private showAlert(message: string) {
if (this.alertService) {
this.alertService.alert(message).catch(console.error)
} else {
window.alert(message)
}
}
private showGenericError(error: { code: number; name: string }) {
const message =
'Unable to save changes locally due to an unknown system issue. ' +
`Issue Code: ${error.code} Issue Name: ${error.name}.`
this.showAlert(message)
}
@@ -225,6 +243,7 @@ export class Database {
'access to the local database. Please use a non-private window.' +
'\n\n2. You have two windows of the app open at the same time. ' +
'Please close any other app instances and reload the page.'
this.alertService.alert(message).catch(console.error)
this.showAlert(message)
}
}

View File

@@ -41,6 +41,12 @@ export abstract class WebOrDesktopDevice implements WebOrDesktopDeviceInterface
return this.databases.find((database) => database.databaseName === identifier) as Database
}
async clearAllDataFromDevice(): Promise<void> {
await this.clearRawKeychainValue()
await this.removeAllRawStorageValues()
await Database.deleteAll()
}
deinit() {
for (const database of this.databases) {
database.deinit()

View File

@@ -86,8 +86,4 @@ export class ApplicationGroup extends SNApplicationGroup<WebOrDesktopDevice> {
delete window.webClient
}
}
override handleAllWorkspacesSignedOut(): void {
isDesktopDevice(this.device) && this.device.destroyAllData()
}
}

View File

@@ -70,10 +70,10 @@
"@reach/tooltip": "^0.16.2",
"@reach/visually-hidden": "^0.16.0",
"@standardnotes/components": "1.8.1",
"@standardnotes/filepicker": "1.14.7",
"@standardnotes/filepicker": "1.14.8",
"@standardnotes/icons": "^1.1.7",
"@standardnotes/sncrypto-web": "1.9.2",
"@standardnotes/snjs": "2.109.1",
"@standardnotes/snjs": "2.109.2",
"@standardnotes/stylekit": "5.27.0",
"@zip.js/zip.js": "^2.4.10",
"mobx": "^6.5.0",

View File

@@ -2311,14 +2311,14 @@
"@standardnotes/auth" "^3.18.16"
"@standardnotes/features" "^1.44.0"
"@standardnotes/encryption@^1.7.7":
version "1.7.7"
resolved "https://registry.yarnpkg.com/@standardnotes/encryption/-/encryption-1.7.7.tgz#c78bc2c7a33f9fb784e9631e055a35a300da2ced"
integrity sha512-U3yVYugjY70zJM8o0xflaJxKdjQ8zMDZHEN9SCPrBpFkabZsRPmfVO33vr9bvC3snj5i8sQPgbfPfFi3Pxqe7w==
"@standardnotes/encryption@^1.7.8":
version "1.7.8"
resolved "https://registry.yarnpkg.com/@standardnotes/encryption/-/encryption-1.7.8.tgz#ab59f9c37c3e577f89df1891b6ac2683e2d1dec9"
integrity sha512-RMyFC3OgTDDFgDq0VMU9sBdC1GKvFthW2D0belSojaxtu/3J1SZ6BUiZ5TYMar+jrVKIMs2X976ukmZ0C8KPPA==
dependencies:
"@standardnotes/models" "^1.8.6"
"@standardnotes/responses" "^1.6.23"
"@standardnotes/services" "^1.11.7"
"@standardnotes/services" "^1.11.8"
"@standardnotes/features@^1.44.0":
version "1.44.0"
@@ -2328,24 +2328,24 @@
"@standardnotes/auth" "^3.18.16"
"@standardnotes/common" "^1.21.0"
"@standardnotes/filepicker@1.14.7", "@standardnotes/filepicker@^1.14.7":
version "1.14.7"
resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.14.7.tgz#9f0ff2e88844a18234c6bc93449ef6c13a2cf08e"
integrity sha512-Oe41oNoayjQ4avmwV59vBqg9CfACECHTc0iGicJhQH2E++ErynXFr+ZmIDJEEj2ufIXbM+xiWDa5fWvzMbIcBw==
"@standardnotes/filepicker@1.14.8", "@standardnotes/filepicker@^1.14.8":
version "1.14.8"
resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.14.8.tgz#aa915399df9d7da3b30b0ea901bcf7d97aca3a42"
integrity sha512-52ABvJ79wuINIe6cGKgqV4qulnQbJrw1OwazWVvUWtX3rghWqiFgDT84gH4kma2kZxi0v03VLdbpvd2+i0yIBA==
dependencies:
"@standardnotes/common" "^1.21.0"
"@standardnotes/services" "^1.11.7"
"@standardnotes/services" "^1.11.8"
"@standardnotes/utils" "^1.6.9"
"@standardnotes/files@^1.1.8":
version "1.1.8"
resolved "https://registry.yarnpkg.com/@standardnotes/files/-/files-1.1.8.tgz#8d2978c5ce35353928c76051cd2906399b605117"
integrity sha512-+JFZ9koLJJd9Q+x4JX1WhmPDrGEjTQLOiUeTszcoeQd9qrV6K7nILhchQKgL0t924VhjpONA75w28tu96nI6vw==
"@standardnotes/files@^1.1.9":
version "1.1.9"
resolved "https://registry.yarnpkg.com/@standardnotes/files/-/files-1.1.9.tgz#9a4bfd60ee26ba6b9f5281853626e87155d11cc5"
integrity sha512-yE4zB5QrP4o+sU2EfaK5oidhF4LpSC6slA82787dxKQ9ILDexnH8nyI/YH6sw82OiLHe+CeRR5mW01Pv8A7aYA==
dependencies:
"@standardnotes/encryption" "^1.7.7"
"@standardnotes/encryption" "^1.7.8"
"@standardnotes/models" "^1.8.6"
"@standardnotes/responses" "^1.6.23"
"@standardnotes/services" "^1.11.7"
"@standardnotes/services" "^1.11.8"
"@standardnotes/utils" "^1.6.9"
"@standardnotes/icons@^1.1.6", "@standardnotes/icons@^1.1.7":
@@ -2371,10 +2371,10 @@
"@standardnotes/common" "^1.21.0"
"@standardnotes/features" "^1.44.0"
"@standardnotes/services@^1.11.7":
version "1.11.7"
resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.11.7.tgz#c57f2443dfdb59008a95260ad6d631302a838226"
integrity sha512-pGj32mLCzFBPZdvaE4WmgBnV+Tjif6ueHjEIZKuMEFqOPpete6/eu7nXGWQOkwDoi1yKyEmR4a8n0f3sQN+IQQ==
"@standardnotes/services@^1.11.8":
version "1.11.8"
resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.11.8.tgz#8a9ef3212ef0693f611661cff552f22add00a236"
integrity sha512-E+hougOnKobH5nKPzpTxaGvYUSw3BWS0rKRMY2Jh5ZhD+y4GqCCA7VoR/7lbxR2GjP5xGpKHYgZR5QIyW+wFJQ==
dependencies:
"@standardnotes/auth" "^3.18.16"
"@standardnotes/common" "^1.21.0"
@@ -2401,21 +2401,21 @@
buffer "^6.0.3"
libsodium-wrappers "^0.7.9"
"@standardnotes/snjs@2.109.1":
version "2.109.1"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.109.1.tgz#afda401370e4faf42e15c6275e727cf67d10e708"
integrity sha512-3ptkJOFVK8T/bp7k9YYw4W+6dUbllFuqd+IR6b2QJd9iCe3NMgy+5M6gcgvApe0NWFlJL5Wv69/sba6Y3DiY5A==
"@standardnotes/snjs@2.109.2":
version "2.109.2"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.109.2.tgz#c7ee667cd7a3a9db5ccf7132a41d680a33888e2c"
integrity sha512-+4G8LQjzLrZe7Unzjqyr5Y2q4dtxu816MSMqWTmoAWQ3LFE0BEOm+1ltEfLC0cgic8ieH4tY14RUaTvNyznrFA==
dependencies:
"@standardnotes/auth" "^3.18.16"
"@standardnotes/common" "^1.21.0"
"@standardnotes/domain-events" "^2.28.7"
"@standardnotes/encryption" "^1.7.7"
"@standardnotes/encryption" "^1.7.8"
"@standardnotes/features" "^1.44.0"
"@standardnotes/filepicker" "^1.14.7"
"@standardnotes/files" "^1.1.8"
"@standardnotes/filepicker" "^1.14.8"
"@standardnotes/files" "^1.1.9"
"@standardnotes/models" "^1.8.6"
"@standardnotes/responses" "^1.6.23"
"@standardnotes/services" "^1.11.7"
"@standardnotes/services" "^1.11.8"
"@standardnotes/settings" "^1.14.3"
"@standardnotes/sncrypto-common" "^1.8.2"
"@standardnotes/utils" "^1.6.9"