Merge remote-tracking branch 'mkljczk/quotes-count' into quotes-count

This commit is contained in:
marcin mikołajczak 2024-01-19 19:01:38 +01:00
commit d28e48e9dc
10 changed files with 56 additions and 8 deletions

View File

@ -0,0 +1 @@
Display public favorites on user profiles

View File

@ -0,0 +1 @@
Show a dedicated registration notice page when further action is required after registering

View File

@ -83,6 +83,8 @@ const registration = {
signedIn: (state) => !!state.users.currentUser, signedIn: (state) => !!state.users.currentUser,
isPending: (state) => state.users.signUpPending, isPending: (state) => state.users.signUpPending,
serverValidationErrors: (state) => state.users.signUpErrors, serverValidationErrors: (state) => state.users.signUpErrors,
signUpNotice: (state) => state.users.signUpNotice,
hasSignUpNotice: (state) => !!state.users.signUpNotice.message,
termsOfService: (state) => state.instance.tos, termsOfService: (state) => state.instance.tos,
accountActivationRequired: (state) => state.instance.accountActivationRequired, accountActivationRequired: (state) => state.instance.accountActivationRequired,
accountApprovalRequired: (state) => state.instance.accountApprovalRequired, accountApprovalRequired: (state) => state.instance.accountApprovalRequired,
@ -107,8 +109,12 @@ const registration = {
if (!this.v$.$invalid) { if (!this.v$.$invalid) {
try { try {
await this.signUp(this.user) const status = await this.signUp(this.user)
this.$router.push({ name: 'friends' }) if (status === 'ok') {
this.$router.push({ name: 'friends' })
}
// If status is not 'ok' (i.e. it needs further actions to be done
// before you can login), display sign up notice, do not switch anywhere
} catch (error) { } catch (error) {
console.warn('Registration failed: ', error) console.warn('Registration failed: ', error)
this.setCaptcha() this.setCaptcha()

View File

@ -3,7 +3,10 @@
<div class="panel-heading"> <div class="panel-heading">
{{ $t('registration.registration') }} {{ $t('registration.registration') }}
</div> </div>
<div class="panel-body"> <div
v-if="!hasSignUpNotice"
class="panel-body"
>
<form <form
class="registration-form" class="registration-form"
@submit.prevent="submit(user)" @submit.prevent="submit(user)"
@ -307,6 +310,11 @@
</div> </div>
</form> </form>
</div> </div>
<div v-else>
<p class="registration-notice">
{{ signUpNotice.message }}
</p>
</div>
</div> </div>
</template> </template>
@ -404,6 +412,10 @@ $validations-cRed: #f04124;
} }
} }
.registration-notice {
margin: 0.6em;
}
@media all and (max-width: 800px) { @media all and (max-width: 800px) {
.registration-form .container { .registration-form .container {
flex-direction: column-reverse; flex-direction: column-reverse;

View File

@ -80,6 +80,9 @@ const UserProfile = {
followersTabVisible () { followersTabVisible () {
return this.isUs || !this.user.hide_followers return this.isUs || !this.user.hide_followers
}, },
favoritesTabVisible () {
return this.isUs || !this.user.hide_favorites
},
formattedBirthday () { formattedBirthday () {
const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale) const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale)
return this.user.birthday && new Date(Date.parse(this.user.birthday)).toLocaleDateString(browserLocale, { timeZone: 'UTC', day: 'numeric', month: 'long', year: 'numeric' }) return this.user.birthday && new Date(Date.parse(this.user.birthday)).toLocaleDateString(browserLocale, { timeZone: 'UTC', day: 'numeric', month: 'long', year: 'numeric' })
@ -103,6 +106,8 @@ const UserProfile = {
startFetchingTimeline('user', userId) startFetchingTimeline('user', userId)
startFetchingTimeline('media', userId) startFetchingTimeline('media', userId)
if (this.isUs) { if (this.isUs) {
startFetchingTimeline('favorites')
} else if (!this.user.hide_favorites) {
startFetchingTimeline('favorites', userId) startFetchingTimeline('favorites', userId)
} }
// Fetch all pinned statuses immediately // Fetch all pinned statuses immediately

View File

@ -109,7 +109,7 @@
:footer-slipgate="footerRef" :footer-slipgate="footerRef"
/> />
<Timeline <Timeline
v-if="isUs" v-if="favoritesTabVisible"
key="favorites" key="favorites"
:label="$t('user_card.favorites')" :label="$t('user_card.favorites')"
:disabled="!favorites.visibleStatuses.length" :disabled="!favorites.visibleStatuses.length"
@ -117,6 +117,7 @@
:title="$t('user_card.favorites')" :title="$t('user_card.favorites')"
timeline-name="favorites" timeline-name="favorites"
:timeline="favorites" :timeline="favorites"
:user-id="userId"
:in-profile="true" :in-profile="true"
:footer-slipgate="footerRef" :footer-slipgate="footerRef"
/> />

View File

@ -943,7 +943,7 @@
"sandbox": "强制帖子为只有关注者可看", "sandbox": "强制帖子为只有关注者可看",
"disable_remote_subscription": "禁止从远程实例关注用户", "disable_remote_subscription": "禁止从远程实例关注用户",
"disable_any_subscription": "完全禁止关注用户", "disable_any_subscription": "完全禁止关注用户",
"quarantine": "从联合实例中禁止用户帖子", "quarantine": "不许帖子传入别站",
"delete_user": "删除用户", "delete_user": "删除用户",
"delete_user_data_and_deactivate_confirmation": "这将永久删除该账户的数据并停用该账户。你完全确定吗?" "delete_user_data_and_deactivate_confirmation": "这将永久删除该账户的数据并停用该账户。你完全确定吗?"
}, },

View File

@ -250,6 +250,7 @@ export const mutations = {
signUpPending (state) { signUpPending (state) {
state.signUpPending = true state.signUpPending = true
state.signUpErrors = [] state.signUpErrors = []
state.signUpNotice = {}
}, },
signUpSuccess (state) { signUpSuccess (state) {
state.signUpPending = false state.signUpPending = false
@ -257,6 +258,12 @@ export const mutations = {
signUpFailure (state, errors) { signUpFailure (state, errors) {
state.signUpPending = false state.signUpPending = false
state.signUpErrors = errors state.signUpErrors = errors
state.signUpNotice = {}
},
signUpNotice (state, notice) {
state.signUpPending = false
state.signUpErrors = []
state.signUpNotice = notice
} }
} }
@ -287,6 +294,7 @@ export const defaultState = {
usersByNameObject: {}, usersByNameObject: {},
signUpPending: false, signUpPending: false,
signUpErrors: [], signUpErrors: [],
signUpNotice: {},
relationships: {} relationships: {}
} }
@ -524,9 +532,16 @@ const users = {
const data = await rootState.api.backendInteractor.register( const data = await rootState.api.backendInteractor.register(
{ params: { ...userInfo } } { params: { ...userInfo } }
) )
store.commit('signUpSuccess')
store.commit('setToken', data.access_token) if (data.access_token) {
store.dispatch('loginUser', data.access_token) store.commit('signUpSuccess')
store.commit('setToken', data.access_token)
store.dispatch('loginUser', data.access_token)
return 'ok'
} else { // Request succeeded, but user cannot login yet.
store.commit('signUpNotice', data)
return 'request_sent'
}
} catch (e) { } catch (e) {
const errors = e.message const errors = e.message
store.commit('signUpFailure', errors) store.commit('signUpFailure', errors)

View File

@ -109,6 +109,7 @@ const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements
const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}`
const PLEROMA_SCROBBLES_URL = id => `/api/v1/pleroma/accounts/${id}/scrobbles` const PLEROMA_SCROBBLES_URL = id => `/api/v1/pleroma/accounts/${id}/scrobbles`
const PLEROMA_STATUS_QUOTES_URL = id => `/api/v1/pleroma/statuses/${id}/quotes` const PLEROMA_STATUS_QUOTES_URL = id => `/api/v1/pleroma/statuses/${id}/quotes`
const PLEROMA_USER_FAVORITES_TIMELINE_URL = id => `/api/v1/pleroma/accounts/${id}/favourites`
const PLEROMA_ADMIN_CONFIG_URL = '/api/pleroma/admin/config' const PLEROMA_ADMIN_CONFIG_URL = '/api/pleroma/admin/config'
const PLEROMA_ADMIN_DESCRIPTIONS_URL = '/api/pleroma/admin/config/descriptions' const PLEROMA_ADMIN_DESCRIPTIONS_URL = '/api/pleroma/admin/config/descriptions'
@ -692,6 +693,7 @@ const fetchTimeline = ({
media: MASTODON_USER_TIMELINE_URL, media: MASTODON_USER_TIMELINE_URL,
list: MASTODON_LIST_TIMELINE_URL, list: MASTODON_LIST_TIMELINE_URL,
favorites: MASTODON_USER_FAVORITES_TIMELINE_URL, favorites: MASTODON_USER_FAVORITES_TIMELINE_URL,
publicFavorites: PLEROMA_USER_FAVORITES_TIMELINE_URL,
tag: MASTODON_TAG_TIMELINE_URL, tag: MASTODON_TAG_TIMELINE_URL,
bookmarks: MASTODON_BOOKMARK_TIMELINE_URL, bookmarks: MASTODON_BOOKMARK_TIMELINE_URL,
quotes: PLEROMA_STATUS_QUOTES_URL quotes: PLEROMA_STATUS_QUOTES_URL
@ -701,6 +703,10 @@ const fetchTimeline = ({
let url = timelineUrls[timeline] let url = timelineUrls[timeline]
if (timeline === 'favorites' && userId) {
url = timelineUrls.publicFavorites(userId)
}
if (timeline === 'user' || timeline === 'media') { if (timeline === 'user' || timeline === 'media') {
url = url(userId) url = url(userId)
} }

View File

@ -107,6 +107,7 @@ export const parseUser = (data) => {
output.allow_following_move = data.pleroma.allow_following_move output.allow_following_move = data.pleroma.allow_following_move
output.hide_favorites = data.pleroma.hide_favorites
output.hide_follows = data.pleroma.hide_follows output.hide_follows = data.pleroma.hide_follows
output.hide_followers = data.pleroma.hide_followers output.hide_followers = data.pleroma.hide_followers
output.hide_follows_count = data.pleroma.hide_follows_count output.hide_follows_count = data.pleroma.hide_follows_count