Skip to content

Commit 4c5b781

Browse files
committed
feat: refresh users avatar in header when the user changes their icon in their profile
1 parent f46e31a commit 4c5b781

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/components/images/ImageUploader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default {
122122
}
123123
124124
// update loading status
125-
function updateImagesUploading(index, percent, url) {
125+
const updateImagesUploading = (index, percent, url) => {
126126
// on successful update
127127
if (percent) {
128128
// update images' progress sum

src/components/layout/Header.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ export default {
349349
breadcrumbs: [{label:'Home', state: '#', opts: {}}]
350350
})
351351
352+
watch(() => $auth.user, u => v.currentUser = u, { deep: true })
352353
watch(() => $route.path, p => v.hideAnnnouncement = v.motdData?.main_view_only && p !== '' && p !== '/')
353354
watch(() => NotificationsStore.messages, c => v.notificationMessages = c)
354355
watch(() => NotificationsStore.mentions, c => v.notificationMentions = c)

src/components/modals/profile/UpdateAvatar.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import Modal from '@/components/layout/Modal.vue'
3636
import { reactive, toRefs, inject } from 'vue'
3737
import { usersApi } from '@/api'
3838
import { cloneDeep } from 'lodash'
39+
import { AuthStore } from '@/composables/stores/auth'
3940
4041
export default {
4142
name: 'update-avatar-modal',
@@ -55,6 +56,7 @@ export default {
5556
v.userCopy.avatar = data.avatar
5657
$alertStore.success(`Successfully updated avatar for user ${params.username}`)
5758
Object.assign(v.userReactive, v.userCopy)
59+
$auth.reauthenticate()
5860
})
5961
.catch(() => v.errorMessage = 'There was an error updating avatar.')
6062
.finally(() => v.errorMessage ? null : close())
@@ -69,6 +71,7 @@ export default {
6971
const uploadError = err => v.errorMessage = err
7072
/* Internal Data */
7173
const $alertStore = inject('$alertStore')
74+
const $auth = inject(AuthStore)
7275
7376
/* Template Data */
7477
const v = reactive({

0 commit comments

Comments
 (0)