-
diff --git a/src/lib/components/Browse/Sections/SectionCarousel.svelte b/src/lib/components/Browse/Sections/SectionCarousel.svelte
index 212eb452..047fb50d 100644
--- a/src/lib/components/Browse/Sections/SectionCarousel.svelte
+++ b/src/lib/components/Browse/Sections/SectionCarousel.svelte
@@ -3,7 +3,9 @@
import IconDrawerChevron from '$lib/assets/icons/drawer/IconDrawerChevron.svelte'
import LoadingItemCarousel from '$lib/components/Browse/Sections/LoadingItemCarousel.svelte'
import { onMount } from 'svelte'
- import Swiper, { Navigation } from 'swiper'
+ import Swiper from 'swiper'
+ import { Navigation } from 'swiper/modules'
+
import ItemCarousel from '$lib/components/Browse/Sections/ItemCarousel.svelte'
import 'swiper/css'
@@ -60,7 +62,8 @@
{:then value}
{#if value?.length > 0}
-
+
@@ -70,7 +73,8 @@
{/each}
-
diff --git a/src/lib/components/Channel/Chat/ChatInput.svelte b/src/lib/components/Channel/Chat/ChatInput.svelte
index 127f654f..9545e01e 100644
--- a/src/lib/components/Channel/Chat/ChatInput.svelte
+++ b/src/lib/components/Channel/Chat/ChatInput.svelte
@@ -8,8 +8,9 @@
import EmojiPicker from '$lib/components/Channel/Chat/EmojiPicker.svelte'
import GifPicker from '$lib/components/Channel/Chat/GifPicker.svelte'
- export let channel: any
- export let users: any
+ export let channel: any,
+ viewers: any[] = []
+
let selectedCommand = 0
let selectedUser = 0
let inputBox: any = null
@@ -19,14 +20,18 @@
$channel_connection === `open-${channel._id}` && $page.data.user?.userId
$: isHost = channel.user === $page.data.user?.userId
+ $: viewersWithOutHost = viewers.filter((viewer) => viewer.userId !== channel.user)
+
function insert(str: string, index: number, value: string) {
return str.substr(0, index) + value + str.substr(index)
}
const sendMessage = () => {
- if (messageIsCommand) {
- if (selectedCommand && selectedUser >= 0) {
- const user = users[selectedUser]
+ if (messageIsCommand && !chatMessage.startsWith('/ai ')) {
+ if (selectedCommand) {
+ const usernameFromMsg = chatMessage.substring(chatMessage.indexOf('@') + 1)
+ const user = viewersWithOutHost.find((viewer: any) => viewer.username === usernameFromMsg)
+ if (!user) return
executeCommand(selectedCommand, user.userId)
}
} else if (!chatMessage.startsWith('/') || chatMessage.startsWith('/ai')) {
@@ -55,15 +60,15 @@
}
const slectCommandfromKey = (key: string) => {
- if (key === 'ArrowDown' && selectedCommand < 3) {
+ if (key === 'ArrowDown' && selectedCommand < 4) {
selectedCommand++
- } else if (key === 'ArrowUp' && selectedCommand >= 1) {
+ } else if (key === 'ArrowUp' && selectedCommand >= 2) {
selectedCommand--
}
}
const slectUserfromKey = (key: string) => {
- if (key === 'ArrowDown' && selectedUser < users.length) {
+ if (key === 'ArrowDown' && selectedUser < viewers.length) {
selectedUser++
} else if (key === 'ArrowUp' && selectedUser >= 0) {
selectedUser--
@@ -109,6 +114,7 @@
// toggle commands handlers
const toggleBan = (userId: string) => {
+ if (channel.user === userId) return
let isEnabled = false
if (!channel.bans.includes(userId)) {
channel.bans.push(userId)
@@ -126,6 +132,7 @@
}
const toggleMod = (userId: string) => {
+ if (channel.user === userId) return
if (!channel.bans.includes(userId)) {
let isEnabled = false
if (!channel.mods?.includes(userId)) {
@@ -143,6 +150,7 @@
}
const toggleGuest = (userId: string) => {
+ if (channel.user === userId) return
if (!channel.bans.includes(userId)) {
let isEnabled = false
if (!channel.guests.includes(userId) && channel.guests.length < 9) {
@@ -187,16 +195,14 @@
]
$: messageIsCommand =
- chatMessage &&
- chatMessage.startsWith('/') &&
- /[a-z] @[a-z]/.test(chatMessage.substr(1)) &&
- chatMessage.startsWith('/ai ')
+ chatMessage && chatMessage.startsWith('/') && /[a-z] @[a-z]/.test(chatMessage.substr(1))
$: showUsers = chatMessage && chatMessage.endsWith('@')
$: showCommandOptions =
chatMessage &&
chatMessage.startsWith('/') &&
!chatMessage.startsWith('/ai ') &&
+ !chatMessage.includes('@') &&
(channel.user === $page.data.user?.userId || channel.mods?.includes($page.data.user?.userId)) &&
!showUsers
@@ -253,12 +259,12 @@
{/if}
- {#if users.length > 0 && showUsers}
+ {#if viewersWithOutHost.length > 0 && showUsers}
- {#each users as user, idx}
+ {#each viewersWithOutHost as user, idx}
- {
@@ -293,8 +299,8 @@
e.preventDefault()
if (showUsers) {
if (selectedUser >= 0) {
- const user = users[selectedUser]
- chatMessage = chatMessage.replace(/@/, '@' + user.username) + ' '
+ const user = viewers[selectedUser]
+ chatMessage = chatMessage.replace(/@/, '@' + user.username)
}
} else {
if (selectedCommand) {
diff --git a/src/lib/components/Channel/Chat/DrawerChat.svelte b/src/lib/components/Channel/Chat/DrawerChat.svelte
index 725c6887..bccbe630 100644
--- a/src/lib/components/Channel/Chat/DrawerChat.svelte
+++ b/src/lib/components/Channel/Chat/DrawerChat.svelte
@@ -11,10 +11,11 @@
import LastItemInViewport from '$lib/actions/LastItemInViewport'
export let channel: any = undefined,
- showEditChannelDrawer: boolean = false
+ showEditChannelDrawer: boolean = false,
+ viewers: any[] = []
let chatHistory: any[] = [],
chatDrawerElement: HTMLElement
- let cursor = "";
+ let cursor = ''
channel_message.subscribe((value) => {
if (!value) return
@@ -30,7 +31,7 @@
channel,
currentUserId: $page.data.user?.userId
})
- return message;
+ return message
})
chatHistory = [...chatHistory, ...messages]
@@ -68,14 +69,6 @@
$is_chat_drawer_open = false
})
- const createuserList = (list: any[]) => {
- let users: any = {}
- list.forEach((chat) => {
- if ($page.data.user?.userId !== chat.user.userId) users[chat.user.userId] = chat.user
- })
- return Object.keys(users).map((key) => users[key])
- }
-
const loadMore = () => {
if (
$channel_connection === `open-${channel._id}` &&
@@ -85,12 +78,10 @@
channelSocket: channel.socket,
channelId: channel._id,
skip: 100,
- cursor: cursor || "none"
+ cursor: cursor || 'none'
})
}
}
-
- $: users = createuserList(chatHistory)
@@ -102,6 +93,6 @@
-
+
diff --git a/src/lib/components/Channel/Chat/DropdownViewChannel.svelte b/src/lib/components/Channel/Chat/DropdownViewChannel.svelte
index 71ab6c2e..05b8719f 100644
--- a/src/lib/components/Channel/Chat/DropdownViewChannel.svelte
+++ b/src/lib/components/Channel/Chat/DropdownViewChannel.svelte
@@ -119,7 +119,7 @@
-
diff --git a/src/lib/components/Channel/Chat/FloatingMenu.svelte b/src/lib/components/Channel/Chat/FloatingMenu.svelte
index 0aa20bc6..a07a2d98 100644
--- a/src/lib/components/Channel/Chat/FloatingMenu.svelte
+++ b/src/lib/components/Channel/Chat/FloatingMenu.svelte
@@ -1,5 +1,5 @@
-