Skip to content

Commit 5e4127d

Browse files
committed
fix: search filter navigation in chatbox
1 parent 65fc64a commit 5e4127d

File tree

4 files changed

+10
-26
lines changed

4 files changed

+10
-26
lines changed

client/packages/lowcoder/src/comps/comps/chatBoxComponent/ChatBoxContext.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ type ChatEventName =
1414
| "startTyping"
1515
| "stopTyping"
1616
| "roomSwitch"
17-
| "roomJoin"
1817
| "roomLeave"
1918
| "roomCreate"
2019
| "inviteSend"
@@ -62,7 +61,6 @@ export interface ChatBoxContextValue {
6261

6362
// Room actions
6463
onRoomSwitch: (roomId: string) => void;
65-
onRoomJoin: (roomId: string) => void;
6664
onRoomLeave: (roomId: string) => void;
6765
onRoomCreate: (
6866
name: string,

client/packages/lowcoder/src/comps/comps/chatBoxComponent/chatBoxComp.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ const ChatEvents = [
5151
value: "roomSwitch",
5252
description: trans("chatBox.roomSwitchDesc"),
5353
},
54-
{
55-
label: trans("chatBox.roomJoin"),
56-
value: "roomJoin",
57-
description: trans("chatBox.roomJoinDesc"),
58-
},
5954
{
6055
label: trans("chatBox.roomLeave"),
6156
value: "roomLeave",
@@ -281,10 +276,6 @@ let ChatBoxTmp = (function () {
281276
props.pendingRoomId.onChange(roomId);
282277
props.onEvent("roomSwitch");
283278
},
284-
onRoomJoin: (roomId: string) => {
285-
props.pendingRoomId.onChange(roomId);
286-
props.onEvent("roomJoin");
287-
},
288279
onRoomLeave: (roomId: string) => {
289280
props.pendingRoomId.onChange(roomId);
290281
props.onEvent("roomLeave");

client/packages/lowcoder/src/comps/comps/chatBoxComponent/components/RoomPanel.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
RoomPanelHeader,
1818
RoomListContainer,
1919
RoomItemStyled,
20-
SearchResultBadge,
2120
LlmRoomBadge,
2221
OnlinePresenceSection,
2322
OnlinePresenceLabel,
@@ -48,7 +47,6 @@ export const RoomPanel = React.memo((props: RoomPanelProps) => {
4847
onlineUsers,
4948
sidebarStyle,
5049
onRoomSwitch,
51-
onRoomJoin,
5250
onRoomLeave,
5351
onInviteAccept,
5452
onInviteDecline,
@@ -81,7 +79,7 @@ export const RoomPanel = React.memo((props: RoomPanelProps) => {
8179
setIsSearchMode(true);
8280
const lower = q.toLowerCase();
8381
setSearchResults(
84-
rooms.filter((r) => r.type === "public" && r.name.toLowerCase().includes(lower)),
82+
rooms.filter((r) => r.name.toLowerCase().includes(lower)),
8583
);
8684
};
8785

@@ -91,11 +89,6 @@ export const RoomPanel = React.memo((props: RoomPanelProps) => {
9189
setSearchResults([]);
9290
};
9391

94-
const handleJoinAndClear = (roomId: string) => {
95-
onRoomJoin(roomId);
96-
clearSearch();
97-
};
98-
9992
const roomListItems = isSearchMode ? searchResults : rooms;
10093

10194
const publicRooms = roomListItems.filter((r) => r.type === "public");
@@ -112,13 +105,14 @@ export const RoomPanel = React.memo((props: RoomPanelProps) => {
112105
$active={isActive}
113106
$sidebarStyle={sidebarStyle}
114107
onClick={() => {
115-
if (isSearch) {
116-
handleJoinAndClear(room.id);
117-
} else if (!isActive) {
108+
if (!isActive) {
118109
onRoomSwitch(room.id);
119110
}
111+
if (isSearch) {
112+
clearSearch();
113+
}
120114
}}
121-
title={isSearch ? trans("chatBox.joinRoomTitle", { roomName: room.name }) : room.name}
115+
title={room.name}
122116
>
123117
{room.type === "llm" ? (
124118
<RobotOutlined
@@ -154,7 +148,6 @@ export const RoomPanel = React.memo((props: RoomPanelProps) => {
154148
{trans("chatBox.aiShortLabel")}
155149
</LlmRoomBadge>
156150
)}
157-
{isSearch && <SearchResultBadge>{trans("chatBox.joinAction")}</SearchResultBadge>}
158151
{isActive && !isSearch && (
159152
<Popconfirm
160153
title={trans("chatBox.leaveRoomConfirm", { roomName: room.name })}
@@ -209,7 +202,7 @@ export const RoomPanel = React.memo((props: RoomPanelProps) => {
209202
<div style={{ padding: "8px 8px 0" }}>
210203
<Input
211204
size="small"
212-
placeholder={trans("chatBox.searchPublicRoomsPlaceholder")}
205+
placeholder={trans("chatBox.searchPlaceholder")}
213206
prefix={<SearchOutlined style={{ color: "#aaa" }} />}
214207
value={searchQuery}
215208
onChange={(e) => handleSearch(e.target.value)}
@@ -228,7 +221,7 @@ export const RoomPanel = React.memo((props: RoomPanelProps) => {
228221
: "chatBox.searchResultsCountPlural",
229222
{ count: searchResults.length },
230223
)
231-
: trans("chatBox.noPublicRoomsMatch", { searchQuery })}
224+
: trans("chatBox.noRoomsMatch", { searchQuery })}
232225
<Button
233226
type="link"
234227
size="small"

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,9 +1652,11 @@ export const en = {
16521652
"inviteUserToRoomTooltip": "Invite user to room",
16531653
"createRoomTooltip": "Create room",
16541654
"searchPublicRoomsPlaceholder": "Search public rooms...",
1655+
"searchPlaceholder": "Search",
16551656
"searchResultsCountSingle": "{count} result",
16561657
"searchResultsCountPlural": "{count} results",
16571658
"noPublicRoomsMatch": "No public rooms match \"{searchQuery}\"",
1659+
"noRoomsMatch": "No rooms match \"{searchQuery}\"",
16581660
"backAction": "Back",
16591661
"pendingInvitesHeader": "Pending Invites ({count})",
16601662
"invitedBy": "Invited by {userName}",

0 commit comments

Comments
 (0)