Skip to content

Commit

Permalink
refactor(flat-pages): format pmi invitation (#2061)
Browse files Browse the repository at this point in the history
  • Loading branch information
syt-honey authored Oct 27, 2023
1 parent e5290be commit 6bbd7dd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"periodic": "Periodic",
"today": "Today",
"tomorrow": "Tomorrow",
"pmi-invite-prefix": "{{userName}} invites you to join {{appName}} personal room",
"invite-begin-time": "Start time: {{time}}",
"invite-prefix": "{{userName}} invites you to join the {{appName}} room\n\nRoom theme: {{title}}",
"invite-suffix": "Room ID: {{uuid}}",
Expand Down
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"all-loaded": "已全部加载",
"no-record": "暂无记录",
"no-room": "暂无房间",
"pmi-invite-prefix": "{{userName}} 邀请你加入 {{appName}} 个人房间",
"invite-prefix": "{{userName}} 邀请你加入 {{appName}} 房间\n房间主题:{{title}}\n",
"invite-begin-time": "开始时间:{{time}}\n",
"invite-suffix": "房间号:{{uuid}}",
Expand Down
27 changes: 23 additions & 4 deletions packages/flat-pages/src/HomePage/MainRoomMenu/CreateRoomBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import "./CreateRoomBox.less";

import React, { useContext, useEffect, useRef, useState, KeyboardEvent, useCallback } from "react";
import { ClassPicker, HomePageHeroButton, PmiDesc, PmiExistTip, Region } from "flat-components";
import {
ClassPicker,
HomePageHeroButton,
PmiDesc,
PmiExistTip,
Region,
formatInviteCode,
} from "flat-components";
import { Input, Modal, Checkbox, Form, InputRef, Dropdown, message, Button } from "antd";
import { MoreOutlined } from "@ant-design/icons";
import { useTranslate } from "@netless/flat-i18n";
Expand All @@ -12,6 +19,7 @@ import { PreferencesStoreContext, GlobalStoreContext } from "../../components/St
import { RouteNameType, usePushHistory } from "../../utils/routes";
import { joinRoomHandler } from "../../utils/join-room-handler";
import { useSafePromise } from "../../utils/hooks/lifecycle";
import { FLAT_WEB_BASE_URL } from "../../constants/process";

interface CreateRoomFormValues {
roomTitle: string;
Expand Down Expand Up @@ -51,7 +59,7 @@ export const CreateRoomBox = observer<CreateRoomBoxProps>(function CreateRoomBox
roomType: RoomType.BigClass,
autoMicOn: preferencesStore.autoMicOn,
autoCameraOn: preferencesStore.autoCameraOn,
// if there exists pmi room, it will can not be selected
// if there exists pmi room, it can not be selected
pmi: preferencesStore.autoPmiOn && !globalStore.pmiRoomExist,
};

Expand Down Expand Up @@ -83,10 +91,21 @@ export const CreateRoomBox = observer<CreateRoomBoxProps>(function CreateRoomBox

const handleCopy = useCallback(
(text: string) => {
navigator.clipboard.writeText(text);
const copyText =
t("pmi-invite-prefix", {
userName: globalStore.userInfo?.name,
}) +
"\n" +
"\n" +
t("invite-suffix", { uuid: formatInviteCode("", text) }) +
"\n" +
"\n" +
t("invite-join-link", { link: `${FLAT_WEB_BASE_URL}/join/${text}` });

navigator.clipboard.writeText(copyText);
void message.success(t("copy-success"));
},
[t],
[globalStore.userInfo?.name, t],
);

const handleCreateRoom = (): void => {
Expand Down
2 changes: 1 addition & 1 deletion packages/flat-pages/src/UserScheduledPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const UserScheduledPage = observer(function UserScheduledPage() {
rate: 7,
endTime: addWeeks(scheduleBeginTime, 6),
},
// if there exists pmi room, it will can not be selected
// if there exists pmi room, it can not be selected
pmi: preferencesStore.autoPmiOn && !globalStore.pmiRoomExist,
};
});
Expand Down

0 comments on commit 6bbd7dd

Please sign in to comment.