Skip to content

Commit

Permalink
fix(liveshare): update color for other members
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed May 9, 2023
1 parent 66359ab commit 088de58
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div
v-if="presence.length > 0"
:style="[
LIVESHARE.lastUpdatedColor
? { border: `1px solid ${LIVESHARE.lastUpdatedColor}` }
LIVESHARE.activeColor
? { border: `1px solid ${LIVESHARE.activeColor}` }
: {},
]"
class="flex px-2 cursor-pointer items-center gap-2"
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/store/liveshare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const useLiveshareStore = defineStore('liveshare', {
presenceLimit: 5,
user: undefined,
roomKey: undefined,
lastUpdatedColor: undefined,
yourColor: undefined,
activeColor: undefined,
}
},
actions: {
Expand Down
14 changes: 8 additions & 6 deletions packages/plugin-multiplayer/src/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const RoomSet = (
stores.PDF.$state = ctx.object.pdf
stores.DOCX.$state = ctx.object.docx

stores.LIVESHARE.lastUpdatedColor = ctx.liveshare.lastUpdatedColor
stores.LIVESHARE.activeColor = ctx.liveshare.yourColor

emitter.emit('plugin-theme-set')
}
Expand Down Expand Up @@ -102,7 +102,7 @@ export const RoomSet = (
if (leftPresences.some((presence) => getOwner(presence))) {
await removePresence(channel)

if (type === 'visit') {
if (type !== 'owner') {
hooks.local.deleteProject()
stores.CONTEXT.$reset()
stores.PROJECT.$reset()
Expand All @@ -123,8 +123,6 @@ export const RoomSet = (
stores.LIVESHARE.presence = state
})
.on('broadcast', { event: 'ctx' }, ({ payload }) => {
if (type === 'owner') return

setCTX(payload)
})
.subscribe(async (status) => {
Expand All @@ -144,7 +142,6 @@ export const RoomSet = (
}

const tracked = await channel.track(user)
stores.LIVESHARE.user = { presence_ref: '', ...user }

if (tracked !== 'ok') {
await removePresence(channel)
Expand All @@ -154,11 +151,14 @@ export const RoomSet = (
return
}

stores.LIVESHARE.user = { presence_ref: '', ...user }
stores.LIVESHARE.yourColor = hexColor

const target = getCTX()

if (type === 'owner') {
channel.send(target)
stores.LIVESHARE.lastUpdatedColor = hexColor
stores.LIVESHARE.activeColor = hexColor
} else {
setCTX(target.payload)
}
Expand Down Expand Up @@ -226,6 +226,8 @@ export const RoomSet = (
stores.LIVESHARE.$reset()
stores.ABSOLUTE.modal.presence.info = false
stores.ABSOLUTE.modal.presence.createOrJoin = false

hooks.toast.warning(hooks.i18n.t('toast.generics.successRemoved'))
},
() => {},
])
Expand Down
3 changes: 2 additions & 1 deletion packages/types/src/liveshare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export interface LiveshareState {
user?: LivesharePresenceUser
roomKey?: string
presenceLimit: number
lastUpdatedColor?: string
yourColor?: string
activeColor?: string
}

0 comments on commit 088de58

Please sign in to comment.