Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/AvatarWrapper/AvatarWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
v-if="isSpecialAvatar"
:key="(isDarkTheme ? 'dark-' : 'light-') + '_' + id"
class="avatar"
:user="name + '_' + id"
:user="id"
:url="!isFederatedUser ? undefined : avatarUrl"
:icon-class="iconClass"
:display-name="name"
:disable-tooltip="disableTooltip"
disable-menu
is-no-user
:hide-status="!showUserStatus"
:verbose-status="false"
:preloaded-user-status="preloadedUserStatus ?? {}"
Expand Down
23 changes: 13 additions & 10 deletions src/components/SetGuestUsername.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,26 @@ const token = useGetToken()

const usernameInput = useTemplateRef('usernameInput')

const guestUserName = ref(getGuestNickname() || '')
const guestUserName = computed({
get: () => guestNameStore.guestUserName,
set: (newValue: string) => {
guestNameStore.guestUserName = newValue
debounceUpdateDisplayName()
emit('update', newValue)
},
})
const isEditingUsername = ref(false)

const actorDisplayName = computed<string>(() => actorStore.displayName || guestUserName.value)
const displayNameLabel = computed(() => t('spreed', 'Display name: {name}', {
name: `<strong>${escapeHtml(actorDisplayName.value)}</strong>`,
}, { escape: false }))
const debounceUpdateDisplayName = debounce(updateDisplayName, 500)
const debounceUpdateDisplayName = debounce(updateDisplayName, 10_000)

watch(actorDisplayName, (newValue) => {
guestUserName.value = newValue
if (newValue && newValue !== guestUserName.value) {
guestUserName.value = newValue
}
})

/** Initially set displayName in store, if available from BrowserStorage */
Expand All @@ -111,7 +120,7 @@ EventBus.once('joined-conversation', () => {
subscribe('user:info:changed', updateDisplayNameFromPublicEvent)
onBeforeUnmount(() => {
unsubscribe('user:info:changed', updateDisplayNameFromPublicEvent)
updateDisplayName()
debounceUpdateDisplayName.flush?.()
})

/**
Expand Down Expand Up @@ -144,12 +153,6 @@ function toggleEdit() {
})
}
}

// One-way binding to parent component
watch(guestUserName, (newValue) => {
debounceUpdateDisplayName()
emit('update', newValue)
}, { immediate: true })
</script>

<style lang="scss" scoped>
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useGetMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,12 @@ export function useGetMessagesProvider() {
try {
debugTimer.start(`${token} | long polling`)
// TODO: move polling logic to the store and also cancel timers on cancel
pollingErrorTimeout = 1_000
await store.dispatch('pollNewMessages', {
token,
lastKnownMessageId: chatStore.getLastKnownId(token),
requestId: token,
})
pollingErrorTimeout = 1_000
debugTimer.end(`${token} | long polling`, 'status 200')
tryChatRelay()
} catch (exception) {
Expand Down
1 change: 1 addition & 0 deletions src/stores/__tests__/guestName.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vi.mock('../../services/participantsService', () => ({
}))
vi.mock('@nextcloud/auth', () => ({
getCurrentUser: vi.fn(),
getGuestNickname: vi.fn(),
setGuestNickname: vi.fn(),
}))

Expand Down
7 changes: 4 additions & 3 deletions src/stores/guestName.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { setGuestNickname } from '@nextcloud/auth'
import { emit } from '@nextcloud/event-bus'
import { t } from '@nextcloud/l10n'
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { getGuestNickname, setGuestNickname } from '@nextcloud/auth'
import { t } from '@nextcloud/l10n'
import { defineStore } from 'pinia'
import { setGuestUserName } from '../services/participantsService.js'
import { useActorStore } from './actor.ts'

export const useGuestNameStore = defineStore('guestName', {
state: () => ({
guestNames: {},
guestUserName: getGuestNickname() || '',
}),

actions: {
Expand Down
Loading