Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(flat-pages): open users panel on click users count #1838

Merged
merged 1 commit into from
Feb 13, 2023
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
7 changes: 5 additions & 2 deletions packages/flat-components/src/components/ChatPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { useTranslate } from "@netless/flat-i18n";
import { ChatMessages, ChatMessagesProps } from "./ChatMessages";
import { ChatTabTitle, ChatTabTitleProps } from "./ChatTabTitle";

export type ChatPanelProps = { totalUserCount?: number } & ChatTabTitleProps &
export type ChatPanelProps = {
totalUserCount?: number;
onClickTotalUsersCount?: () => void;
} & ChatTabTitleProps &
Omit<ChatMessagesProps, "visible">;

export const ChatPanel = /* @__PURE__ */ observer<ChatPanelProps>(function ChatPanel(props) {
Expand All @@ -19,7 +22,7 @@ export const ChatPanel = /* @__PURE__ */ observer<ChatPanelProps>(function ChatP
<span>{t("messages")}</span>
</ChatTabTitle>
{props.totalUserCount && (
<span className="chat-tab-subtitle">
<span className="chat-tab-subtitle" onClick={props.onClickTotalUsersCount}>
{t("total-users-count", { count: props.totalUserCount })}
</span>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/flat-pages/src/components/ChatPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const ChatPanel = observer<ChatPanelProps>(function ChatPanel({ classRoom
unreadCount={classRoomStore.users.handRaisingJoiners.length || null}
userUUID={classRoomStore.userUUID}
onBanChange={classRoomStore.onToggleBan}
onClickTotalUsersCount={() => classRoomStore.toggleUsersPanel(true)}
onMessageSend={classRoomStore.onMessageSend}
/>
);
Expand Down
9 changes: 4 additions & 5 deletions packages/flat-pages/src/components/UsersButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./UsersButton.less";

// TODO: remove this component when multi sub window is done
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useEffect } from "react";
import { Modal } from "antd";
import { observer } from "mobx-react-lite";
import { useTranslate } from "@netless/flat-i18n";
Expand All @@ -14,7 +14,6 @@ interface UsersButtonProps {

export const UsersButton = observer<UsersButtonProps>(function UsersButton({ classroom }) {
const t = useTranslate();
const [open, setOpen] = useState(false);

// not including teacher
const users = useComputed(() => {
Expand Down Expand Up @@ -87,16 +86,16 @@ export const UsersButton = observer<UsersButtonProps>(function UsersButton({ cla
<TopBarRightBtn
icon={<SVGUserGroup />}
title={t("users")}
onClick={() => setOpen(!open)}
onClick={() => classroom.toggleUsersPanel(!classroom.isUsersPanelVisible)}
/>
<Modal
centered
destroyOnClose
className="users-button-modal"
footer={[]}
open={open}
open={classroom.isUsersPanelVisible}
title={t("users")}
onCancel={() => setOpen(false)}
onCancel={() => classroom.toggleUsersPanel(false)}
>
<UsersPanel
getDeviceState={getDeviceState}
Expand Down
5 changes: 5 additions & 0 deletions packages/flat-stores/src/classroom-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class ClassroomStore {

public isCloudStoragePanelVisible = false;
public isHandRaisingPanelVisible = false;
public isUsersPanelVisible = false;

public roomStatusLoading = RoomStatusLoadingType.Null;

Expand Down Expand Up @@ -665,6 +666,10 @@ export class ClassroomStore {
this.isCloudStoragePanelVisible = visible;
};

public toggleUsersPanel = (visible = !this.isUsersPanelVisible): void => {
this.isUsersPanelVisible = visible;
};

public onDrop = (file: File): void => {
this.toggleCloudStoragePanel(true);
const cloudStorage = this.whiteboardStore.cloudStorageStore;
Expand Down