From e7e35ead09589e1673dd6b6fdd24f7679ef108bf Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Wed, 9 Feb 2022 16:21:19 -0500 Subject: Add confirmation for muting --- src/components/user_card/user_card.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/components/user_card/user_card.vue') diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 349c7cb1..fac900a9 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -314,6 +314,24 @@ :handle-links="true" /> + + + + + -- cgit v1.2.3-70-g09d2 From 39e4746f615970001839309e06a0f13d9613b175 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Thu, 17 Mar 2022 00:06:26 -0400 Subject: Use portal for modals --- src/components/account_actions/account_actions.vue | 36 +++++++------- src/components/confirm_modal/confirm_modal.js | 5 -- src/components/confirm_modal/confirm_modal.vue | 1 - src/components/desktop_nav/desktop_nav.vue | 22 +++++---- src/components/extra_buttons/extra_buttons.vue | 22 +++++---- src/components/follow_button/follow_button.vue | 56 +++++++++++----------- src/components/mobile_nav/mobile_nav.vue | 22 +++++---- src/components/retweet_button/retweet_button.vue | 22 +++++---- src/components/user_card/user_card.vue | 36 +++++++------- 9 files changed, 114 insertions(+), 108 deletions(-) (limited to 'src/components/user_card/user_card.vue') diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue index dfe1f706..273aac69 100644 --- a/src/components/account_actions/account_actions.vue +++ b/src/components/account_actions/account_actions.vue @@ -74,24 +74,26 @@ - - + - - - + + + + + diff --git a/src/components/confirm_modal/confirm_modal.js b/src/components/confirm_modal/confirm_modal.js index bb5e9d97..96ddc118 100644 --- a/src/components/confirm_modal/confirm_modal.js +++ b/src/components/confirm_modal/confirm_modal.js @@ -11,12 +11,7 @@ const ConfirmModal = { components: { DialogModal }, - data: { - }, props: { - showing: { - type: Boolean - }, title: { type: String }, diff --git a/src/components/confirm_modal/confirm_modal.vue b/src/components/confirm_modal/confirm_modal.vue index 59e46dc1..5b5014c5 100644 --- a/src/components/confirm_modal/confirm_modal.vue +++ b/src/components/confirm_modal/confirm_modal.vue @@ -1,6 +1,5 @@ diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue index 293f6d68..4641947a 100644 --- a/src/components/extra_buttons/extra_buttons.vue +++ b/src/components/extra_buttons/extra_buttons.vue @@ -165,16 +165,18 @@ /> - - {{ $t('status.delete_confirm') }} - + + + {{ $t('status.delete_confirm') }} + + diff --git a/src/components/follow_button/follow_button.vue b/src/components/follow_button/follow_button.vue index 4fc2233a..5c799406 100644 --- a/src/components/follow_button/follow_button.vue +++ b/src/components/follow_button/follow_button.vue @@ -1,33 +1,33 @@ diff --git a/src/components/mobile_nav/mobile_nav.vue b/src/components/mobile_nav/mobile_nav.vue index 0f23b7ac..6b6b8f21 100644 --- a/src/components/mobile_nav/mobile_nav.vue +++ b/src/components/mobile_nav/mobile_nav.vue @@ -88,16 +88,18 @@ ref="sideDrawer" :logout="logout" /> - - {{ $t('login.logout_confirm') }} - + + + {{ $t('login.logout_confirm') }} + + diff --git a/src/components/retweet_button/retweet_button.vue b/src/components/retweet_button/retweet_button.vue index 38d4dc3f..9ed24bd5 100644 --- a/src/components/retweet_button/retweet_button.vue +++ b/src/components/retweet_button/retweet_button.vue @@ -59,16 +59,18 @@ > {{ status.repeat_num }} - - {{ $t('status.repeat_confirm') }} - + + + {{ $t('status.repeat_confirm') }} + + diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index fac900a9..5a848ead 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -314,24 +314,26 @@ :handle-links="true" /> - - + - - - + + + + + -- cgit v1.2.3-70-g09d2 From dc04c8cbd48dd8dcfc6b1937663e57983d38562a Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Wed, 6 Apr 2022 14:54:58 -0400 Subject: Use vue3 teleport instead of portal --- src/components/account_actions/account_actions.vue | 4 ++-- src/components/desktop_nav/desktop_nav.vue | 4 ++-- src/components/extra_buttons/extra_buttons.vue | 4 ++-- src/components/follow_button/follow_button.vue | 4 ++-- src/components/mobile_nav/mobile_nav.vue | 4 ++-- src/components/retweet_button/retweet_button.vue | 4 ++-- src/components/user_card/user_card.vue | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/components/user_card/user_card.vue') diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue index 273aac69..fc303271 100644 --- a/src/components/account_actions/account_actions.vue +++ b/src/components/account_actions/account_actions.vue @@ -74,7 +74,7 @@ - + - + diff --git a/src/components/desktop_nav/desktop_nav.vue b/src/components/desktop_nav/desktop_nav.vue index 18630385..92622cf9 100644 --- a/src/components/desktop_nav/desktop_nav.vue +++ b/src/components/desktop_nav/desktop_nav.vue @@ -76,7 +76,7 @@ - + {{ $t('login.logout_confirm') }} - + diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue index 4641947a..c1c15c0f 100644 --- a/src/components/extra_buttons/extra_buttons.vue +++ b/src/components/extra_buttons/extra_buttons.vue @@ -165,7 +165,7 @@ /> - + {{ $t('status.delete_confirm') }} - + diff --git a/src/components/follow_button/follow_button.vue b/src/components/follow_button/follow_button.vue index 5c799406..b4567348 100644 --- a/src/components/follow_button/follow_button.vue +++ b/src/components/follow_button/follow_button.vue @@ -7,7 +7,7 @@ @click="onClick" > {{ label }} - + - + diff --git a/src/components/mobile_nav/mobile_nav.vue b/src/components/mobile_nav/mobile_nav.vue index 6b6b8f21..6d826622 100644 --- a/src/components/mobile_nav/mobile_nav.vue +++ b/src/components/mobile_nav/mobile_nav.vue @@ -88,7 +88,7 @@ ref="sideDrawer" :logout="logout" /> - + {{ $t('login.logout_confirm') }} - + diff --git a/src/components/retweet_button/retweet_button.vue b/src/components/retweet_button/retweet_button.vue index 9ed24bd5..134fcb36 100644 --- a/src/components/retweet_button/retweet_button.vue +++ b/src/components/retweet_button/retweet_button.vue @@ -59,7 +59,7 @@ > {{ status.repeat_num }} - + {{ $t('status.repeat_confirm') }} - + diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 5a848ead..856ed54b 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -314,7 +314,7 @@ :handle-links="true" /> - + - + -- cgit v1.2.3-70-g09d2 From ec957d41620fecc5103474f1b07bbb96f5cae446 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Sat, 9 Apr 2022 23:26:27 -0400 Subject: Make confirm dialogs work with vue-i18n 9 --- src/components/account_actions/account_actions.vue | 15 ++++++++------- src/components/follow_button/follow_button.vue | 15 ++++++++------- src/components/user_card/user_card.vue | 15 ++++++++------- 3 files changed, 24 insertions(+), 21 deletions(-) (limited to 'src/components/user_card/user_card.vue') diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue index fc303271..161bab09 100644 --- a/src/components/account_actions/account_actions.vue +++ b/src/components/account_actions/account_actions.vue @@ -83,15 +83,16 @@ @accepted="doBlockUser" @cancelled="hideConfirmBlock" > - - - + + diff --git a/src/components/follow_button/follow_button.vue b/src/components/follow_button/follow_button.vue index b4567348..e421c15b 100644 --- a/src/components/follow_button/follow_button.vue +++ b/src/components/follow_button/follow_button.vue @@ -16,15 +16,16 @@ @accepted="doUnfollow" @cancelled="hideConfirmUnfollow" > - - - + + diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 856ed54b..01882aa8 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -323,15 +323,16 @@ @accepted="doMuteUser" @cancelled="hideConfirmMute" > - - - + + -- cgit v1.2.3-70-g09d2 From 228a9afdf5ecc10a17de31f88bd88ad1efbe0004 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Sat, 30 Apr 2022 11:08:19 -0400 Subject: Add timed-mute functionality --- src/components/poll/poll_form.js | 13 ++----------- src/components/user_card/user_card.js | 13 +++++++++++-- src/components/user_card/user_card.scss | 5 +++++ src/components/user_card/user_card.vue | 28 +++++++++++++++++++++++++++- src/modules/users.js | 7 +++++-- src/services/api/api.service.js | 8 ++++++-- src/services/date_utils/date_utils.js | 16 ++++++++++++++++ 7 files changed, 72 insertions(+), 18 deletions(-) (limited to 'src/components/user_card/user_card.vue') diff --git a/src/components/poll/poll_form.js b/src/components/poll/poll_form.js index e30645c3..a2070155 100644 --- a/src/components/poll/poll_form.js +++ b/src/components/poll/poll_form.js @@ -94,19 +94,10 @@ export default { }, convertExpiryToUnit (unit, amount) { // Note: we want seconds and not milliseconds - switch (unit) { - case 'minutes': return (1000 * amount) / DateUtils.MINUTE - case 'hours': return (1000 * amount) / DateUtils.HOUR - case 'days': return (1000 * amount) / DateUtils.DAY - } + return DateUtils.secondsToUnit(unit, amount) }, convertExpiryFromUnit (unit, amount) { - // Note: we want seconds and not milliseconds - switch (unit) { - case 'minutes': return 0.001 * amount * DateUtils.MINUTE - case 'hours': return 0.001 * amount * DateUtils.HOUR - case 'days': return 0.001 * amount * DateUtils.DAY - } + return DateUtils.unitToSeconds(unit, amount) }, expiryAmountChange () { this.expiryAmount = diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 1bcc4341..e17bf8eb 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -1,3 +1,4 @@ +import { unitToSeconds } from 'src/services/date_utils/date_utils.js' import UserAvatar from '../user_avatar/user_avatar.vue' import RemoteFollow from '../remote_follow/remote_follow.vue' import ProgressButton from '../progress_button/progress_button.vue' @@ -48,7 +49,9 @@ export default { return { followRequestInProgress: false, betterShadow: this.$store.state.interface.browserSupport.cssFilter, - showingConfirmMute: false + showingConfirmMute: false, + muteExpiryAmount: 0, + muteExpiryUnit: 'minutes' } }, created () { @@ -142,6 +145,9 @@ export default { shouldConfirmMute () { return this.mergedConfig.modalOnMute }, + muteExpiryUnits () { + return ['minutes', 'hours', 'days'] + }, ...mapGetters(['mergedConfig']) }, components: { @@ -172,7 +178,10 @@ export default { } }, doMuteUser () { - this.$store.dispatch('muteUser', this.user.id) + this.$store.dispatch('muteUser', { + id: this.user.id, + expiresIn: this.shouldConfirmMute ? unitToSeconds(this.muteExpiryUnit, this.muteExpiryAmount) : 0 + }) this.hideConfirmMute() }, unmuteUser () { diff --git a/src/components/user_card/user_card.scss b/src/components/user_card/user_card.scss index d56b6672..4ab93a8a 100644 --- a/src/components/user_card/user_card.scss +++ b/src/components/user_card/user_card.scss @@ -355,3 +355,8 @@ text-decoration: none; } } + +.mute-expiry { + display: flex; + flex-direction: row; +} diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 01882aa8..2de14063 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -325,7 +325,7 @@ > +
+ + + +
diff --git a/src/modules/users.js b/src/modules/users.js index 053e44b6..a1316ba2 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -61,13 +61,16 @@ const editUserNote = (store, { id, comment }) => { .then((relationship) => store.commit('updateUserRelationship', [relationship])) } -const muteUser = (store, id) => { +const muteUser = (store, args) => { + const id = typeof args === 'object' ? args.id : args + const expiresIn = typeof args === 'object' ? args.expiresIn : 0 + const predictedRelationship = store.state.relationships[id] || { id } predictedRelationship.muting = true store.commit('updateUserRelationship', [predictedRelationship]) store.commit('addMuteId', id) - return store.rootState.api.backendInteractor.muteUser({ id }) + return store.rootState.api.backendInteractor.muteUser({ id, expiresIn }) .then((relationship) => { store.commit('updateUserRelationship', [relationship]) store.commit('addMuteId', id) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index af12265e..c7a36af9 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -1118,8 +1118,12 @@ const fetchMutes = ({ credentials }) => { .then((users) => users.map(parseUser)) } -const muteUser = ({ id, credentials }) => { - return promisedRequest({ url: MASTODON_MUTE_USER_URL(id), credentials, method: 'POST' }) +const muteUser = ({ id, expiresIn, credentials }) => { + const payload = {} + if (expiresIn) { + payload['expires_in'] = expiresIn + } + return promisedRequest({ url: MASTODON_MUTE_USER_URL(id), credentials, method: 'POST', payload }) } const unmuteUser = ({ id, credentials }) => { diff --git a/src/services/date_utils/date_utils.js b/src/services/date_utils/date_utils.js index c93d2176..ed8e1417 100644 --- a/src/services/date_utils/date_utils.js +++ b/src/services/date_utils/date_utils.js @@ -41,3 +41,19 @@ export const relativeTimeShort = (date, nowThreshold = 1) => { r.key += '_short' return r } + +export const unitToSeconds = (unit, amount) => { + switch (unit) { + case 'minutes': return 0.001 * amount * MINUTE + case 'hours': return 0.001 * amount * HOUR + case 'days': return 0.001 * amount * DAY + } +} + +export const secondsToUnit = (unit, amount) => { + switch (unit) { + case 'minutes': return (1000 * amount) / MINUTE + case 'hours': return (1000 * amount) / HOUR + case 'days': return (1000 * amount) / DAY + } +} -- cgit v1.2.3-70-g09d2