mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 06:03:09 +02:00
clean up
This commit is contained in:
parent
882a30fabe
commit
572e475b39
5 changed files with 1 additions and 106 deletions
|
@ -154,7 +154,6 @@
|
||||||
"http-proxy-agent": "4.0.1",
|
"http-proxy-agent": "4.0.1",
|
||||||
"http-signature": "1.3.5",
|
"http-signature": "1.3.5",
|
||||||
"https-proxy-agent": "5.0.0",
|
"https-proxy-agent": "5.0.0",
|
||||||
"idb-keyval": "3.2.0",
|
|
||||||
"insert-text-at-cursor": "0.3.0",
|
"insert-text-at-cursor": "0.3.0",
|
||||||
"is-root": "2.1.0",
|
"is-root": "2.1.0",
|
||||||
"is-svg": "4.2.1",
|
"is-svg": "4.2.1",
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
import { Store } from 'idb-keyval';
|
|
||||||
// Provide functions from idb-keyval
|
|
||||||
export { get, set, del, clear, keys } from 'idb-keyval';
|
|
||||||
|
|
||||||
//#region Construct DB
|
|
||||||
export const clientDb = {
|
|
||||||
i18n: new Store('MisskeyClient', 'i18n')
|
|
||||||
};
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
//#region Provide some tool functions
|
|
||||||
function openTransaction(store: Store, mode: IDBTransactionMode): Promise<IDBTransaction>{
|
|
||||||
return store._dbp.then(db => db.transaction(store.storeName, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function entries(store: Store): Promise<[IDBValidKey, unknown][]> {
|
|
||||||
const entries: [IDBValidKey, unknown][] = [];
|
|
||||||
|
|
||||||
return store._withIDBStore('readonly', store => {
|
|
||||||
store.openCursor().onsuccess = function () {
|
|
||||||
if (!this.result) return;
|
|
||||||
entries.push([this.result.key, this.result.value]);
|
|
||||||
this.result.continue();
|
|
||||||
};
|
|
||||||
}).then(() => entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function bulkGet(keys: IDBValidKey[], store: Store): Promise<[IDBValidKey, unknown][]> {
|
|
||||||
const valPromises: Promise<[IDBValidKey, unknown]>[] = [];
|
|
||||||
|
|
||||||
const tx = await openTransaction(store, 'readwrite');
|
|
||||||
const st = tx.objectStore(store.storeName);
|
|
||||||
for (const key of keys) {
|
|
||||||
valPromises.push(new Promise((resolve, reject) => {
|
|
||||||
const getting = st.get(key);
|
|
||||||
getting.onsuccess = function (e) {
|
|
||||||
return resolve([key, this.result]);
|
|
||||||
};
|
|
||||||
getting.onerror = function (e) {
|
|
||||||
return reject(this.error);
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
tx.oncomplete = () => resolve(Promise.all(valPromises));
|
|
||||||
tx.abort = tx.onerror = () => reject(tx.error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function bulkSet(map: [IDBValidKey, any][], store: Store): Promise<void> {
|
|
||||||
const tx = await openTransaction(store, 'readwrite');
|
|
||||||
const st = tx.objectStore(store.storeName);
|
|
||||||
for (const [key, value] of map) {
|
|
||||||
st.put(value, key);
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
tx.oncomplete = () => resolve();
|
|
||||||
tx.abort = tx.onerror = () => reject(tx.error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function count(store: Store): Promise<number> {
|
|
||||||
let req: IDBRequest<number>;
|
|
||||||
return store._withIDBStore('readonly', store => {
|
|
||||||
req = store.count();
|
|
||||||
}).then(() => req.result);
|
|
||||||
}
|
|
||||||
//#endregion
|
|
|
@ -36,8 +36,6 @@ import FormSelect from '@/components/form/select.vue';
|
||||||
import FormRadios from '@/components/form/radios.vue';
|
import FormRadios from '@/components/form/radios.vue';
|
||||||
import FormBase from '@/components/form/base.vue';
|
import FormBase from '@/components/form/base.vue';
|
||||||
import FormGroup from '@/components/form/group.vue';
|
import FormGroup from '@/components/form/group.vue';
|
||||||
import { clientDb, set } from '@/db';
|
|
||||||
import * as os from '@/os';
|
|
||||||
import { deckStore } from '@/ui/deck/deck-store';
|
import { deckStore } from '@/ui/deck/deck-store';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|
|
@ -77,8 +77,6 @@
|
||||||
</FormSelect>
|
</FormSelect>
|
||||||
|
|
||||||
<FormLink to="/settings/deck">{{ $ts.deck }}</FormLink>
|
<FormLink to="/settings/deck">{{ $ts.deck }}</FormLink>
|
||||||
|
|
||||||
<FormButton @click="cacheClear()" danger>{{ $ts.cacheClear }}</FormButton>
|
|
||||||
</FormBase>
|
</FormBase>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -94,8 +92,6 @@ import FormLink from '@/components/form/link.vue';
|
||||||
import FormButton from '@/components/form/button.vue';
|
import FormButton from '@/components/form/button.vue';
|
||||||
import MkLink from '@/components/link.vue';
|
import MkLink from '@/components/link.vue';
|
||||||
import { langs } from '@/config';
|
import { langs } from '@/config';
|
||||||
import { clientDb, set } from '@/db';
|
|
||||||
import * as os from '@/os';
|
|
||||||
import { defaultStore } from '@/store';
|
import { defaultStore } from '@/store';
|
||||||
import { ColdDeviceStorage } from '@/store';
|
import { ColdDeviceStorage } from '@/store';
|
||||||
|
|
||||||
|
@ -149,14 +145,7 @@ export default defineComponent({
|
||||||
watch: {
|
watch: {
|
||||||
lang() {
|
lang() {
|
||||||
localStorage.setItem('lang', this.lang);
|
localStorage.setItem('lang', this.lang);
|
||||||
|
location.reload();
|
||||||
return set('_version_', `changeLang-${(new Date()).toJSON()}`, clientDb.i18n)
|
|
||||||
.then(() => location.reload())
|
|
||||||
.catch(() => {
|
|
||||||
os.dialog({
|
|
||||||
type: 'error',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fontSize() {
|
fontSize() {
|
||||||
|
@ -185,23 +174,5 @@ export default defineComponent({
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$emit('info', this.INFO);
|
this.$emit('info', this.INFO);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
|
||||||
cacheClear() {
|
|
||||||
// Clear cache (service worker)
|
|
||||||
try {
|
|
||||||
navigator.serviceWorker.controller.postMessage('clear');
|
|
||||||
|
|
||||||
navigator.serviceWorker.getRegistrations().then(registrations => {
|
|
||||||
for (const registration of registrations) registration.unregister();
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force reload
|
|
||||||
location.reload(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -4955,11 +4955,6 @@ icss-utils@^5.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.0.0.tgz#03ed56c3accd32f9caaf1752ebf64ef12347bb84"
|
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.0.0.tgz#03ed56c3accd32f9caaf1752ebf64ef12347bb84"
|
||||||
integrity sha512-aF2Cf/CkEZrI/vsu5WI/I+akFgdbwQHVE9YRZxATrhH4PVIe6a3BIjwjEcW+z+jP/hNh+YvM3lAAn1wJQ6opSg==
|
integrity sha512-aF2Cf/CkEZrI/vsu5WI/I+akFgdbwQHVE9YRZxATrhH4PVIe6a3BIjwjEcW+z+jP/hNh+YvM3lAAn1wJQ6opSg==
|
||||||
|
|
||||||
idb-keyval@3.2.0:
|
|
||||||
version "3.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/idb-keyval/-/idb-keyval-3.2.0.tgz#cbbf354deb5684b6cdc84376294fc05932845bd6"
|
|
||||||
integrity sha512-slx8Q6oywCCSfKgPgL0sEsXtPVnSbTLWpyiDcu6msHOyKOLari1TD1qocXVCft80umnkk3/Qqh3lwoFt8T/BPQ==
|
|
||||||
|
|
||||||
ieee754@1.1.13, ieee754@^1.1.13, ieee754@^1.1.4:
|
ieee754@1.1.13, ieee754@^1.1.13, ieee754@^1.1.4:
|
||||||
version "1.1.13"
|
version "1.1.13"
|
||||||
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
|
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
|
||||||
|
|
Loading…
Reference in a new issue