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 @@
+
diff --git a/src/components/edit_status_modal/edit_status_modal.js b/src/components/edit_status_modal/edit_status_modal.js
new file mode 100644
index 00000000..14320d21
--- /dev/null
+++ b/src/components/edit_status_modal/edit_status_modal.js
@@ -0,0 +1,75 @@
+import PostStatusForm from '../post_status_form/post_status_form.vue'
+import Modal from '../modal/modal.vue'
+import statusPosterService from '../../services/status_poster/status_poster.service.js'
+import get from 'lodash/get'
+
+const EditStatusModal = {
+ components: {
+ PostStatusForm,
+ Modal
+ },
+ data () {
+ return {
+ resettingForm: false
+ }
+ },
+ computed: {
+ isLoggedIn () {
+ return !!this.$store.state.users.currentUser
+ },
+ modalActivated () {
+ return this.$store.state.editStatus.modalActivated
+ },
+ isFormVisible () {
+ return this.isLoggedIn && !this.resettingForm && this.modalActivated
+ },
+ params () {
+ return this.$store.state.editStatus.params || {}
+ }
+ },
+ watch: {
+ params (newVal, oldVal) {
+ if (get(newVal, 'repliedUser.id') !== get(oldVal, 'repliedUser.id')) {
+ this.resettingForm = true
+ this.$nextTick(() => {
+ this.resettingForm = false
+ })
+ }
+ },
+ isFormVisible (val) {
+ if (val) {
+ this.$nextTick(() => this.$el && this.$el.querySelector('textarea').focus())
+ }
+ }
+ },
+ methods: {
+ doEditStatus ({ status, spoilerText, sensitive, media, contentType, poll }) {
+ const params = {
+ store: this.$store,
+ statusId: this.$store.state.editStatus.params.statusId,
+ status,
+ spoilerText,
+ sensitive,
+ poll,
+ media,
+ contentType
+ }
+
+ return statusPosterService.editStatus(params)
+ .then((data) => {
+ return data
+ })
+ .catch((err) => {
+ console.error('Error editing status', err)
+ return {
+ error: err.message
+ }
+ })
+ },
+ closeModal () {
+ this.$store.dispatch('closeEditStatusModal')
+ }
+ }
+}
+
+export default EditStatusModal
diff --git a/src/components/edit_status_modal/edit_status_modal.vue b/src/components/edit_status_modal/edit_status_modal.vue
new file mode 100644
index 00000000..00dde7de
--- /dev/null
+++ b/src/components/edit_status_modal/edit_status_modal.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js
index dd45b6b9..9508a707 100644
--- a/src/components/extra_buttons/extra_buttons.js
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -71,6 +71,19 @@ const ExtraButtons = {
},
reportStatus () {
this.$store.dispatch('openUserReportingModal', { userId: this.status.user.id, statusIds: [this.status.id] })
+ },
+ editStatus () {
+ this.$store.dispatch('fetchStatusSource', { id: this.status.id })
+ .then(data => this.$store.dispatch('openEditStatusModal', {
+ statusId: this.status.id,
+ subject: data.spoiler_text,
+ statusText: data.text,
+ statusIsSensitive: this.status.nsfw,
+ statusPoll: this.status.poll,
+ statusFiles: this.status.attachments,
+ visibility: this.status.visibility,
+ statusContentType: data.content_type
+ }))
}
},
computed: {
diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue
index a3c3c767..8e90ee27 100644
--- a/src/components/extra_buttons/extra_buttons.vue
+++ b/src/components/extra_buttons/extra_buttons.vue
@@ -73,6 +73,17 @@
icon="bookmark"
/>{{ $t("status.unbookmark") }}
+
+
+ {{ $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 @@
+
diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js
index 8a703953..11fe3235 100644
--- a/src/components/extra_buttons/extra_buttons.js
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -6,7 +6,8 @@ import {
faEyeSlash,
faThumbtack,
faShareAlt,
- faExternalLinkAlt
+ faExternalLinkAlt,
+ faHistory
} from '@fortawesome/free-solid-svg-icons'
import {
faBookmark as faBookmarkReg,
@@ -21,7 +22,8 @@ library.add(
faThumbtack,
faShareAlt,
faExternalLinkAlt,
- faFlag
+ faFlag,
+ faHistory
)
const ExtraButtons = {
@@ -84,6 +86,20 @@ const ExtraButtons = {
visibility: this.status.visibility,
statusContentType: data.content_type
}))
+ },
+ showStatusHistory () {
+ let originalStatus = {}
+ Object.assign(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
+ this.$store.dispatch('openStatusHistoryModal', originalStatus)
}
},
computed: {
@@ -104,6 +120,9 @@ const ExtraButtons = {
},
statusLink () {
return `${this.$store.state.instance.server}${this.$router.resolve({ name: 'conversation', params: { id: this.status.id } }).href}`
+ },
+ isEdited () {
+ return this.status.edited_at !== null
}
}
}
diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue
index 8e90ee27..877e1424 100644
--- a/src/components/extra_buttons/extra_buttons.vue
+++ b/src/components/extra_buttons/extra_buttons.vue
@@ -84,6 +84,17 @@
icon="pen"
/>{{ $t("status.edit") }}
+
{{ $t("status.edit") }}
: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 | 28 +++++++++++++++++++---------
2 files changed, 25 insertions(+), 19 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,6 +26,23 @@ 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
+ }
+ },
+ watch: {
+ time (newVal, oldVal) {
+ if (oldVal !== newVal) {
+ clearTimeout(this.interval)
+ this.refreshRelativeTimeObject()
+ }
}
},
created () {
@@ -34,13 +51,6 @@ 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