From f2477a47628d5d1524b25142bb07fbef85a2ef98 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Mon, 30 Apr 2018 21:33:12 +0900 Subject: [PATCH 1/3] refs #254 Add delete button in toot detail menu if toot is my toot --- .../TimelineSpace/Contents/Cards/Toot.vue | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue b/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue index c81d0a37..c0a06bde 100644 --- a/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue +++ b/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue @@ -57,9 +57,11 @@
  • Copy Link to Toot
  • +
  • + Delete +
  • - @@ -224,6 +226,11 @@ export default { return this.originalMessage(message).favourites_count } return '' + }, + isMyMessage (message) { + return this.$store.state.TimelineSpace.account.accountId === this.originalMessage(message).account.id + }, + deleteToot (message) { } } } @@ -350,10 +357,9 @@ function findLink (target) { } .toot-menu { - padding-right: 8px; - .menu-list { padding: 0; + margin: 4px 0; font-size: 0.8em; list-style-type: none; line-height: 20px; @@ -362,13 +368,19 @@ function findLink (target) { li { box-sizing: border-box; - padding-left: 0.5em; - padding-bottom: 0.5em; + margin: 0; + padding: 0 1.1em 0.5em; &:hover { background-color: #f2f6fc; cursor: pointer; } + + &.separate { + border-top: 1px solid var(--theme-border-color); + padding-top: 4px; + margin-top: 2px; + } } } } From 439966cbcb17d243b0c398b9b38fd8f14e375eda Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Mon, 30 Apr 2018 22:04:33 +0900 Subject: [PATCH 2/3] refs #254 Allow delete toot in home --- .../TimelineSpace/Contents/Cards/Toot.vue | 14 ++++++++++++-- .../components/TimelineSpace/Contents/Home.vue | 5 ++++- .../store/TimelineSpace/Contents/Cards/Toot.js | 14 ++++++++++++++ src/renderer/store/TimelineSpace/Contents/Home.js | 9 +++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue b/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue index c0a06bde..67e7c38f 100644 --- a/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue +++ b/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue @@ -153,7 +153,7 @@ export default { }) .catch(() => { this.$message({ - message: 'Faild to unreblog', + message: 'Failed to unreblog', type: 'error' }) }) @@ -164,7 +164,7 @@ export default { }) .catch(() => { this.$message({ - message: 'Faild to reblog', + message: 'Failed to reblog', type: 'error' }) }) @@ -231,6 +231,16 @@ export default { return this.$store.state.TimelineSpace.account.accountId === this.originalMessage(message).account.id }, deleteToot (message) { + this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/deleteToot', message) + .then((message) => { + this.$emit('delete', message) + }) + .catch(() => { + this.$message({ + message: 'Failed to delete the toot', + type: 'error' + }) + }) } } } diff --git a/src/renderer/components/TimelineSpace/Contents/Home.vue b/src/renderer/components/TimelineSpace/Contents/Home.vue index 81698b5a..2ea00022 100644 --- a/src/renderer/components/TimelineSpace/Contents/Home.vue +++ b/src/renderer/components/TimelineSpace/Contents/Home.vue @@ -3,7 +3,7 @@
    {{ unread.length > 0 ? unread.length : '' }}
    - +
    @@ -67,6 +67,9 @@ export default { }, updateToot (message) { this.$store.commit('TimelineSpace/Contents/Home/updateToot', message) + }, + deleteToot (message) { + this.$store.commit('TimelineSpace/Contents/Home/deleteToot', message) } } } diff --git a/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js b/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js index c1fd63a8..65c2b2d8 100644 --- a/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js +++ b/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js @@ -66,6 +66,20 @@ const Toot = { resolve(data) }) }) + }, + deleteToot ({ state, commit, rootState }, message) { + return new Promise((resolve, reject) => { + const client = new Mastodon( + { + access_token: rootState.TimelineSpace.account.accessToken, + api_url: rootState.TimelineSpace.account.baseURL + '/api/v1' + } + ) + client.delete(`/statuses/${message.id}`, {}, (err, data, res) => { + if (err) return reject(err) + resolve(message) + }) + }) } } } diff --git a/src/renderer/store/TimelineSpace/Contents/Home.js b/src/renderer/store/TimelineSpace/Contents/Home.js index 49031d40..a36f04b3 100644 --- a/src/renderer/store/TimelineSpace/Contents/Home.js +++ b/src/renderer/store/TimelineSpace/Contents/Home.js @@ -55,6 +55,15 @@ const Home = { return toot } }) + }, + deleteToot (state, message) { + state.timeline = state.timeline.filter((toot) => { + if (toot.reblog !== null && toot.reblog.id === message.id) { + return false + } else { + return toot.id !== message.id + } + }) } }, actions: { From 2a0e432f23d515733f7a8e4d7038975793c2f5d6 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Mon, 30 Apr 2018 22:11:40 +0900 Subject: [PATCH 3/3] refs #254 Allow delete toot in favourites, local, public and lists --- .../components/TimelineSpace/Contents/Favourites.vue | 5 ++++- src/renderer/components/TimelineSpace/Contents/Lists.vue | 5 ++++- src/renderer/components/TimelineSpace/Contents/Local.vue | 5 ++++- .../components/TimelineSpace/Contents/Public.vue | 5 ++++- src/renderer/store/TimelineSpace/Contents/Favourites.js | 9 +++++++++ src/renderer/store/TimelineSpace/Contents/Lists.js | 9 +++++++++ src/renderer/store/TimelineSpace/Contents/Local.js | 9 +++++++++ src/renderer/store/TimelineSpace/Contents/Public.js | 9 +++++++++ 8 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/TimelineSpace/Contents/Favourites.vue b/src/renderer/components/TimelineSpace/Contents/Favourites.vue index b98afa53..b20aea9b 100644 --- a/src/renderer/components/TimelineSpace/Contents/Favourites.vue +++ b/src/renderer/components/TimelineSpace/Contents/Favourites.vue @@ -1,7 +1,7 @@