pl-fe: chats cleanup
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -101,6 +101,7 @@ const ChatMessage = (props: IChatMessage) => {
|
|||||||
navigator.clipboard.writeText(text);
|
navigator.clipboard.writeText(text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setBubbleRef = (c: HTMLDivElement) => {
|
const setBubbleRef = (c: HTMLDivElement) => {
|
||||||
if (!c) return;
|
if (!c) return;
|
||||||
const links = c.querySelectorAll('a[rel="ugc"]');
|
const links = c.querySelectorAll('a[rel="ugc"]');
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Link, useNavigate } from '@tanstack/react-router';
|
|||||||
import React, { useRef } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
|
import Account from '@/components/account';
|
||||||
import DropdownMenu, { type Menu } from '@/components/dropdown-menu';
|
import DropdownMenu, { type Menu } from '@/components/dropdown-menu';
|
||||||
import Avatar from '@/components/ui/avatar';
|
import Avatar from '@/components/ui/avatar';
|
||||||
import HStack from '@/components/ui/hstack';
|
import HStack from '@/components/ui/hstack';
|
||||||
@ -129,15 +130,7 @@ const ChatsPageChat = () => {
|
|||||||
|
|
||||||
<DropdownMenu
|
<DropdownMenu
|
||||||
src={require('@phosphor-icons/core/regular/info.svg')}
|
src={require('@phosphor-icons/core/regular/info.svg')}
|
||||||
component={() => (
|
component={() => <div className='px-4 py-2'><Account account={chat.account} disabled hideActions /></div>}
|
||||||
<HStack className='px-4 py-2' alignItems='center' space={3}>
|
|
||||||
<Avatar src={chat.account.avatar} staticSrc={chat.account.avatar_static} alt={chat.account.avatar_description} size={50} isCat={chat.account.is_cat} username={chat.account.username} />
|
|
||||||
<Stack>
|
|
||||||
<Text weight='semibold'>{chat.account.display_name}</Text>
|
|
||||||
<Text size='sm' theme='primary'>@{chat.account.acct}</Text>
|
|
||||||
</Stack>
|
|
||||||
</HStack>
|
|
||||||
)}
|
|
||||||
items={menuItems}
|
items={menuItems}
|
||||||
/>
|
/>
|
||||||
</HStack>
|
</HStack>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { InfiniteData, keepPreviousData, useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
|
import { InfiniteData, keepPreviousData, useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
|
||||||
import sumBy from 'lodash/sumBy';
|
import sumBy from 'lodash/sumBy';
|
||||||
import { type Chat, type ChatMessage as BaseChatMessage, type PaginatedResponse, chatMessageSchema } from 'pl-api';
|
import { type Chat, type ChatMessage as BaseChatMessage, type PaginatedResponse, chatMessageSchema } from 'pl-api';
|
||||||
|
import { useCallback, useMemo } from 'react';
|
||||||
import * as v from 'valibot';
|
import * as v from 'valibot';
|
||||||
|
|
||||||
import { importEntities } from '@/actions/importer';
|
import { importEntities } from '@/actions/importer';
|
||||||
@ -211,8 +212,7 @@ const useChatActions = (chatId: string) => {
|
|||||||
reOrderChatListItems();
|
reOrderChatListItems();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const deleteChatMessage = (chatMessageId: string) =>
|
const deleteChatMessage = useCallback((chatMessageId: string) => client.chats.deleteChatMessage(chatId, chatMessageId), [chatId]);
|
||||||
client.chats.deleteChatMessage(chatId, chatMessageId);
|
|
||||||
|
|
||||||
const deleteChat = useMutation({
|
const deleteChat = useMutation({
|
||||||
mutationFn: () => client.chats.deleteChat(chatId),
|
mutationFn: () => client.chats.deleteChat(chatId),
|
||||||
@ -223,12 +223,12 @@ const useChatActions = (chatId: string) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return useMemo(() => ({
|
||||||
createChatMessage,
|
createChatMessage,
|
||||||
deleteChat,
|
deleteChat,
|
||||||
deleteChatMessage,
|
deleteChatMessage,
|
||||||
markChatAsRead,
|
markChatAsRead,
|
||||||
};
|
}), [createChatMessage, deleteChat, deleteChatMessage, markChatAsRead]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { ChatKeys, useChat, useChatActions, useChats, useChatMessages };
|
export { ChatKeys, useChat, useChatActions, useChats, useChatMessages };
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
height: 4rem;
|
height: 4rem;
|
||||||
|
min-height: 4rem;
|
||||||
border-top-left-radius: 0.75rem;
|
border-top-left-radius: 0.75rem;
|
||||||
border-top-right-radius: 0.75rem;
|
border-top-right-radius: 0.75rem;
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.75rem 1rem;
|
||||||
@ -43,6 +44,12 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
p {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title div:first-child,
|
&__title div:first-child,
|
||||||
|
|||||||
Reference in New Issue
Block a user