diff --git a/package-lock.json b/package-lock.json index 5e418d7..5c41767 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "time-chain", - "version": "1.1.0", + "version": "1.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "time-chain", - "version": "1.1.0", + "version": "1.1.3", "license": "UNLICENSED", "dependencies": { "@sentry/browser": "^6.17.6", @@ -15,6 +15,7 @@ "better-sqlite3": "^7.5.0", "conf": "^10.1.1", "dayjs": "^1.10.7", + "debounce": "^1.2.1", "electron-config": "^2.0.0", "empty-lite": "^1.2.0", "es6-interface": "^3.2.1", @@ -4509,6 +4510,11 @@ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.7.tgz", "integrity": "sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==" }, + "node_modules/debounce": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", + "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==" + }, "node_modules/debounce-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/debounce-fn/-/debounce-fn-4.0.0.tgz", @@ -16803,6 +16809,11 @@ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.7.tgz", "integrity": "sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==" }, + "debounce": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", + "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==" + }, "debounce-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/debounce-fn/-/debounce-fn-4.0.0.tgz", diff --git a/package.json b/package.json index f1209fd..66b719a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "time-chain", - "version": "1.1.2", + "version": "1.1.4", "description": "timechain", "author": "Jaosn Tudisco", "license": "UNLICENSED", @@ -44,6 +44,7 @@ "better-sqlite3": "^7.5.0", "conf": "^10.1.1", "dayjs": "^1.10.7", + "debounce": "^1.2.1", "electron-config": "^2.0.0", "empty-lite": "^1.2.0", "es6-interface": "^3.2.1", diff --git a/src/data/sqlite-client.js b/src/data/sqlite-client.js index abf4c1e..ead65c1 100644 --- a/src/data/sqlite-client.js +++ b/src/data/sqlite-client.js @@ -32,6 +32,14 @@ class TimeChainDataSqliteTag //extends Interface(InterfaceTag) return this.send('has',{tag:tag}) } + all(){ + return this.send('all',{}) + } + + like(str){ + return this.send('like',{str:str}) + } + } class TimeChainDataSqliteTagLink //extends Interface(InterfaceTagLink) diff --git a/src/data/sqlite-electron-ipc.js b/src/data/sqlite-electron-ipc.js index 81cbac3..49d939c 100644 --- a/src/data/sqlite-electron-ipc.js +++ b/src/data/sqlite-electron-ipc.js @@ -153,6 +153,12 @@ ipcMain.handle('timechain-tag', async (event, arg) => { case 'has': res = await DbTag.delete(arg.tag) break + case 'all': + res = await DbTag.all() + break; + case 'like': + res = await DbTag.like(arg.str) + break; default: res = new Error('Command Unknown') } diff --git a/src/data/sqlite.js b/src/data/sqlite.js index ba1d4d0..ab4478d 100644 --- a/src/data/sqlite.js +++ b/src/data/sqlite.js @@ -54,6 +54,20 @@ class TimeChainDataSqliteTag extends Interface(InterfaceTag) { return this._table_get } + get table_get_like () { + if (!this._table_get) { + this._table_get = db.prepare('SELECT * FROM tags WHERE tag LIKE ?') + } + return this._table_get + } + + get table_get_all() { + if (!this._table_get_all) { + this._table_get_all = db.prepare('SELECT * FROM tags') + } + return this._table_get_all + } + get table_count () { if (!this._table_count) { this._table_count = db.prepare('SELECT count(tag) as cnt FROM tags WHERE tag = ?') @@ -75,6 +89,20 @@ class TimeChainDataSqliteTag extends Interface(InterfaceTag) { }) } + all() { + return new Promise(resolve => { + const res = this.table_get_all.all(); + return resolve(res); + }) + } + + like(str){ + return new Promise(resolve => { + const res = this.table_get_like.all(str + '%'); + return resolve(res); + }) + } + delete (tag) { return new Promise(resolve => { const dt = Math.floor(Date.now()) diff --git a/src/ui/timechain-list.riot b/src/ui/timechain-list.riot index 28a7524..05126dc 100644 --- a/src/ui/timechain-list.riot +++ b/src/ui/timechain-list.riot @@ -106,7 +106,7 @@ processImages(){ var URLObj = window.URL || window.webkitURL; this.state.records.forEach(r=>{ - if(r.mime == "image/jpeg" || r.mime == "image/png"){ + if(typeof r.mime == 'string' && r.mime.startsWith("image/")){ r.imageURL = r.content; } }); diff --git a/src/ui/timechain-tag.riot b/src/ui/timechain-tag.riot index e205c28..f06411d 100644 --- a/src/ui/timechain-tag.riot +++ b/src/ui/timechain-tag.riot @@ -6,6 +6,11 @@ diff --git a/src/ui/timechain-tags.riot b/src/ui/timechain-tags.riot new file mode 100644 index 0000000..20da737 --- /dev/null +++ b/src/ui/timechain-tags.riot @@ -0,0 +1,3 @@ + + +