Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @baseapp-frontend/components

## 0.0.48

### Patch Changes

- Chatroom search fixed

## 0.0.47

### Patch Changes
Expand Down
20 changes: 17 additions & 3 deletions packages/components/modules/messages/ChatRoomsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,27 @@ const ChatRoomsList: FC<ChatRoomsListProps> = ({

const isInUnreadTab = tab === CHAT_TAB_VALUES.unread
const isInArchivedTab = tab === CHAT_TAB_VALUES.archived
const searchValue = watch('search')

const handleSearchChange: ChangeEventHandler<HTMLInputElement> = (e) => {
const value = e.target.value || ''
startTransition(() => {
refetch({ q: value })
refetch({
q: value,
unreadMessages: isInUnreadTab,
archived: isInArchivedTab,
})
})
}

const handleSearchClear = () => {
startTransition(() => {
reset()
refetch({ q: '' })
refetch({
q: '',
unreadMessages: isInUnreadTab,
archived: isInArchivedTab,
})
})
}

Expand All @@ -60,6 +69,7 @@ const ChatRoomsList: FC<ChatRoomsListProps> = ({
startRefetchTransition(() => {
refetch(
{
q: searchValue,
unreadMessages: newTab === CHAT_TAB_VALUES.unread,
archived: newTab === CHAT_TAB_VALUES.archived,
},
Expand Down Expand Up @@ -119,7 +129,6 @@ const ChatRoomsList: FC<ChatRoomsListProps> = ({

const renderListContent = () => {
const emptyChatRoomsList = chatRooms.length === 0
const searchValue = watch('search')

if (!isPending && searchValue && emptyChatRoomsList) return <SearchNotFoundState />

Expand Down Expand Up @@ -156,6 +165,11 @@ const ChatRoomsList: FC<ChatRoomsListProps> = ({
}}
>
<Searchbar
key={
tab /* The handleSearchChange function depends on tab.
Searchbar calls useRef on the onChange function (to debounce),
hence it does not see the changes unless it is reloaded */
}
name="search"
control={control}
onChange={handleSearchChange}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@baseapp-frontend/components",
"description": "BaseApp components modules such as comments, notifications, messages, and more.",
"version": "0.0.47",
"version": "0.0.48",
"main": "./index.ts",
"types": "dist/index.d.ts",
"sideEffects": false,
Expand Down
Loading