|
|
|
@ -5,6 +5,7 @@ import {
@@ -5,6 +5,7 @@ import {
|
|
|
|
|
ChatMemberRole, |
|
|
|
|
ChatType, |
|
|
|
|
createFullName, |
|
|
|
|
ErrorMessage, |
|
|
|
|
IChat, |
|
|
|
|
RouteKey, |
|
|
|
|
SocketEvents, |
|
|
|
@ -27,6 +28,7 @@ import { showUknowError } from '@/shared/helpers/alert.helper'
@@ -27,6 +28,7 @@ import { showUknowError } from '@/shared/helpers/alert.helper'
|
|
|
|
|
import { getChatIdFromMessages, isChatInList } from '../helpers' |
|
|
|
|
import { SkeletonDataKey } from '@/services/system' |
|
|
|
|
import { chatManager } from '@/managers' |
|
|
|
|
import { getErrorMessage } from '@/shared/helpers' |
|
|
|
|
|
|
|
|
|
export const useChatList = () => { |
|
|
|
|
const nav = useNav() |
|
|
|
@ -223,6 +225,14 @@ export const useChatList = () => {
@@ -223,6 +225,14 @@ export const useChatList = () => {
|
|
|
|
|
} else handleClearForMe(chatId, chat.unreadMessagesCount) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const showMaxFixedError = () => { |
|
|
|
|
appEvents.emit('openInfoModal', { |
|
|
|
|
title: 'Максимум закріпленних чатів ', |
|
|
|
|
message: 'можна закріпити лише 5 чатів', |
|
|
|
|
pressButtonText: 'Продовжити', |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onPin = async (chatId: number | string) => { |
|
|
|
|
try { |
|
|
|
|
const chatIndex = chats.findIndex(it => it.id === chatId) |
|
|
|
@ -230,11 +240,7 @@ export const useChatList = () => {
@@ -230,11 +240,7 @@ export const useChatList = () => {
|
|
|
|
|
const pinned = chats.filter(it => it.isChatFixed) |
|
|
|
|
|
|
|
|
|
if (pinned.length > 4) { |
|
|
|
|
appEvents.emit('openInfoModal', { |
|
|
|
|
title: 'Максимум закріпленних чатів ', |
|
|
|
|
message: 'можна закріпити лише 5 чатів', |
|
|
|
|
pressButtonText: 'Продовжити', |
|
|
|
|
}) |
|
|
|
|
showMaxFixedError() |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -255,7 +261,9 @@ export const useChatList = () => {
@@ -255,7 +261,9 @@ export const useChatList = () => {
|
|
|
|
|
|
|
|
|
|
// _setItems(newList)
|
|
|
|
|
} catch (e) { |
|
|
|
|
showUknowError() |
|
|
|
|
const message = getErrorMessage(e) |
|
|
|
|
if (message === ErrorMessage.MaxFixed) showMaxFixedError() |
|
|
|
|
else showUknowError() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -334,7 +342,7 @@ export const useChatList = () => {
@@ -334,7 +342,7 @@ export const useChatList = () => {
|
|
|
|
|
chats, |
|
|
|
|
chat => chat.id.toString() === data.chatId.toString(), |
|
|
|
|
) |
|
|
|
|
console.log(!chat || chat.isChatFixed) |
|
|
|
|
|
|
|
|
|
if (!chat || chat.isChatFixed) return |
|
|
|
|
resetFlatList() |
|
|
|
|
} |
|
|
|
|