diff --git a/src/routes/rooms/components/RoomHugins.svelte b/src/routes/rooms/components/RoomHugins.svelte index 12cc1f34..36f343e1 100644 --- a/src/routes/rooms/components/RoomHugins.svelte +++ b/src/routes/rooms/components/RoomHugins.svelte @@ -22,7 +22,7 @@ let asian = false let firstConnect = false let loading = false let voice_channel = [] - +const me = {address: $user.myAddress, name: $user.username } function sendPM() { // Add friend request here? } @@ -61,7 +61,7 @@ $ : if (thisSwarm && $rooms.activeHugins) { $: if (thisSwarm) { //Adds connected and known users to one array - knownUsers = removeDuplicates([...thisSwarm.connections.filter(a => notIncludes(a)), ...$rooms.activeHugins]) + knownUsers = removeDuplicates([...thisSwarm.connections.filter(a => notIncludes(a)), ...$rooms.activeHugins]).filter( a => a.address !== myAddress) updateOnline() } else { onlineUsers = [] @@ -71,6 +71,7 @@ const updateOnline = () => { //Updates the online status and checks known users onlineUsers = knownUsers.filter(a => thisSwarm.connections.map(b=>b.address).includes(a.address)) knownUsers = removeDuplicates([...onlineUsers.filter(a => notIncludes(a)), ...knownUsers]) + knownUsers.unshift(me) } @@ -108,7 +109,10 @@ const join_voice_channel = async (video = false, screen) => { function disconnect_from_active_voice() { window.api.exitVoiceChannel() } - + + const isOnline = (user) => { + return (thisSwarm && user.address === myAddress) || onlineUsers.some(a => a.address === user.address) + } @@ -148,8 +152,8 @@ const join_voice_channel = async (video = false, screen) => {
- {#if (thisSwarm && user.address === myAddress) || onlineUsers.some(a => a.address === user.address)} -
+ {#if isOnline(user)} +
{/if}