diff --git a/src/main/hashtags.js b/src/main/hashtags.js index 78fa587e..01adeff0 100644 --- a/src/main/hashtags.js +++ b/src/main/hashtags.js @@ -21,4 +21,19 @@ export default class Hashtags { }) }) } + + removeTag (tag) { + return new Promise((resolve, reject) => { + this.db.remove( + { + tagName: tag.tagName + }, + { multi: true }, + (err, numRemoved) => { + if (err) return reject(err) + resolve(numRemoved) + } + ) + }) + } } diff --git a/src/main/index.js b/src/main/index.js index 9ff40a89..d59c5ad1 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -637,6 +637,17 @@ ipcMain.on('list-hashtags', (event, _) => { }) }) +ipcMain.on('remove-hashtag', (event, tag) => { + const hashtags = new Hashtags(hashtagsDB) + hashtags.removeTag(tag) + .then(() => { + event.sender.send('response-remove-hashtag') + }) + .catch((err) => { + event.sender.send('error-remove-hashtag', err) + }) +}) + /** * Auto Updater * diff --git a/src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue b/src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue index 582e7fd3..d8a300b1 100644 --- a/src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue +++ b/src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue @@ -2,10 +2,15 @@
- + +
{{ tag.tagName }} + + + +
@@ -28,6 +33,9 @@ export default { methods: { openTimeline (tag) { this.$router.push({ path: `/${this.$route.params.id}/hashtag/${tag}` }) + }, + deleteTag (tag) { + this.$store.dispatch('TimelineSpace/Contents/Hashtag/List/removeTag', tag) } } } @@ -51,6 +59,15 @@ export default { &:first-child { border-top: 1px solid var(--theme-border-color); } + + .action { + width: 20px; + + .el-button /deep/ { + padding: 0; + color: var(--theme-secondary-color); + } + } } } diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag/List.js b/src/renderer/store/TimelineSpace/Contents/Hashtag/List.js index e68a1e70..4e6598d8 100644 --- a/src/renderer/store/TimelineSpace/Contents/Hashtag/List.js +++ b/src/renderer/store/TimelineSpace/Contents/Hashtag/List.js @@ -24,6 +24,20 @@ const List = { }) ipcRenderer.send('list-hashtags') }) + }, + removeTag ({ dispatch }, tag) { + return new Promise((resolve, reject) => { + ipcRenderer.once('response-remove-hashtag', (event, _) => { + ipcRenderer.removeAllListeners('error-remove-hashtag') + dispatch('listTags') + resolve('deleted') + }) + ipcRenderer.once('error-remove-hashtag', (event, err) => { + ipcRenderer.removeAllListeners('response-remove-hashtag') + reject(err) + }) + ipcRenderer.send('remove-hashtag', tag) + }) } } }