diff --git a/main.go b/main.go index 4724d7a..d788939 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ import ( "time" ) -const VERSION = "v32" +const VERSION = "v31" const CONTEXT_USER = 1 const SYNC_PAGINATION = 200 diff --git a/static/js/app.mjs b/static/js/app.mjs index 2fc713b..e44eabd 100644 --- a/static/js/app.mjs +++ b/static/js/app.mjs @@ -221,7 +221,7 @@ export class App { const devPrefSet = localStorage.getItem('device_preference_set') || 'default' const userData = localStorage.getItem('user') || '{"default": {}}' const user = JSON.parse(userData) - return new N2PreferenceSet(devPrefSet, user.Preferences[devPrefSet] || {}) + return new N2PreferenceSet(devPrefSet, user.Preferences[devPrefSet]) }// }}} } diff --git a/static/js/node_store.mjs b/static/js/node_store.mjs index a086d85..531626b 100644 --- a/static/js/node_store.mjs +++ b/static/js/node_store.mjs @@ -328,52 +328,6 @@ export class NodeStore { this.nodes[ORPHANED_NODE] = new Node({ UUID: ORPHANED_NODE, Name: 'Orphaned nodes', Special: true }, -1) }// }}} - deleteAll() {// {{{ - this.db.close() - - const req = indexedDB.deleteDatabase('notes') - - req.onsuccess = async () => { - try { - console.log('Database deleted successfully') - - // Deleting the storage will log out the user. - await this.deleteStorage() - await this.deleteCaches() - await this.deleteServiceWorkers() - - alert('Database deleted, will now log out.') - location.href = '/login' - } catch (e) { - console.error(e) - alert(e.message) - } - } - - req.onerror = (event) => { - console.error('Error deleting database:', event.target.errorCode) - } - - req.onblocked = () => { - console.warn('Deletion blocked. Close all other tabs/connections to this DB.') - } - }// }}} - async deleteStorage() {// {{{ - // Clearing local- and session-storage in case - // something of value to evil people gets stored there. - localStorage.clear() - sessionStorage.clear() - console.log('Local- and session-storage cleared.') - }// }}} - async deleteCaches() {// {{{ - const keys = await caches.keys() - return Promise.all(keys.map(key => caches.delete(key))) - }// }}} - async deleteServiceWorkers() {// {{{ - const registrations = await navigator.serviceWorker.getRegistrations() - await Promise.all(registrations.map(r => r.unregister())) - }// }}} - node(uuid, dataIfUndefined, newLevel) {//{{{ let n = this.nodes[uuid] if (n === undefined && dataIfUndefined !== undefined) diff --git a/static/js/page_preferences.mjs b/static/js/page_preferences.mjs index 2c44d55..dd85ebf 100644 --- a/static/js/page_preferences.mjs +++ b/static/js/page_preferences.mjs @@ -238,7 +238,6 @@ export class N2PreferenceSet extends CustomHTMLElement { super(true) this.name = name this.data = data - this.validateDefaultProfile() this.render() // Enable the save button when settings are modified. @@ -249,16 +248,6 @@ export class N2PreferenceSet extends CustomHTMLElement { this.elName.addEventListener('click', () => this.updateName()) this.elDelete.addEventListener('click', () => this.deleteSet()) }// }}} - validateDefaultProfile() {// {{{ - if (!this.data.hasOwnProperty('default')) - this.data.default = {} - - if (!this.data.default.hasOwnProperty('DownloadFiles')) - this.data.default.DownloadFiles = false - - if (!this.data.default.hasOwnProperty('DownloadImages')) - this.data.default.DownloadImages = false - }// }}} updateName() {// {{{ if (this.name == 'default') { alert('Can not change name of the default profile.') diff --git a/static/js/page_storage.mjs b/static/js/page_storage.mjs index ed3970b..f6f562f 100644 --- a/static/js/page_storage.mjs +++ b/static/js/page_storage.mjs @@ -2,7 +2,7 @@ import { CustomHTMLElement } from "./lib/custom_html_element.mjs" import { API } from 'api' export class N2PageStorage extends CustomHTMLElement { - static {// {{{ + static { this.tmpl = document.createElement('template') this.tmpl.innerHTML = `

Local storage

-

Notes

+

Nodes

-
Local notes
+
Local nodes
-
History notes
-
- -
Notes to send
+
Queued to sync
+ +
History nodes
+

Files

@@ -56,24 +52,17 @@ export class N2PageStorage extends CustomHTMLElement {
Files to send
- -

Clear storage

-
Remove all data from this device (not server) and logout the session.
-
This ensures that no notes or files is left on the browser.
- ` - }// }}} - constructor() {// {{{ + } + constructor() { super(true) - .elBtnClearAll.addEventListener('click', ()=>this.clearAll()) - window._mbus.subscribe('SHOW_PAGE', event => { if (event.detail.data?.page == 'storage') this.render() }) - }// }}} - async render() {// {{{ + } + async render() { API.query('GET', '/file/count') .then(res => { this.elCountFilesOnServer.innerText = res.Count @@ -91,12 +80,6 @@ export class N2PageStorage extends CustomHTMLElement { this.elCountQueuedFiles.innerText = await globalThis.nodeStore.filesMetadata.countToUpload() this.elCountFilesOnDevice.innerText = await globalThis.nodeStore.filesMetadata.count() - }// }}} - clearAll() {// {{{ - if (!confirm('Do you want to remove ALL data from this device and logout?')) - return - - globalThis.nodeStore.deleteAll() - }// }}} + } } customElements.define('n2-pagestorage', N2PageStorage) diff --git a/views/layouts/main.gotmpl b/views/layouts/main.gotmpl index 3385bec..13a0bcf 100644 --- a/views/layouts/main.gotmpl +++ b/views/layouts/main.gotmpl @@ -20,8 +20,7 @@