Skip to content
Open
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
76 changes: 38 additions & 38 deletions packages/api/src/EmbeddedChatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class EmbeddedChatApi {
constructor(
host: string,
rid: string,
{ getToken, saveToken, deleteToken }: IRocketChatAuthOptions
{ getToken, saveToken, deleteToken }: IRocketChatAuthOptions,
) {
this.host = host;
this.rid = rid;
Expand Down Expand Up @@ -73,7 +73,7 @@ export default class EmbeddedChatApi {
private async _restRequest(
endpoint: string,
method: "GET" | "POST" | "PUT" | "DELETE" = "GET",
body?: any
body?: any,
) {
const options: RequestInit = {};
if (body !== undefined) {
Expand Down Expand Up @@ -151,7 +151,7 @@ export default class EmbeddedChatApi {
if (!response.data.me.username) {
await this.updateUserUsername(
response.data.userId,
response.data.me.name
response.data.me.name,
);
}
return { status: response.status, me: response.data.me };
Expand Down Expand Up @@ -220,7 +220,7 @@ export default class EmbeddedChatApi {
} catch (error) {
console.error(
"Auto-login failed:",
error instanceof Error ? error.message : error
error instanceof Error ? error.message : error,
);
}
}
Expand Down Expand Up @@ -294,7 +294,7 @@ export default class EmbeddedChatApi {
if (message) {
this.onMessageCallbacks.forEach((callback) => callback(message));
}
}
},
);
this._activeSubscriptions.push(roomMsgSub);

Expand All @@ -312,7 +312,7 @@ export default class EmbeddedChatApi {
// Legacy "typing" event: args[1] is a boolean
this.handleTypingEvent({ typingUser, isTyping: !!activities });
}
}
},
);
this._activeSubscriptions.push(notifyRoomSub);

Expand All @@ -324,10 +324,10 @@ export default class EmbeddedChatApi {
const messageId = args[0]?._id;
if (messageId) {
this.onMessageDeleteCallbacks.forEach((callback) =>
callback(messageId)
callback(messageId),
);
}
}
},
);
this._activeSubscriptions.push(deleteRoomSub);

Expand All @@ -346,7 +346,7 @@ export default class EmbeddedChatApi {
message.renderType = "blocks";
this.onMessageCallbacks.forEach((callback) => callback(message));
}
}
},
);
this._activeSubscriptions.push(notifyUserMsgSub);

