Display profile background of other users #371

Merged
floatingghost merged 1 commit from Oneric/akkoma-fe:profile-backgrounds into develop 2024-02-20 16:20:15 +00:00
6 changed files with 28 additions and 2 deletions

View file

@ -64,6 +64,11 @@ export default {
'-' + this.layoutType '-' + this.layoutType
] ]
}, },
pageBackground () {
return this.mergedConfig.displayPageBackgrounds
? this.$store.state.users.displayBackground
: null
},
currentUser () { return this.$store.state.users.currentUser }, currentUser () { return this.$store.state.users.currentUser },
userBackground () { return this.currentUser.background_image }, userBackground () { return this.currentUser.background_image },
instanceBackground () { instanceBackground () {
@ -71,7 +76,7 @@ export default {
? null ? null
: this.$store.state.instance.background : this.$store.state.instance.background
}, },
background () { return this.userBackground || this.instanceBackground }, background () { return this.pageBackground || this.userBackground || this.instanceBackground },
bgStyle () { bgStyle () {
if (this.background) { if (this.background) {
return { return {

View file

@ -146,6 +146,11 @@
{{ $t('settings.show_wider_shortcuts') }} {{ $t('settings.show_wider_shortcuts') }}
</BooleanSetting> </BooleanSetting>
</li> </li>
<li>
<BooleanSetting path="displayPageBackgrounds">
{{ $t('settings.show_page_backgrounds') }}
</BooleanSetting>
</li>
<li> <li>
<BooleanSetting path="stopGifs"> <BooleanSetting path="stopGifs">
{{ $t('settings.stop_gifs') }} {{ $t('settings.stop_gifs') }}

View file

@ -145,10 +145,12 @@ const UserProfile = {
if (user) { if (user) {
loadById(user.id) loadById(user.id)
this.note = user.relationship.note this.note = user.relationship.note
this.$store.dispatch('setDisplayBackground', user.background_image)
} else { } else {
this.$store.dispatch('fetchUser', userNameOrId) this.$store.dispatch('fetchUser', userNameOrId)
.then(({ id, relationship }) => { .then(({ id, relationship, background_image }) => {
this.note = relationship.note this.note = relationship.note
this.$store.dispatch('setDisplayBackground', background_image)
return loadById(id) return loadById(id)
}) })
.catch((reason) => { .catch((reason) => {
@ -225,6 +227,9 @@ const UserProfile = {
Conversation, Conversation,
RichContent, RichContent,
FollowedTagList FollowedTagList
},
beforeRouteLeave(to, from) {
this.$store.dispatch('setDisplayBackground', null)
} }
} }

View file

@ -750,6 +750,7 @@
"show_nav_shortcuts": "Show extra navigation shortcuts in top panel", "show_nav_shortcuts": "Show extra navigation shortcuts in top panel",
"show_panel_nav_shortcuts": "Show timeline navigation shortcuts at the top of the panel", "show_panel_nav_shortcuts": "Show timeline navigation shortcuts at the top of the panel",
"show_scrollbars": "Show side column's scrollbars", "show_scrollbars": "Show side column's scrollbars",
"show_page_backgrounds": "Show page-specific backgrounds, e.g. for user profiles",
"show_wider_shortcuts": "Show wider gap between top panel shortcuts", "show_wider_shortcuts": "Show wider gap between top panel shortcuts",
"show_yous": "Show (You)s", "show_yous": "Show (You)s",
"stop_gifs": "Pause animated images until you hover on them", "stop_gifs": "Pause animated images until you hover on them",

View file

@ -55,6 +55,7 @@ export const defaultState = {
alwaysShowNewPostButton: false, alwaysShowNewPostButton: false,
autohideFloatingPostButton: false, autohideFloatingPostButton: false,
pauseOnUnfocused: true, pauseOnUnfocused: true,
displayPageBackgrounds: true,
stopGifs: undefined, stopGifs: undefined,
replyVisibility: 'all', replyVisibility: 'all',
thirdColumnMode: 'notifications', thirdColumnMode: 'notifications',

View file

@ -135,6 +135,10 @@ export const mutations = {
const user = state.usersObject[id] const user = state.usersObject[id]
user['deactivated'] = deactivated user['deactivated'] = deactivated
}, },
setDisplayBackground(state, url) {
console.log("Commiting user profile bg mutation")
state.displayBackground = url
},
setCurrentUser (state, user) { setCurrentUser (state, user) {
state.lastLoginName = user.screen_name state.lastLoginName = user.screen_name
state.currentUser = mergeWith(state.currentUser || {}, user, mergeArrayLength) state.currentUser = mergeWith(state.currentUser || {}, user, mergeArrayLength)
@ -307,6 +311,7 @@ export const defaultState = {
currentUser: false, currentUser: false,
users: [], users: [],
usersObject: {}, usersObject: {},
displayBackground: null,
signUpPending: false, signUpPending: false,
signUpErrors: [], signUpErrors: [],
relationships: {}, relationships: {},
@ -319,6 +324,10 @@ const users = {
mutations, mutations,
getters, getters,
actions: { actions: {
setDisplayBackground (store, url) {
console.log("Performing user profile bg action...")
store.commit('setDisplayBackground', url)
},
fetchUserIfMissing (store, id) { fetchUserIfMissing (store, id) {
if (!store.getters.findUser(id)) { if (!store.getters.findUser(id)) {
store.dispatch('fetchUser', id) store.dispatch('fetchUser', id)