From b77565821b399751074c0aff9c7e735fa3e4b65a Mon Sep 17 00:00:00 2001
From: Sean King
Date: Tue, 7 Jun 2022 21:31:48 -0600
Subject: [PATCH 01/21] 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 | 48 +++++++---
.../post_status_form/post_status_form.vue | 1 +
src/main.js | 4 +-
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 +++++++++
16 files changed, 365 insertions(+), 14 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 4304787f..6637a08e 100644
--- a/src/App.js
+++ b/src/App.js
@@ -10,6 +10,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'
@@ -33,6 +34,7 @@ export default {
SettingsModal,
UserReportingModal,
PostStatusModal,
+ EditStatusModal,
GlobalNoticeList
},
data: () => ({
diff --git a/src/App.vue b/src/App.vue
index ed4f318e..1e2cd343 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -58,6 +58,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 042a96a1..6f59b11d 100644
--- a/src/components/extra_buttons/extra_buttons.js
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -101,6 +101,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 b1cbe8dc..b3ccb370 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: Mon, 20 Jun 2022 22:52:08 -0600
Subject: [PATCH 12/21] 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/main.js | 4 +-
src/modules/statusHistory.js | 25 ++++++++
src/modules/statuses.js | 3 +
src/services/api/api.service.js | 17 +++---
.../entity_normalizer.service.js | 6 +-
11 files changed, 185 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 6637a08e..5310d504 100644
--- a/src/App.js
+++ b/src/App.js
@@ -12,6 +12,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'
@@ -35,6 +36,7 @@ export default {
UserReportingModal,
PostStatusModal,
EditStatusModal,
+ StatusHistoryModal,
GlobalNoticeList
},
data: () => ({
diff --git a/src/App.vue b/src/App.vue
index 1e2cd343..7aad1a65 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -59,6 +59,7 @@
+
diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js
index 2a375a80..27b9b7c9 100644
--- a/src/components/extra_buttons/extra_buttons.js
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -7,7 +7,8 @@ import {
faEyeSlash,
faThumbtack,
faShareAlt,
- faExternalLinkAlt
+ faExternalLinkAlt,
+ faHistory
} from '@fortawesome/free-solid-svg-icons'
import {
faBookmark as faBookmarkReg,
@@ -22,7 +23,8 @@ library.add(
faThumbtack,
faShareAlt,
faExternalLinkAlt,
- faFlag
+ faFlag,
+ faHistory
)
const ExtraButtons = {
@@ -114,6 +116,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: {
@@ -147,6 +163,9 @@ const ExtraButtons = {
},
shouldConfirmDelete () {
return this.$store.getters.mergedConfig.modalOnDelete
+ },
+ 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 b3ccb370..b10ceb2b 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;
--
2.34.1
From 92790cf6b43bd3d38cd174fc326c4428b39aa9c2 Mon Sep 17 00:00:00 2001
From: Tusooa Zhu
Date: Wed, 22 Jun 2022 16:05:27 -0400
Subject: [PATCH 15/21] 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 2959c3fd..a794b284 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -437,6 +437,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 cc9d4eb7..448577d3 100644
--- a/src/components/status/status.scss
+++ b/src/components/status/status.scss
@@ -160,7 +160,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 aef375fa..7bd2ef4d 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -329,6 +329,30 @@
class="mentions-line"
/>
+
+
+
+
+
+
+
+
+
+
+
Date: Wed, 22 Jun 2022 16:14:19 -0400
Subject: [PATCH 16/21] 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 7bd2ef4d..7366670b 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -330,7 +330,7 @@
/>
Date: Sun, 26 Jun 2022 13:25:36 -0600
Subject: [PATCH 17/21] 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 5450f7a1..0568c6e2 100644
--- a/src/components/attachment/attachment.js
+++ b/src/components/attachment/attachment.js
@@ -132,6 +132,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 d2c5531b..947b1bfc 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 @@
@@ -259,7 +259,7 @@
@input="resize"
/>
- {{ attachment.description }}
+ {{ localDescription }}
--
2.34.1
From a1d6758caa560ed20a8979d3ae6275babafac049 Mon Sep 17 00:00:00 2001
From: Sean King
Date: Sun, 26 Jun 2022 17:41:21 -0600
Subject: [PATCH 18/21] 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 36d199c5..e991d661 100644
--- a/src/components/extra_buttons/extra_buttons.js
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -118,8 +118,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
--
2.34.1
From 1c5b94c7a9b9c82fef1768cf2553d9488a00eb10 Mon Sep 17 00:00:00 2001
From: Sean King
Date: Sun, 26 Jun 2022 18:10:30 -0600
Subject: [PATCH 19/21] 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 e991d661..f24e261b 100644
--- a/src/components/extra_buttons/extra_buttons.js
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -118,16 +118,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)
}
},
--
2.34.1
From 35dc8ee30a93dc6f749fb57375c5a1ecae33369d Mon Sep 17 00:00:00 2001
From: Sean King
Date: Sun, 10 Jul 2022 21:07:47 -0600
Subject: [PATCH 20/21] 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 43288bca..9e380f28 100644
--- a/src/components/status_body/status_body.js
+++ b/src/components/status_body/status_body.js
@@ -137,13 +137,6 @@ const StatusContent = {
const translateTo = this.$store.getters.mergedConfig.translationLanguage || this.$store.state.instance.interfaceLanguage
this.$store.dispatch('translateStatus', { id: this.status.id, language: translateTo, from: this.translateFrom })
}
- },
- watch: {
- 'status.raw_html' (newVal, oldVal) {
- if (newVal !== oldVal) {
- this.parseReadyDone = false
- }
- }
}
}
--
2.34.1
From 9da9425c9bd80ddd7c619f705d4abf67fada1ffd Mon Sep 17 00:00:00 2001
From: FloatingGhost
Date: Tue, 6 Sep 2022 18:26:45 +0100
Subject: [PATCH 21/21] alter localisation
---
src/components/extra_buttons/extra_buttons.vue | 2 +-
.../status_history_modal/status_history_modal.vue | 2 +-
src/i18n/en.json | 7 +++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue
index a71130e8..a15f0bf2 100644
--- a/src/components/extra_buttons/extra_buttons.vue
+++ b/src/components/extra_buttons/extra_buttons.vue
@@ -93,7 +93,7 @@
{{ $t("status.status_history") }}
+ />{{ $t("status.edit_history") }}