Expand All @@ -355,7 +355,7 @@ export default class EmbeddedChatApi {
[`${userId}/uiInteraction`, false],
(data: any) => {
this.onUiInteractionCallbacks.forEach((callback) => callback(data));
}
},
);
this._activeSubscriptions.push(notifyUserUiSub);
}
Expand All @@ -375,7 +375,7 @@ export default class EmbeddedChatApi {

async removeMessageListener(callback: (message: any) => void) {
this.onMessageCallbacks = this.onMessageCallbacks.filter(
(c) => c !== callback
(c) => c !== callback,
);
}

Expand All @@ -390,7 +390,7 @@ export default class EmbeddedChatApi {

async removeMessageDeleteListener(callback: (messageId: string) => void) {
this.onMessageDeleteCallbacks = this.onMessageDeleteCallbacks.filter(
(c) => c !== callback
(c) => c !== callback,
);
}

Expand All @@ -405,13 +405,13 @@ export default class EmbeddedChatApi {

async removeTypingStatusListener(callback: (users: string[]) => void) {
this.onTypingStatusCallbacks = this.onTypingStatusCallbacks.filter(
(c) => c !== callback
(c) => c !== callback,
);
}

async addActionTriggeredListener(callback: (data: any) => void) {
const idx = this.onActionTriggeredCallbacks.findIndex(
(c) => c === callback
(c) => c === callback,
);
if (idx !== -1) {
this.onActionTriggeredCallbacks[idx] = callback;
Expand All @@ -422,7 +422,7 @@ export default class EmbeddedChatApi {

async removeActionTriggeredListener(callback: (data: any) => void) {
this.onActionTriggeredCallbacks = this.onActionTriggeredCallbacks.filter(
(c) => c !== callback
(c) => c !== callback,
);
}

Expand All @@ -437,7 +437,7 @@ export default class EmbeddedChatApi {

async removeUiInteractionListener(callback: (data: any) => void) {
this.onUiInteractionCallbacks = this.onUiInteractionCallbacks.filter(
(c) => c !== callback
(c) => c !== callback,
);
}

Expand Down Expand Up @@ -466,14 +466,14 @@ export default class EmbeddedChatApi {
typingHandlerLock = 0;
const newTypingStatus = cloneArray(this.typingUsers);
this.onTypingStatusCallbacks.forEach((callback) =>
callback(newTypingStatus)
callback(newTypingStatus),
);
}

async getRCAppInfo() {
try {
const response = await fetch(
`${this.host}/api/apps/public/${ROCKETCHAT_APP_ID}/info`
`${this.host}/api/apps/public/${ROCKETCHAT_APP_ID}/info`,
);

if (!response.ok) {
Expand All @@ -489,7 +489,7 @@ export default class EmbeddedChatApi {
async updateUserNameThroughSuggestion(userid: string) {
try {
const suggestedUsername = await this._restRequest(
"/v1/users.getUsernameSuggestion"
"/v1/users.getUsernameSuggestion",
);
if (suggestedUsername.success) {
return await this._restRequest("/v1/users.update", "POST", {
Expand Down Expand Up @@ -564,7 +564,7 @@ export default class EmbeddedChatApi {
latest?: string;
count?: number;
} = {},
isChannelPrivate = false
isChannelPrivate = false,
) {
const roomType = isChannelPrivate ? "groups" : "channels";
const endp = anonymousMode ? "anonymousread" : "messages";
Expand All @@ -573,7 +573,7 @@ export default class EmbeddedChatApi {
const count = options?.count != null ? `&count=${options.count}` : "";
try {
return await this._restRequest(
`/v1/${roomType}.${endp}?roomId=${this.rid}${oldest}${latest}${count}`
`/v1/${roomType}.${endp}?roomId=${this.rid}${oldest}${latest}${count}`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : err);
Expand All @@ -589,7 +589,7 @@ export default class EmbeddedChatApi {
count?: number;
offset?: number;
} = {},
isChannelPrivate = false
isChannelPrivate = false,
) {
const roomType = isChannelPrivate ? "groups" : "channels";
const endp = anonymousMode ? "anonymousread" : "messages";
Expand All @@ -599,7 +599,7 @@ export default class EmbeddedChatApi {
const offset = options?.offset ? `&offset=${options.offset}` : "&offset=0";
try {
return await this._restRequest(
`/v1/${roomType}.${endp}?roomId=${this.rid}${oldest}${latest}${count}${offset}`
`/v1/${roomType}.${endp}?roomId=${this.rid}${oldest}${latest}${count}${offset}`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : String(err));
Expand All @@ -609,7 +609,7 @@ export default class EmbeddedChatApi {

async getThreadMessages(
tmid: string,
isChannelPrivate = false
isChannelPrivate = false,
): Promise<any> {
try {
return await this._restRequest(`/v1/chat.getThreadMessages?tmid=${tmid}`);
Expand All @@ -623,7 +623,7 @@ export default class EmbeddedChatApi {
const roomType = isChannelPrivate ? "groups" : "channels";
try {
return await this._restRequest(
`/v1/${roomType}.roles?roomId=${this.rid}`
`/v1/${roomType}.roles?roomId=${this.rid}`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : String(err));
Expand Down Expand Up @@ -659,7 +659,7 @@ export default class EmbeddedChatApi {
"stream-notify-room",
`${this.rid}/user-activity`,
username,
typing ? ["user-typing"] : []
typing ? ["user-typing"] : [],
);
} catch (err) {
// DDP typing indicator fails when connection is temporarily down — expected, safe to ignore
Expand Down Expand Up @@ -761,7 +761,7 @@ export default class EmbeddedChatApi {
async getStarredMessages(): Promise<any> {
try {
return await this._restRequest(
`/v1/chat.getStarredMessages?roomId=${this.rid}`
`/v1/chat.getStarredMessages?roomId=${this.rid}`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : err);
Expand All @@ -772,7 +772,7 @@ export default class EmbeddedChatApi {
async getPinnedMessages(): Promise<any> {
try {
return await this._restRequest(
`/v1/chat.getPinnedMessages?roomId=${this.rid}`
`/v1/chat.getPinnedMessages?roomId=${this.rid}`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : err);
Expand All @@ -783,7 +783,7 @@ export default class EmbeddedChatApi {
async getMentionedMessages(): Promise<any> {
try {
return await this._restRequest(
`/v1/chat.getMentionedMessages?roomId=${this.rid}`
`/v1/chat.getMentionedMessages?roomId=${this.rid}`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : err);
Expand Down Expand Up @@ -815,7 +815,7 @@ export default class EmbeddedChatApi {
async reactToMessage(
emoji: string,
messageId: string,
shouldReact: boolean | string
shouldReact: boolean | string,
): Promise<any> {
try {
return await this._restRequest("/v1/chat.react", "POST", {
Expand Down Expand Up @@ -861,7 +861,7 @@ export default class EmbeddedChatApi {
file: File,
fileName: string,
fileDescription = "",
threadId = undefined
threadId = undefined,
) {
try {
const currentUser = await this.auth.getCurrentUser();
Expand All @@ -875,7 +875,7 @@ export default class EmbeddedChatApi {

const uploadResult = await this._restUpload(
`/v1/rooms.media/${this.rid}`,
form
form,
);

if (!uploadResult.success || !uploadResult.file?._id) {
Expand All @@ -888,7 +888,7 @@ export default class EmbeddedChatApi {
"POST",
threadId
? { msg: "", description: fileDescription || "", tmid: threadId }
: { msg: "", description: fileDescription || "" }
: { msg: "", description: fileDescription || "" },
);
} catch (err) {
console.error("sendAttachment error:", err);
Expand All @@ -908,7 +908,7 @@ export default class EmbeddedChatApi {
const roomType = isChannelPrivate ? "groups" : "channels";
try {
return await this._restRequest(
`/v1/${roomType}.members?roomId=${this.rid}`
`/v1/${roomType}.members?roomId=${this.rid}&count=500`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : err);
Expand All @@ -920,8 +920,8 @@ export default class EmbeddedChatApi {
try {
return await this._restRequest(
`/v1/chat.search?roomId=${this.rid}&searchText=${encodeURIComponent(
text
)}`
text,
)}`,
);
} catch (err: any) {
console.error(err instanceof Error ? err.message : err);
Expand All @@ -944,7 +944,7 @@ export default class EmbeddedChatApi {
const interaction = await this._restRequest(
`/apps/ui.interaction/${appId}`,
"POST",
{ triggerId, ...userInteraction }
{ triggerId, ...userInteraction },
);
this.onActionTriggeredCallbacks.forEach((cb) => cb(interaction));
return interaction;
Expand Down Expand Up @@ -985,7 +985,7 @@ export default class EmbeddedChatApi {

async userData(username: string): Promise<any> {
return await this._restRequest(
`/v1/users.info?username=${encodeURIComponent(username)}`
`/v1/users.info?username=${encodeURIComponent(username)}`,
);
}
}
9 changes: 6 additions & 3 deletions packages/react/src/views/RoomMembers/RoomMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { css } from '@emotion/react';
import RoomMemberItem from './RoomMemberItem';
import RCContext, { useRCContext } from '../../context/RCInstance';
import useInviteStore from '../../store/inviteStore';
import useChannelStore from '../../store/channelStore';
import InviteMembers from './InviteMembers';
import { getRoomMemberStyles } from './RoomMembers.styles';
import LoadingIndicator from '../MessageAggregators/common/LoadingIndicator';
Expand All @@ -30,6 +31,7 @@ const RoomMembers = ({ members }) => {

const toggleInviteView = useInviteStore((state) => state.toggleInviteView);
const showInvite = useInviteStore((state) => state.showInvite);
const channelInfo = useChannelStore((state) => state.channelInfo);
const [isLoading, setIsLoading] = useState(true);
const { variantOverrides } = useComponentOverrides('RoomMember');
const viewType = variantOverrides.viewType || 'Sidebar';
Expand Down Expand Up @@ -68,8 +70,8 @@ const RoomMembers = ({ members }) => {
filtered.filter(
(member) =>
member.name?.toLowerCase().includes(searchTerm.toLowerCase()) ||
member.username?.toLowerCase().includes(searchTerm.toLowerCase())
)
member.username?.toLowerCase().includes(searchTerm.toLowerCase()),
),
);
}, [viewStatus, searchTerm, members]);

Expand Down Expand Up @@ -163,7 +165,8 @@ const RoomMembers = ({ members }) => {
<Divider />
</Box>
<Box>
Showing {displayedMembers} of {displayedMembers}
Showing {displayedMembers} of{' '}
{channelInfo?.usersCount ?? members.length}
</Box>
<Box css={styles.memberList}>
{filteredMembers.length > 0 ? (
Expand Down