From 40ca0b394ea066dea95c672eb0a42a35c9e65317 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Sun, 6 Sep 2020 15:28:09 +0300 Subject: [PATCH 1/6] add basic deletes support that works with masto WS --- src/components/status/status.js | 2 +- src/components/status/status.scss | 11 +++++++++ src/components/status/status.vue | 26 ++++++++++++++++++++++ src/components/user_avatar/user_avatar.vue | 11 +++++++++ src/i18n/en.json | 3 ++- src/modules/api.js | 2 ++ src/modules/statuses.js | 4 ++++ 7 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/components/status/status.js b/src/components/status/status.js index d263da68..5a6110c1 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -157,7 +157,7 @@ const Status = { return this.mergedConfig.hideFilteredStatuses }, hideStatus () { - return this.deleted || (this.muted && this.hideFilteredStatuses) + return (this.muted && this.hideFilteredStatuses) }, isFocused () { // retweet or root of an expanded conversation diff --git a/src/components/status/status.scss b/src/components/status/status.scss index 8d292d3f..02ce3ffa 100644 --- a/src/components/status/status.scss +++ b/src/components/status/status.scss @@ -25,6 +25,17 @@ $status-margin: 0.75em; --icon: var(--selectedPostIcon, $fallback--icon); } + .deleted { + padding: $status-margin; + color: $fallback--faint; + color: var(--faint, $fallback--faint); + display: flex; + .deleted-text { + margin: 0.5em 0; + align-items: center; + } + } + .status-container { display: flex; padding: $status-margin; diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 282ad37d..d7dfc0ab 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -95,6 +95,7 @@
+
+
+ +
+
+
+ {{ $t('status.status_deleted') }} +
+
+ +
+
+
+
@@ -42,5 +48,10 @@ border-radius: $fallback--avatarAltRadius; border-radius: var(--avatarAltRadius, $fallback--avatarAltRadius); } + + &.-placeholder { + background-color: $fallback--fg; + background-color: var(--fg, $fallback--fg); + } } diff --git a/src/i18n/en.json b/src/i18n/en.json index 8540f551..850dc4cc 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -659,7 +659,8 @@ "show_full_subject": "Show full subject", "hide_full_subject": "Hide full subject", "show_content": "Show content", - "hide_content": "Hide content" + "hide_content": "Hide content", + "status_deleted": "The post was deleted" }, "user_card": { "approve": "Approve", diff --git a/src/modules/api.js b/src/modules/api.js index 5e213f0d..de415981 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -72,6 +72,8 @@ const api = { showImmediately: timelineData.visibleStatuses.length === 0, timeline: 'friends' }) + } else if (message.event === 'delete') { + dispatch('deleteStatusById', message.id) } else if (message.event === 'pleroma:chat_update') { dispatch('addChatMessages', { chatId: message.chatUpdate.id, diff --git a/src/modules/statuses.js b/src/modules/statuses.js index e108b2a7..d38684ba 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -608,6 +608,10 @@ const statuses = { commit('setDeleted', { status }) apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials }) }, + deleteStatusById ({ rootState, commit }, id) { + const status = rootState.statuses.allStatusesObject[id] + commit('setDeleted', { status }) + }, markStatusesAsDeleted ({ commit }, condition) { commit('setManyDeleted', condition) }, From f9ac23b9a94dd35ba623814a59f4df83895acb42 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Mon, 7 Sep 2020 10:35:49 +0300 Subject: [PATCH 2/6] separate reply button to its own component, add changelog entry --- CHANGELOG.md | 3 ++ src/components/reply_button/reply_button.js | 12 +++++++ src/components/reply_button/reply_button.vue | 21 +++++++++++ src/components/status/status.js | 2 ++ src/components/status/status.vue | 37 ++++++-------------- 5 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 src/components/reply_button/reply_button.js create mode 100644 src/components/reply_button/reply_button.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index 18dafa8e..f07856df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ## [Unreleased patch] +### Added +- Proper handling of deletes when using websocket streaming + ### Changed - Polls will be hidden with status content if "Collapse posts with subjects" is enabled and the post is collapsed. diff --git a/src/components/reply_button/reply_button.js b/src/components/reply_button/reply_button.js new file mode 100644 index 00000000..22957650 --- /dev/null +++ b/src/components/reply_button/reply_button.js @@ -0,0 +1,12 @@ + +const ReplyButton = { + name: 'ReplyButton', + props: ['status', 'replying'], + computed: { + loggedIn () { + return !!this.$store.state.users.currentUser + } + } +} + +export default ReplyButton diff --git a/src/components/reply_button/reply_button.vue b/src/components/reply_button/reply_button.vue new file mode 100644 index 00000000..b2904b5c --- /dev/null +++ b/src/components/reply_button/reply_button.vue @@ -0,0 +1,21 @@ + + + diff --git a/src/components/status/status.js b/src/components/status/status.js index 5a6110c1..cb39fd6e 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -1,3 +1,4 @@ +import ReplyButton from '../reply_button/reply_button.vue' import FavoriteButton from '../favorite_button/favorite_button.vue' import ReactButton from '../react_button/react_button.vue' import RetweetButton from '../retweet_button/retweet_button.vue' @@ -20,6 +21,7 @@ import { mapGetters, mapState } from 'vuex' const Status = { name: 'Status', components: { + ReplyButton, FavoriteButton, ReactButton, RetweetButton, diff --git a/src/components/status/status.vue b/src/components/status/status.vue index d7dfc0ab..cb81b14e 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -321,21 +321,11 @@ v-if="!noHeading && !isPreview" class="status-actions" > -
- - - {{ status.replies_count }} -
+ {{ $t('status.status_deleted') }}
-
- -
+
Date: Mon, 7 Sep 2020 10:39:30 +0300 Subject: [PATCH 3/6] change i18n phrasing --- src/i18n/en.json | 2 +- src/i18n/fi.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index 850dc4cc..adf171e8 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -660,7 +660,7 @@ "hide_full_subject": "Hide full subject", "show_content": "Show content", "hide_content": "Hide content", - "status_deleted": "The post was deleted" + "status_deleted": "This post was deleted" }, "user_card": { "approve": "Approve", diff --git a/src/i18n/fi.json b/src/i18n/fi.json index 3832dcaa..2524f278 100644 --- a/src/i18n/fi.json +++ b/src/i18n/fi.json @@ -578,7 +578,8 @@ "show_full_subject": "Näytä koko otsikko", "hide_full_subject": "Piilota koko otsikko", "show_content": "Näytä sisältö", - "hide_content": "Piilota sisältö" + "hide_content": "Piilota sisältö", + "status_deleted": "Poistettu viesti" }, "user_card": { "approve": "Hyväksy", From 1ec9cde9638b3fb285185072532547b4a4d32158 Mon Sep 17 00:00:00 2001 From: Shpuld Shpludson Date: Tue, 8 Sep 2020 06:31:02 +0000 Subject: [PATCH 4/6] Apply 1 suggestion(s) to 1 file(s) --- src/components/status/status.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/status/status.scss b/src/components/status/status.scss index 02ce3ffa..2717c0ba 100644 --- a/src/components/status/status.scss +++ b/src/components/status/status.scss @@ -30,6 +30,7 @@ $status-margin: 0.75em; color: $fallback--faint; color: var(--faint, $fallback--faint); display: flex; + .deleted-text { margin: 0.5em 0; align-items: center; From fa9176651952468ee996abe0e67d62d9a72d5a69 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Tue, 8 Sep 2020 09:32:43 +0300 Subject: [PATCH 5/6] rename to gravestone --- src/components/status/status.scss | 2 +- src/components/status/status.vue | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/status/status.scss b/src/components/status/status.scss index 2717c0ba..bd23157f 100644 --- a/src/components/status/status.scss +++ b/src/components/status/status.scss @@ -25,7 +25,7 @@ $status-margin: 0.75em; --icon: var(--selectedPostIcon, $fallback--icon); } - .deleted { + .gravestone { padding: $status-margin; color: $fallback--faint; color: var(--faint, $fallback--faint); diff --git a/src/components/status/status.vue b/src/components/status/status.vue index cb81b14e..75142250 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -349,7 +349,7 @@
@@ -359,6 +359,7 @@ {{ $t('status.status_deleted') }}
Date: Thu, 1 Oct 2020 16:01:57 +0300 Subject: [PATCH 6/6] lint fix --- src/components/status/status.scss | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/status/status.scss b/src/components/status/status.scss index ecca288f..66a91c1e 100644 --- a/src/components/status/status.scss +++ b/src/components/status/status.scss @@ -25,6 +25,11 @@ $status-margin: 0.75em; --icon: var(--selectedPostIcon, $fallback--icon); } + &.-conversation { + border-left-width: 4px; + border-left-style: solid; + } + .gravestone { padding: $status-margin; color: $fallback--faint; @@ -36,11 +41,6 @@ $status-margin: 0.75em; align-items: center; } } - - &.-conversation { - border-left-width: 4px; - border-left-style: solid; - } .status-container { display: flex;