fix: error when leaving the room without joining
This commit is contained in:
parent
a473a40807
commit
8476595011
4 changed files with 8 additions and 5 deletions
|
@ -7,7 +7,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "wxt",
|
"dev": "wxt",
|
||||||
"dev:firefox": "wxt -b firefox",
|
"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",
|
"build:firefox": "wxt build -b firefox",
|
||||||
"pack": "cross-env NODE_ENV=production run-p pack:*",
|
"pack": "cross-env NODE_ENV=production run-p pack:*",
|
||||||
"pack:chrome": "wxt zip -b chrome",
|
"pack:chrome": "wxt zip -b chrome",
|
||||||
|
|
|
@ -22,8 +22,8 @@ export default defineContentScript({
|
||||||
excludeMatches: ['*://localhost/*', '*://127.0.0.1/*'],
|
excludeMatches: ['*://localhost/*', '*://127.0.0.1/*'],
|
||||||
async main(ctx) {
|
async main(ctx) {
|
||||||
const store = Remesh.store({
|
const store = Remesh.store({
|
||||||
externs: [IndexDBStorageImpl, BrowserSyncStorageImpl, PeerRoomImpl, ToastImpl],
|
externs: [IndexDBStorageImpl, BrowserSyncStorageImpl, PeerRoomImpl, ToastImpl]
|
||||||
inspectors: __DEV__ ? [RemeshLogger()] : []
|
// inspectors: __DEV__ ? [RemeshLogger()] : []
|
||||||
})
|
})
|
||||||
|
|
||||||
const ui = await createShadowRootUi(ctx, {
|
const ui = await createShadowRootUi(ctx, {
|
||||||
|
|
|
@ -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
|
// 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({
|
domain.effect({
|
||||||
name: 'RoomOnUnloadEffect',
|
name: 'RoomOnUnloadEffect',
|
||||||
impl: () => {
|
impl: ({ get }) => {
|
||||||
const beforeUnload$ = fromEvent(window, 'beforeunload').pipe(
|
const beforeUnload$ = fromEvent(window, 'beforeunload').pipe(
|
||||||
map(() => {
|
map(() => {
|
||||||
return [LeaveRoomCommand()]
|
return get(RoomJoinStatusModule.query.IsFinishedQuery()) ? LeaveRoomCommand() : null
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
return beforeUnload$
|
return beforeUnload$
|
||||||
|
|
|
@ -43,6 +43,8 @@ const UserInfoDomain = Remesh.domain({
|
||||||
const UpdateUserInfoCommand = domain.command({
|
const UpdateUserInfoCommand = domain.command({
|
||||||
name: 'UserInfo.UpdateUserInfoCommand',
|
name: 'UserInfo.UpdateUserInfoCommand',
|
||||||
impl: (_, userInfo: UserInfo | null) => {
|
impl: (_, userInfo: UserInfo | null) => {
|
||||||
|
console.log('111', userInfo)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
UserInfoState().new(userInfo),
|
UserInfoState().new(userInfo),
|
||||||
UpdateUserInfoEvent(),
|
UpdateUserInfoEvent(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue