@d-mok/quasar-app-extension-quasar-axe 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/utils/ORM/basic.ts +16 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-mok/quasar-app-extension-quasar-axe",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "A Quasar App Extension",
|
|
5
5
|
"author": "d-mok <49301824+d-mok@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@supabase/supabase-js": "^1.29.4",
|
|
24
24
|
"@types/papaparse": "^5.3.2",
|
|
25
25
|
"@types/webpack-env": "^1.16.3",
|
|
26
|
+
"localforage": "^1.10.0",
|
|
26
27
|
"papaparse": "^5.3.1",
|
|
27
28
|
"sapphire-js": "^1.0.63"
|
|
28
29
|
},
|
package/src/utils/ORM/basic.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { qNotify } from '../notify'
|
|
|
4
4
|
import { LoadingBar } from 'quasar'
|
|
5
5
|
import { Ordering, Criteria, strKeyOf, Sheet } from 'sapphire-js'
|
|
6
6
|
import { reactive } from 'vue'
|
|
7
|
-
|
|
7
|
+
import localforage from 'localforage'
|
|
8
8
|
|
|
9
9
|
export type Where<T> =
|
|
10
10
|
{ [K in keyof T]?
|
|
@@ -155,30 +155,33 @@ export abstract class BasicTable<T extends R, R extends object> extends Sheet<T>
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return JSON.parse(localStorage.getItem(this.tableName) ?? '[]')
|
|
158
|
+
private async getCache(): Promise<R[]> {
|
|
159
|
+
return await localforage.getItem<R[]>(this.tableName) ?? []
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
private
|
|
164
|
-
|
|
165
|
-
localStorage.setItem(this.tableName, json)
|
|
162
|
+
private async setCache(data: R[]) {
|
|
163
|
+
await localforage.setItem(this.tableName, data)
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
private restoreCache() {
|
|
169
|
-
let
|
|
166
|
+
private async restoreCache() {
|
|
167
|
+
let cache = await this.getCache()
|
|
168
|
+
let entities = this.convert(cache)
|
|
170
169
|
this.set(entities)
|
|
171
170
|
this.log('restore cache')
|
|
172
171
|
}
|
|
173
172
|
|
|
174
|
-
private pushCache(data: R[]) {
|
|
175
|
-
|
|
173
|
+
private async pushCache(data: R[]) {
|
|
174
|
+
let cache = await this.getCache()
|
|
175
|
+
cache = [...cache, ...data]
|
|
176
|
+
await this.setCache(cache)
|
|
176
177
|
this.log('push cache')
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
private screenCache() {
|
|
180
|
+
private async screenCache() {
|
|
181
|
+
let cache = await this.getCache()
|
|
180
182
|
let ids: any[] = this.scan(this.idField)
|
|
181
|
-
|
|
183
|
+
cache = cache.filter($ => ids.includes($[this.idField]))
|
|
184
|
+
await this.setCache(cache)
|
|
182
185
|
this.log('screen cache')
|
|
183
186
|
}
|
|
184
187
|
|