mirror of
https://github.com/docmost/docmost.git
synced 2026-10-05 02:23:48 +10:00
pass userId and avatar to awareness
This commit is contained in:
@@ -471,7 +471,9 @@ export const collabExtensions: CollabExtensions = (provider, user) => [
|
||||
CollaborationCaret.configure({
|
||||
provider,
|
||||
user: {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
avatarUrl: user.avatarUrl,
|
||||
color: randomElement(userColors),
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -224,7 +224,12 @@ export class PersistenceExtension implements Extension {
|
||||
}
|
||||
|
||||
// Drop malformed awareness before it is broadcast
|
||||
async beforeHandleAwareness({ states }: beforeHandleAwarenessPayload) {
|
||||
async beforeHandleAwareness({
|
||||
states,
|
||||
context,
|
||||
}: beforeHandleAwarenessPayload) {
|
||||
const user = context?.user;
|
||||
|
||||
for (const [clientId, state] of states) {
|
||||
if (!isRenderableObject(state)) {
|
||||
states.delete(clientId);
|
||||
@@ -235,6 +240,11 @@ export class PersistenceExtension implements Extension {
|
||||
delete state.user;
|
||||
}
|
||||
|
||||
if (state.user && user) {
|
||||
state.user.id = user.id;
|
||||
state.user.avatarUrl = user.avatarUrl ?? null;
|
||||
}
|
||||
|
||||
if (
|
||||
'cursor' in state &&
|
||||
state.cursor !== null &&
|
||||
|
||||
Reference in New Issue
Block a user