fix: error when leaving the room without joining

This commit is contained in:
molvqingtai 2024-09-29 15:33:12 +08:00
parent a473a40807
commit 8476595011
4 changed files with 8 additions and 5 deletions

View file

@ -7,7 +7,8 @@
"scripts": {
"dev": "wxt",
"dev:firefox": "wxt -b firefox",
"build": "wxt build",
"build": "cross-env NODE_ENV=production run-p build:*",
"build:chorme": "wxt build -b chorme",
"build:firefox": "wxt build -b firefox",
"pack": "cross-env NODE_ENV=production run-p pack:*",
"pack:chrome": "wxt zip -b chrome",

View file

@ -22,8 +22,8 @@ export default defineContentScript({
excludeMatches: ['*://localhost/*', '*://127.0.0.1/*'],
async main(ctx) {
const store = Remesh.store({
externs: [IndexDBStorageImpl, BrowserSyncStorageImpl, PeerRoomImpl, ToastImpl],
inspectors: __DEV__ ? [RemeshLogger()] : []
externs: [IndexDBStorageImpl, BrowserSyncStorageImpl, PeerRoomImpl, ToastImpl]
// inspectors: __DEV__ ? [RemeshLogger()] : []
})
const ui = await createShadowRootUi(ctx, {

View file

@ -408,10 +408,10 @@ const RoomDomain = Remesh.domain({
// TODO: Move this to a service worker in the future, so we don't need to send a leave room message every time the page refreshes
domain.effect({
name: 'RoomOnUnloadEffect',
impl: () => {
impl: ({ get }) => {
const beforeUnload$ = fromEvent(window, 'beforeunload').pipe(
map(() => {
return [LeaveRoomCommand()]
return get(RoomJoinStatusModule.query.IsFinishedQuery()) ? LeaveRoomCommand() : null
})
)
return beforeUnload$

View file

@ -43,6 +43,8 @@ const UserInfoDomain = Remesh.domain({
const UpdateUserInfoCommand = domain.command({
name: 'UserInfo.UpdateUserInfoCommand',
impl: (_, userInfo: UserInfo | null) => {
console.log('111', userInfo)
return [
UserInfoState().new(userInfo),
UpdateUserInfoEvent(),