From d98c9c9657ca51593bf3e31bb609d073e5a2c56e Mon Sep 17 00:00:00 2001 From: notfire Date: Fri, 17 Jan 2025 15:22:33 -0500 Subject: [PATCH] add an option to confirm that you want a post to be public --- .../post_status_form/post_status_form.js | 37 ++++++++++++++++++- .../post_status_form/post_status_form.vue | 20 ++++++++-- .../settings_modal/tabs/general_tab.vue | 5 +++ src/i18n/en.json | 5 +++ src/modules/config.js | 1 + src/modules/instance.js | 1 + 6 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 6eee23ce..7cf65211 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -14,6 +14,7 @@ import suggestor from '../emoji_input/suggestor.js' import { mapGetters, mapState } from 'vuex' import Checkbox from '../checkbox/checkbox.vue' import Select from '../select/select.vue' +import ConfirmModal from '../confirm_modal/confirm_modal.vue' import { library } from '@fortawesome/fontawesome-svg-core' @@ -35,6 +36,10 @@ library.add( faCircleNotch ) +var finEvent +var finNewStatus +var finOpts + const buildMentionsString = ({ user, attentions = [] }, currentUser) => { let allAttentions = [...attentions] @@ -122,7 +127,8 @@ const PostStatusForm = { Select, Attachment, StatusContent, - Gallery + Gallery, + ConfirmModal }, mounted () { this.updateIdempotencyKey() @@ -236,7 +242,8 @@ const PostStatusForm = { idempotencyKey: '', activeEmojiInput: undefined, activeTextInput: undefined, - subjectVisible: showSubject + subjectVisible: showSubject, + showingPostConfirmDialog: false } }, computed: { @@ -770,6 +777,32 @@ const PostStatusForm = { } } return this.$store.state.users.currentUser.default_scope + }, + hideDenyConfirmDialog () { + this.showingPostConfirmDialog = false + + finEvent = null + finNewStatus = null + finOpts = null + }, + doPostYes () { + this.showingPostConfirmDialog = false + this.postStatus(finEvent, finNewStatus, finOpts) + }, + handlePost (event, newStatus, opts = {}) { + if (this.mergedConfig.modalOnPubPost) { + if (newStatus.visibility === "public" || newStatus.visibility === "unlisted" || newStatus.visibility === "local") { + finEvent = event + finNewStatus = newStatus + finOpts = opts + + this.showingPostConfirmDialog = true + } else { + this.postStatus(event, newStatus, opts = {}) + } + } else { + this.postStatus(event, newStatus, opts = {}) + } } } } diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 79049f05..ebab96ab 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -171,9 +171,9 @@ :disabled="posting && !optimisticPosting" class="form-post-body" :class="{ 'scrollable-form': !!maxHeight, '-has-subject': subjectVisible }" - @keydown.exact.enter="submitOnEnter && postStatus($event, newStatus)" - @keydown.meta.enter="postStatus($event, newStatus)" - @keydown.ctrl.enter="!submitOnEnter && postStatus($event, newStatus)" + @keydown.exact.enter="submitOnEnter && handlePost($event, newStatus)" + @keydown.meta.enter="handlePost($event, newStatus)" + @keydown.ctrl.enter="!submitOnEnter && handlePost($event, newStatus)" @input="resize" @compositionupdate="resize" @paste="paste" @@ -317,7 +317,7 @@ v-else :disabled="uploadingFiles || disableSubmit" class="btn button-default" - @click.stop.prevent="postStatus($event, newStatus)" + @click.stop.prevent="handlePost($event, newStatus)" > {{ $t('post_status.post') }} @@ -371,6 +371,18 @@ + + + {{ $t('post_status.post_confirm') }} + + diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue index 4f314ca0..82a83f05 100644 --- a/src/components/settings_modal/tabs/general_tab.vue +++ b/src/components/settings_modal/tabs/general_tab.vue @@ -320,6 +320,11 @@ {{ $t('settings.confirm_dialogs_deny_follow') }} +
  • + + {{ $t('settings.confirm_dialogs_public_post') }} + +
  • diff --git a/src/i18n/en.json b/src/i18n/en.json index 984d5fc7..6b41cfb8 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -395,6 +395,10 @@ "media_not_sensitive_warning": "You have a Content Warning, but the attachments are not marked as sensitive!", "new_status": "New post", "post": "Post", + "post_confirm": "Are you sure you want to post this publicly?", + "post_confirm_accept_button": "Yes, post", + "post_confirm_cancel_button": "No, cancel", + "post_confirm_title": "Confirm post visibility", "posting": "Posting", "preview": "Preview", "preview_empty": "Empty", @@ -511,6 +515,7 @@ "confirm_dialogs_delete": "Deleting a post", "confirm_dialogs_deny_follow": "Rejecting a follow request", "confirm_dialogs_mute": "Muting someone", + "confirm_dialogs_public_post": "Posting unlisted or publicly", "confirm_dialogs_repeat": "Boosting a post", "confirm_dialogs_unfollow": "Unfollowing someone", "confirm_new_password": "Confirm new password", diff --git a/src/modules/config.js b/src/modules/config.js index c3363a5e..e7764dde 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -90,6 +90,7 @@ export const defaultState = { modalOnLogout: undefined, // instance default modalOnApproveFollow: undefined, // instance default modalOnDenyFollow: undefined, // instance default + modalOnPubPost: undefined, // instance default playVideosInModal: false, useOneClickNsfw: false, useContainFit: true, diff --git a/src/modules/instance.js b/src/modules/instance.js index 5c3fc1c9..3cc70c02 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -47,6 +47,7 @@ const defaultState = { modalOnLogout: true, modalOnApproveFollow: false, modalOnDenyFollow: false, + modalOnPubPost: false, loginMethod: 'password', logo: '/static/logo.svg', logoMargin: '.2em',