Feat/init app DRAFT#1
Conversation
|
Issue link #9 |
…essage-panel added generic form and textarea field, create message panel component
added shadcn, adjusted theme, fixed gaps
Feat/add chat timiline
…hat, convert dates to ISO format
added sections to the right sidebar
src/components/ChatLayout/index.tsx
Outdated
| const params = useParams() | ||
| const setPageTitle = useSetPageTitle() | ||
|
|
||
| useEffect(() => { | ||
| setPageTitle(getPageTitleFromParams(params)) | ||
| }, [ | ||
| params.feedId, | ||
| params.chatId, | ||
| params.contactId, | ||
| params.folderId, | ||
| params.itemId, | ||
| ]) |
There was a problem hiding this comment.
would be nice to extract this into a separate hook, something like useSetPageTitleFromParams
| FormProps<FormValues> & | ||
| Omit< | ||
| DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, | ||
| 'onSubmit' |
There was a problem hiding this comment.
IMO we should be consistent and either omit all props we override 'onSubmit' | 'onReset' | 'noValidate' or let to override onSubmit as well
| const [isMobile, setIsMobile] = useState(false) | ||
|
|
||
| useEffect(() => { | ||
| setIsMobile(isMobilePlatform()) | ||
| }, []) |
There was a problem hiding this comment.
looks like using isMobile state here could be redundant.
useState vs simple regExp.test() could be an overkill.
|
|
||
| export function getFeedIconSrc(id: FeedIconId): string { | ||
| const src = srcById.get(id) | ||
| if (!src) throw new Error(`Unknown feed icon: ${id}`) |
There was a problem hiding this comment.
it could be an overreaction to crash the whole page because of a missing icon.
| const [messageList, setMessageList] = useState<Message[]>(messages) | ||
| const scrollContainerRef = useRef<HTMLDivElement>(null) | ||
|
|
||
| useEffect(() => { | ||
| setMessageList(messages) | ||
| }, [messages]) |
There was a problem hiding this comment.
if possible we should only use messages directly.
ATM we have two sources for messageList, it can change because parent component updated the messages or we called handleReactionClick.
is can lead to unpredictable behaviour.
most likely handling reactions logic should be moved to parent component or state management lib
src/components/ChatLayout/index.tsx
Outdated
| function getPageTitleFromParams( | ||
| params: Record<string, string | undefined> | ||
| ): PageTitleState { | ||
| const { feedId, chatId, contactId, folderId, itemId } = params as RouteParams |
There was a problem hiding this comment.
| function getPageTitleFromParams( | |
| params: Record<string, string | undefined> | |
| ): PageTitleState { | |
| const { feedId, chatId, contactId, folderId, itemId } = params as RouteParams | |
| function getPageTitleFromParams(params: RouteParams): PageTitleState { | |
| const { feedId, chatId, contactId, folderId, itemId } = params |
- ChatTimeline: use messages prop directly, optional onReactionClick - Chat route: own messages state; reaction click merges by emoji (increment count) - useSetPageTitleFromParams: type params as RouteParams, remove redundant assertion Made-with: Cursor
No description provided.