Skip to content

Commit

Permalink
fix(flat-pages): room not begin modal wrong logic (#2116)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious authored Feb 20, 2024
1 parent d429e3c commit 282cef2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
1 change: 0 additions & 1 deletion packages/flat-i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@
"room-not-begin-title-post": "before it starts",
"room-has-been-added": "has been added to rooms list",
"the-room-is-not-started-yet": "The room has not started yet, please try again later",
"your-room-is-not-started-yet": "Your room has not started yet, please try again later",
"will-start-after-minutes": "will start after {{minutes}} minutes",
"time-limit-tip": "This {{roomType}} room has a limit of {{minutes}} minutes",
"vip-level": {
Expand Down
3 changes: 1 addition & 2 deletions packages/flat-i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,7 @@
"minutes": "{{minutes}}分钟",
"room-not-begin-title-post": "可进入",
"room-has-been-added": "已加入房间列表",
"the-room-is-not-started-yet": "房间未开始,开课前 5 分钟可进入,已将该房间添加到房间列表",
"your-room-is-not-started-yet": "房间未开始,开课前 5 分钟可进入",
"the-room-is-not-started-yet": "房间未开始,开课前 5 分钟可进入",
"will-start-after-minutes": "{{minutes}} 分钟后开始",
"time-limit-tip": "你已加入{{roomType}} {{minutes}} 分钟限时房间",
"vip-level": {
Expand Down
20 changes: 7 additions & 13 deletions packages/flat-pages/src/utils/join-room-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RouteNameType } from "../utils/routes";
import { roomStore, globalStore } from "@netless/flat-stores";
import { RequestErrorCode, RoomType, ServerRequestError } from "@netless/flat-server-api";
import { RequestErrorCode, RoomType } from "@netless/flat-server-api";
import { errorTips, message } from "flat-components";
import { FlatI18n } from "@netless/flat-i18n";

Expand Down Expand Up @@ -56,24 +56,18 @@ export const joinRoomHandler = async (
return;
}

// if room not started, show different message according to owner
if (e.errorCode === RequestErrorCode.RoomNotBegin && e.detail) {
const { title, ownerUUID, ownerName } = e.detail as {
// if room not started, show different tips
if (e.errorCode === RequestErrorCode.RoomNotBeginAndAddList && e.detail) {
const roomNotBegin = e.detail as {
title: string;
uuid: string;
beginTime: number;
ownerUUID: string;
ownerName?: string;
};
if (globalStore.userUUID === ownerUUID) {
(e as ServerRequestError).errorMessage = "your-room-is-not-started-yet";
// show it in error tips
} else {
pushHistory(RouteNameType.HomePage);
// show the modal
globalStore.updateRoomNotBegin({ title, ownerName });
return;
}
pushHistory(RouteNameType.HomePage);
globalStore.updateRoomNotBegin(roomNotBegin);
return;
}

pushHistory(RouteNameType.HomePage);
Expand Down

0 comments on commit 282cef2

Please sign in to comment.