diff options
-rw-r--r-- | lib/Service/SessionService.php | 3 | ||||
-rw-r--r-- | src/components/EditorWrapper.vue | 7 | ||||
-rw-r--r-- | src/extensions/UserColor.js | 5 | ||||
-rw-r--r-- | tests/psalm-baseline.xml | 9 |
4 files changed, 19 insertions, 5 deletions
diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php index cb673335f..516045d20 100644 --- a/lib/Service/SessionService.php +++ b/lib/Service/SessionService.php @@ -222,6 +222,9 @@ class SessionService { } $session = $this->sessionMapper->find($documentId, $sessionId, $sessionToken); $session->setGuestName($guestName); + $color = $this->avatarManager->getGuestAvatar($guestName)->avatarBackgroundColor($guestName); + $color = sprintf("#%02x%02x%02x", $color->r, $color->g, $color->b); + $session->setColor($color); return $this->sessionMapper->update($session); } } diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index 6b5e65a3b..50331592a 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -302,7 +302,6 @@ export default { this.syncError = null this.tiptap.setOptions({ editable: !this.readOnly }) - }) .on('loaded', ({ documentSource }) => { this.hasConnectionIssue = false @@ -483,6 +482,12 @@ export default { updateSessions(sessions) { this.sessions = sessions.sort((a, b) => b.lastContact - a.lastContact) + + // Make sure we get our own session updated + // This should ideally be part of a global store where we can have that updated on the actual name change for guests + const currentUpdatedSession = this.sessions.find(session => session.id === this.currentSession.id) + Vue.set(this, 'currentSession', currentUpdatedSession) + const currentSessionIds = this.sessions.map((session) => session.userId) const currentGuestIds = this.sessions.map((session) => session.guestId) diff --git a/src/extensions/UserColor.js b/src/extensions/UserColor.js index 2dd786b18..d359b3443 100644 --- a/src/extensions/UserColor.js +++ b/src/extensions/UserColor.js @@ -73,10 +73,11 @@ export default class UserColor extends Extension { .filter(span => typeof tState.commits[span.commit]?.author?.color !== 'undefined') .map(span => { const commit = tState.commits[span.commit] + const clientID = commit.author.clientID return Decoration.inline(span.from, span.to, { class: 'author-annotation', - style: 'background-color: ' + commit.author.color + 'ee;', - title: commit.author.name, + style: 'background-color: ' + this.spec.color(clientID) + 'ee;', + title: this.spec.name(clientID), }) }).filter(dec => dec !== null) return { tracked, deco: DecorationSet.create(state.doc, decos) } diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 4842df2bb..c73bc04a2 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -144,13 +144,18 @@ </UndefinedThisPropertyFetch> </file> <file src="lib/Service/SessionService.php"> - <UndefinedDocblockClass occurrences="4"> + <UndefinedDocblockClass occurrences="8"> <code>$color->b</code> + <code>$color->b</code> + <code>$color->g</code> <code>$color->g</code> <code>$color->r</code> + <code>$color->r</code> + <code>$this->avatarManager->getGuestAvatar($guestName)->avatarBackgroundColor($guestName)</code> <code>$this->avatarManager->getGuestAvatar($userName)->avatarBackgroundColor($userName)</code> </UndefinedDocblockClass> - <UndefinedMagicMethod occurrences="6"> + <UndefinedMagicMethod occurrences="7"> + <code>setColor</code> <code>setColor</code> <code>setDocumentId</code> <code>setGuestName</code> |