From 1a333aabba759fb68449ead9c47e986f456e8c8c Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 7 Jun 2022 21:31:48 -0600 Subject: [PATCH 01/26] Add edit status functionality --- CONTRIBUTORS.md | 1 + src/App.js | 2 + src/App.vue | 1 + .../edit_status_modal/edit_status_modal.js | 75 ++++++++++++++++ .../edit_status_modal/edit_status_modal.vue | 48 ++++++++++ src/components/extra_buttons/extra_buttons.js | 13 +++ .../extra_buttons/extra_buttons.vue | 11 +++ .../post_status_form/post_status_form.js | 45 +++++++--- .../post_status_form/post_status_form.vue | 1 + src/i18n/en.json | 2 + src/main.js | 3 + src/modules/api.js | 2 + src/modules/editStatus.js | 25 ++++++ src/modules/statuses.js | 6 ++ src/services/api/api.service.js | 88 ++++++++++++++++++- .../entity_normalizer.service.js | 12 +++ .../status_poster/status_poster.service.js | 42 +++++++++ 17 files changed, 365 insertions(+), 12 deletions(-) create mode 100644 src/components/edit_status_modal/edit_status_modal.js create mode 100644 src/components/edit_status_modal/edit_status_modal.vue create mode 100644 src/modules/editStatus.js diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f666a4ef..18f4a930 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -10,3 +10,4 @@ Contributors of this project. - shpuld (shpuld@shitposter.club): CSS and styling - Vincent Guth (https://unsplash.com/photos/XrwVIFy6rTw): Background images. - hj (hj@shigusegubu.club): Code +- Sean King (seanking@freespeechextremist.com): Code diff --git a/src/App.js b/src/App.js index f01f8788..6e0e34a8 100644 --- a/src/App.js +++ b/src/App.js @@ -11,6 +11,7 @@ import MobilePostStatusButton from './components/mobile_post_status_button/mobil import MobileNav from './components/mobile_nav/mobile_nav.vue' import DesktopNav from './components/desktop_nav/desktop_nav.vue' import UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue' +import EditStatusModal from './components/edit_status_modal/edit_status_modal.vue' import PostStatusModal from './components/post_status_modal/post_status_modal.vue' import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue' import { windowWidth, windowHeight } from './services/window_utils/window_utils' @@ -35,6 +36,7 @@ export default { SettingsModal, UserReportingModal, PostStatusModal, + EditStatusModal, GlobalNoticeList }, data: () => ({ diff --git a/src/App.vue b/src/App.vue index 5b448972..9484f993 100644 --- a/src/App.vue +++ b/src/App.vue @@ -52,6 +52,7 @@ +
@@ -257,7 +257,7 @@ @keydown.enter.prevent="" >

- {{ localDescription }} + {{ attachment.description }}

From 80ec88beabefd41e75040dd35364a94783e423a0 Mon Sep 17 00:00:00 2001 From: Sean King Date: Sat, 11 Jun 2022 16:32:46 -0600 Subject: [PATCH 05/26] Use statusId instead of repliedUser.id --- src/components/edit_status_modal/edit_status_modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/edit_status_modal/edit_status_modal.js b/src/components/edit_status_modal/edit_status_modal.js index 14320d21..75adfea7 100644 --- a/src/components/edit_status_modal/edit_status_modal.js +++ b/src/components/edit_status_modal/edit_status_modal.js @@ -29,7 +29,7 @@ const EditStatusModal = { }, watch: { params (newVal, oldVal) { - if (get(newVal, 'repliedUser.id') !== get(oldVal, 'repliedUser.id')) { + if (get(newVal, 'statusId') !== get(oldVal, 'statusId')) { this.resettingForm = true this.$nextTick(() => { this.resettingForm = false From 32ecdfdd8738befa004f865f496b7df17a4c2030 Mon Sep 17 00:00:00 2001 From: Sean King Date: Sat, 11 Jun 2022 16:38:03 -0600 Subject: [PATCH 06/26] Don't pollute the original timeline when new media attachment is added --- src/components/extra_buttons/extra_buttons.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js index 9508a707..8a703953 100644 --- a/src/components/extra_buttons/extra_buttons.js +++ b/src/components/extra_buttons/extra_buttons.js @@ -80,7 +80,7 @@ const ExtraButtons = { statusText: data.text, statusIsSensitive: this.status.nsfw, statusPoll: this.status.poll, - statusFiles: this.status.attachments, + statusFiles: [...this.status.attachments], visibility: this.status.visibility, statusContentType: data.content_type })) From 29e7972d8b46e9ad15ecc0cdd398f6054fe0004a Mon Sep 17 00:00:00 2001 From: Sean King Date: Sat, 11 Jun 2022 16:44:08 -0600 Subject: [PATCH 07/26] Credit to the chad tusooa --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 18f4a930..bfc41ac4 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -11,3 +11,4 @@ Contributors of this project. - Vincent Guth (https://unsplash.com/photos/XrwVIFy6rTw): Background images. - hj (hj@shigusegubu.club): Code - Sean King (seanking@freespeechextremist.com): Code +- Tusooa Zhu (tusooa@kazv.moe): Code From c195e3571c113d29778ad86f4cbea019716fe787 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Sat, 11 Jun 2022 20:33:12 -0400 Subject: [PATCH 08/26] Handle explicit mention changes in status updates --- src/components/status_body/status_body.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index b8f6f9a0..0a3dcf79 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -125,6 +125,13 @@ const StatusContent = { generateTagLink (tag) { return `/tag/${tag}` } + }, + watch: { + 'status.raw_html' (newVal, oldVal) { + if (newVal !== oldVal) { + this.parseReadyDone = false + } + } } } From 6e42409b8a0002ecbc75433b4f0881f10eb58bff Mon Sep 17 00:00:00 2001 From: Sean King Date: Sat, 11 Jun 2022 19:30:29 -0600 Subject: [PATCH 09/26] Fetch status when highlighting it --- src/components/conversation/conversation.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 2ef2977a..1e6c0008 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -395,6 +395,7 @@ const conversation = { setHighlight (id) { if (!id) return this.highlight = id + this.$store.dispatch('fetchStatus', id) this.$store.dispatch('fetchFavsAndRepeats', id) this.$store.dispatch('fetchEmojiReactionsBy', id) }, From 8dac3932fed30e4238c2a7ef9cef8255a5c83a5a Mon Sep 17 00:00:00 2001 From: Sean King Date: Sat, 11 Jun 2022 20:10:16 -0600 Subject: [PATCH 10/26] Only refetch status on highlight if streaming is not enabled --- src/components/conversation/conversation.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 1e6c0008..f8df9eb5 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,6 +1,8 @@ import { reduce, filter, findIndex, clone, get } from 'lodash' import Status from '../status/status.vue' import ThreadTree from '../thread_tree/thread_tree.vue' +import { WSConnectionStatus } from '../../services/api/api.service.js' +import { mapGetters, mapState } from 'vuex' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -77,6 +79,9 @@ const conversation = { const maxDepth = this.$store.getters.mergedConfig.maxDepthInThread - 2 return maxDepth >= 1 ? maxDepth : 1 }, + streamingEnabled () { + return this.mergedConfig.useStreamingApi && this.mastoUserSocketStatus === WSConnectionStatus.JOINED + }, displayStyle () { return this.$store.getters.mergedConfig.conversationDisplay }, @@ -339,7 +344,11 @@ const conversation = { }, maybeHighlight () { return this.isExpanded ? this.highlight : null - } + }, + ...mapGetters(['mergedConfig']), + ...mapState({ + mastoUserSocketStatus: state => state.api.mastoUserSocketStatus + }) }, components: { Status, @@ -395,7 +404,11 @@ const conversation = { setHighlight (id) { if (!id) return this.highlight = id - this.$store.dispatch('fetchStatus', id) + + if (!this.streamingEnabled) { + this.$store.dispatch('fetchStatus', id) + } + this.$store.dispatch('fetchFavsAndRepeats', id) this.$store.dispatch('fetchEmojiReactionsBy', id) }, From 87fa7b82fb597ea597ee228c97cb2350a7d6c044 Mon Sep 17 00:00:00 2001 From: Sean King Date: Sat, 11 Jun 2022 20:40:53 -0600 Subject: [PATCH 11/26] Add warning for editing statuses --- src/components/post_status_form/post_status_form.js | 3 +++ src/components/post_status_form/post_status_form.vue | 8 ++++++++ src/i18n/en.json | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index d73219ad..ae81bfa6 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -261,6 +261,9 @@ const PostStatusForm = { uploadFileLimitReached () { return this.newStatus.files.length >= this.fileLimit }, + isEdit () { + return typeof this.statusId !== 'undefined' && this.statusId.trim() !== '' + }, ...mapGetters(['mergedConfig']), ...mapState({ mobileLayout: state => state.interface.mobileLayout diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 60cab745..650b5b8c 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -66,6 +66,14 @@ {{ $t('post_status.direct_warning_to_first_only') }} {{ $t('post_status.direct_warning_to_all') }}

+

+ {{ $t('post_status.edit_remote_warning') }} +
+ {{ $t('post_status.edit_unsupported_warning') }} +

Date: Sat, 11 Jun 2022 23:51:13 -0600 Subject: [PATCH 12/26] Clarification on unsupported edit features warning --- src/i18n/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index a303c0e8..b7a1dcbf 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -217,7 +217,7 @@ "direct_warning_to_all": "This post will be visible to all the mentioned users.", "direct_warning_to_first_only": "This post will only be visible to the mentioned users at the beginning of the message.", "edit_remote_warning": "Other remote instances may not support editing and unable to receive the latest version of your post.", - "edit_unsupported_warning": "Pleroma currently does not support editing mentions or polls.", + "edit_unsupported_warning": "Pleroma does not support removing mentions or editing polls.", "posting": "Posting", "post": "Post", "preview": "Preview", From 1b796691b0c396c1780e5520bf285e22923f3b6a Mon Sep 17 00:00:00 2001 From: Sean King Date: Sun, 12 Jun 2022 10:16:56 -0600 Subject: [PATCH 13/26] Change message on unsupported edit features --- src/i18n/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index b7a1dcbf..7b1bac79 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -217,7 +217,7 @@ "direct_warning_to_all": "This post will be visible to all the mentioned users.", "direct_warning_to_first_only": "This post will only be visible to the mentioned users at the beginning of the message.", "edit_remote_warning": "Other remote instances may not support editing and unable to receive the latest version of your post.", - "edit_unsupported_warning": "Pleroma does not support removing mentions or editing polls.", + "edit_unsupported_warning": "Pleroma does not support editing mentions or polls.", "posting": "Posting", "post": "Post", "preview": "Preview", From fa5d35523dd081b6948d38325374cac5707b7868 Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 20 Jun 2022 22:52:08 -0600 Subject: [PATCH 14/26] Add ability to view status history for edited statuses --- src/App.js | 2 + src/App.vue | 1 + src/components/extra_buttons/extra_buttons.js | 23 ++++++- .../extra_buttons/extra_buttons.vue | 11 ++++ .../status_history_modal.js | 60 +++++++++++++++++++ .../status_history_modal.vue | 46 ++++++++++++++ src/i18n/en.json | 3 +- src/main.js | 2 + src/modules/statusHistory.js | 25 ++++++++ src/modules/statuses.js | 3 + src/services/api/api.service.js | 17 +++--- .../entity_normalizer.service.js | 6 +- 12 files changed, 186 insertions(+), 13 deletions(-) create mode 100644 src/components/status_history_modal/status_history_modal.js create mode 100644 src/components/status_history_modal/status_history_modal.vue create mode 100644 src/modules/statusHistory.js diff --git a/src/App.js b/src/App.js index 6e0e34a8..af638a1c 100644 --- a/src/App.js +++ b/src/App.js @@ -13,6 +13,7 @@ import DesktopNav from './components/desktop_nav/desktop_nav.vue' import UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue' import EditStatusModal from './components/edit_status_modal/edit_status_modal.vue' import PostStatusModal from './components/post_status_modal/post_status_modal.vue' +import StatusHistoryModal from './components/status_history_modal/status_history_modal.vue' import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue' import { windowWidth, windowHeight } from './services/window_utils/window_utils' import { mapGetters } from 'vuex' @@ -37,6 +38,7 @@ export default { UserReportingModal, PostStatusModal, EditStatusModal, + StatusHistoryModal, GlobalNoticeList }, data: () => ({ diff --git a/src/App.vue b/src/App.vue index 9484f993..1b513e08 100644 --- a/src/App.vue +++ b/src/App.vue @@ -53,6 +53,7 @@ +
:first-child { + margin-top: 0; + } + + > :last-child { + margin-bottom: 0; + } + } + .media-upload-icon, .poll-icon, .emoji-icon { font-size: 1.85em; line-height: 1.1; From ed8bc6102290cb50d44c1c7aa5696aac5624d907 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Wed, 22 Jun 2022 16:05:27 -0400 Subject: [PATCH 17/26] Add last edited at indicator in status --- src/components/status/status.js | 6 ++++++ src/components/status/status.scss | 3 ++- src/components/status/status.vue | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/status/status.js b/src/components/status/status.js index a925f30b..b7f20374 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -392,6 +392,12 @@ const Status = { }, visibilityLocalized () { return this.$i18n.t('general.scope_in_timeline.' + this.status.visibility) + }, + isEdited () { + return this.status.edited_at !== null + }, + editingAvailable () { + return this.$store.state.instance.editingAvailable } }, methods: { diff --git a/src/components/status/status.scss b/src/components/status/status.scss index b3ad3818..ada9841e 100644 --- a/src/components/status/status.scss +++ b/src/components/status/status.scss @@ -156,7 +156,8 @@ margin-right: 0.2em; } - & .heading-reply-row { + & .heading-reply-row, + & .heading-edited-row { position: relative; align-content: baseline; font-size: 0.85em; diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 67ce999a..a9630a53 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -328,6 +328,30 @@ class="mentions-line" />
+
+ + + +
Date: Wed, 22 Jun 2022 16:05:44 -0400 Subject: [PATCH 18/26] Add English translation for last edited at indicator --- src/i18n/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/i18n/en.json b/src/i18n/en.json index f125c249..c4a044f5 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -748,6 +748,7 @@ "repeats": "Repeats", "delete": "Delete status", "edit": "Edit status", + "edited_at": "(last edited {time})", "pin": "Pin on profile", "unpin": "Unpin from profile", "pinned": "Pinned", From acd53957e09a499b04c8f901e5829607f7363b57 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Wed, 22 Jun 2022 16:14:19 -0400 Subject: [PATCH 19/26] Do not show edited indicator in history items --- src/components/status/status.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/status/status.vue b/src/components/status/status.vue index a9630a53..00462f0a 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -329,7 +329,7 @@ />
Date: Sun, 26 Jun 2022 13:25:36 -0600 Subject: [PATCH 20/26] Use watch to change localDescription --- src/components/attachment/attachment.js | 3 +++ src/components/attachment/attachment.vue | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index d62a4adc..5dc50475 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -129,6 +129,9 @@ const Attachment = { ...mapGetters(['mergedConfig']) }, watch: { + 'attachment.description' (newVal) { + this.localDescription = newVal + }, localDescription (newVal) { this.onEdit(newVal) } diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 14f6a0ae..2a89886d 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -166,7 +166,7 @@ :icon="placeholderIconClass" />

- {{ edit ? localDescription : attachment.description }} + {{ localDescription }}

@@ -244,7 +244,7 @@
@@ -257,7 +257,7 @@ @keydown.enter.prevent="" >

- {{ attachment.description }} + {{ localDescription }}

From 6f4b57e84559871f8c59f968d5cf17f2971e74c3 Mon Sep 17 00:00:00 2001 From: Sean King Date: Sun, 26 Jun 2022 17:41:21 -0600 Subject: [PATCH 21/26] Use a better way to clone the original status --- src/components/extra_buttons/extra_buttons.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js index 92eb63b0..5ddb7f0f 100644 --- a/src/components/extra_buttons/extra_buttons.js +++ b/src/components/extra_buttons/extra_buttons.js @@ -88,8 +88,7 @@ const ExtraButtons = { })) }, showStatusHistory () { - let originalStatus = {} - Object.assign(originalStatus, this.status) + let originalStatus = { ...this.status } delete originalStatus.attachments delete originalStatus.created_at delete originalStatus.emojis From 29ff63d1b420d0c36fb16c72389fdccd1294205a Mon Sep 17 00:00:00 2001 From: Sean King Date: Sun, 26 Jun 2022 18:10:30 -0600 Subject: [PATCH 22/26] Refactor to delete the properties for originalStatus in showStatusHistory in a better way --- src/components/extra_buttons/extra_buttons.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js index 5ddb7f0f..ef040d26 100644 --- a/src/components/extra_buttons/extra_buttons.js +++ b/src/components/extra_buttons/extra_buttons.js @@ -88,16 +88,9 @@ const ExtraButtons = { })) }, showStatusHistory () { - let originalStatus = { ...this.status } - delete originalStatus.attachments - delete originalStatus.created_at - delete originalStatus.emojis - delete originalStatus.text - delete originalStatus.raw_html - delete originalStatus.nsfw - delete originalStatus.poll - delete originalStatus.summary - delete originalStatus.summary_raw_html + const originalStatus = { ...this.status } + const stripFieldsList = ['attachments', 'created_at', 'emojis', 'text', 'raw_html', 'nsfw', 'poll', 'summary', 'summary_raw_html'] + stripFieldsList.forEach(p => delete originalStatus[p]) this.$store.dispatch('openStatusHistoryModal', originalStatus) } }, From 75216c5feb32b32e24952663ffa4233410585785 Mon Sep 17 00:00:00 2001 From: Sean King Date: Sun, 10 Jul 2022 21:07:47 -0600 Subject: [PATCH 23/26] Remove guard for raw_html --- src/components/status_body/status_body.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index 0a3dcf79..b8f6f9a0 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -125,13 +125,6 @@ const StatusContent = { generateTagLink (tag) { return `/tag/${tag}` } - }, - watch: { - 'status.raw_html' (newVal, oldVal) { - if (newVal !== oldVal) { - this.parseReadyDone = false - } - } } } From 232cc72df8352db15ac3e6b11c1f9c5908069771 Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 1 Aug 2022 18:45:52 -0600 Subject: [PATCH 24/26] Fix lint errors and warnings --- .../edit_status_modal/edit_status_modal.vue | 6 +++--- src/components/status/status.vue | 12 +++++------- .../status_history_modal/status_history_modal.vue | 4 ++-- src/services/api/api.service.js | 6 +++--- .../entity_normalizer/entity_normalizer.service.js | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/components/edit_status_modal/edit_status_modal.vue b/src/components/edit_status_modal/edit_status_modal.vue index 00dde7de..1dbacaab 100644 --- a/src/components/edit_status_modal/edit_status_modal.vue +++ b/src/components/edit_status_modal/edit_status_modal.vue @@ -11,10 +11,10 @@ diff --git a/src/components/status/status.vue b/src/components/status/status.vue index a13e5ab0..5ddb94b4 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -340,13 +340,11 @@ keypath="time.in_past" tag="span" > - + diff --git a/src/components/status_history_modal/status_history_modal.vue b/src/components/status_history_modal/status_history_modal.vue index d6680df2..990be35b 100644 --- a/src/components/status_history_modal/status_history_modal.vue +++ b/src/components/status_history_modal/status_history_modal.vue @@ -17,9 +17,9 @@ v-for="status in history" :key="status.id" :statusoid="status" - :isPreview="true" + :is-preview="true" class="conversation-status status-fadein panel-body" - /> + /> diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 41c14596..381dd112 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -417,7 +417,7 @@ const fetchStatus = ({ id, credentials }) => { } const fetchStatusSource = ({ id, credentials }) => { - let url = MASTODON_STATUS_SOURCE_URL(id) + const url = MASTODON_STATUS_SOURCE_URL(id) return fetch(url, { headers: authHeaders(credentials) }) .then((data) => { if (data.ok) { @@ -430,7 +430,7 @@ const fetchStatusSource = ({ id, credentials }) => { } const fetchStatusHistory = ({ status, credentials }) => { - let url = MASTODON_STATUS_HISTORY_URL(status.id) + const url = MASTODON_STATUS_HISTORY_URL(status.id) return promisedRequest({ url, credentials }) .then((data) => { data.reverse() @@ -767,7 +767,7 @@ const editStatus = ({ }) } - let putHeaders = authHeaders(credentials) + const putHeaders = authHeaders(credentials) return fetch(MASTODON_STATUS_URL(id), { body: form, diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index c00e9796..c1b2ffac 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -378,7 +378,7 @@ export const parseStatus = (data) => { output.favoritedBy = [] output.rebloggedBy = [] - if (data.hasOwnProperty('originalStatus')) { + if (Object.prototype.hasOwnProperty.call(data, 'originalStatus')) { Object.assign(output, data.originalStatus) } From b70d50407cef26926635b1b47131c01e597fcfc6 Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 1 Aug 2022 21:25:08 -0600 Subject: [PATCH 25/26] Refresh the relative time object for a Timeago component if the time changes --- src/components/timeago/timeago.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/timeago/timeago.vue b/src/components/timeago/timeago.vue index 2b487dfd..fce9605b 100644 --- a/src/components/timeago/timeago.vue +++ b/src/components/timeago/timeago.vue @@ -34,6 +34,13 @@ export default { unmounted () { clearTimeout(this.interval) }, + watch: { + time (newVal, oldVal) { + if (oldVal !== newVal) { + this.refreshRelativeTimeObject() + } + } + }, methods: { refreshRelativeTimeObject () { const nowThreshold = typeof this.nowThreshold === 'number' ? this.nowThreshold : 1 From 04e62df377fdd2ea563f58dcd23ea8048fc1c140 Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 2 Aug 2022 23:19:25 -0600 Subject: [PATCH 26/26] Allow for template inside Timeago component that shows unless the time string is 'just now' --- src/components/status/status.vue | 16 ++++++---------- src/components/timeago/timeago.vue | 26 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 5ddb94b4..8036ddf4 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -336,16 +336,12 @@ tag="span" > diff --git a/src/components/timeago/timeago.vue b/src/components/timeago/timeago.vue index fce9605b..b5f49515 100644 --- a/src/components/timeago/timeago.vue +++ b/src/components/timeago/timeago.vue @@ -3,7 +3,7 @@ :datetime="time" :title="localeDateString" > - {{ $tc(relativeTime.key, relativeTime.num, [relativeTime.num]) }} + {{ relativeTimeString }} @@ -13,7 +13,7 @@ import localeService from 'src/services/locale/locale.service.js' export default { name: 'Timeago', - props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold'], + props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold', 'templateKey'], data () { return { relativeTime: { key: 'time.now', num: 0 }, @@ -26,21 +26,31 @@ export default { return typeof this.time === 'string' ? new Date(Date.parse(this.time)).toLocaleString(browserLocale) : this.time.toLocaleString(browserLocale) + }, + relativeTimeString () { + const timeString = this.$i18n.tc(this.relativeTime.key, this.relativeTime.num, [this.relativeTime.num]) + + if (typeof this.templateKey === 'string' && this.relativeTime.key !== 'time.now') { + return this.$i18n.t(this.templateKey, [timeString]) + } + + return timeString } }, - created () { - this.refreshRelativeTimeObject() - }, - unmounted () { - clearTimeout(this.interval) - }, watch: { time (newVal, oldVal) { if (oldVal !== newVal) { + clearTimeout(this.interval) this.refreshRelativeTimeObject() } } }, + created () { + this.refreshRelativeTimeObject() + }, + unmounted () { + clearTimeout(this.interval) + }, methods: { refreshRelativeTimeObject () { const nowThreshold = typeof this.nowThreshold === 'number' ? this.nowThreshold : 1