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

perf(flat-stores): fetch users info only when necessary #1946

Merged
merged 8 commits into from
Jun 5, 2023

Conversation

hyrious
Copy link
Member

@hyrious hyrious commented Jun 1, 2023

New RTM commands @netless-io/native

Broadcast Command "enter": Tell everyone in the room your basic info (name, avatar, rtcUID); pick up to 3 peers to tell you everyone else's info, see the next command.

onJoinRoom((rtm) => {
    rtm.sendRoomCommand("enter", {
        roomUUID: this.roomUUID,
        userUUID: user.userUUID,
        userInfo: {
            name: user.name,
            avatarURL: user.avatar,
            rtcUID: +user.rtcUID || 0,
        },
        peers: sampleSize(rtm.members, 3),
    })
})

onRoomCommand("enter", ({ userUUID, userInfo }) => {
    usersStore.cacheUser(userUUID, userInfo)
})
Disabled "users-info" command for now because of the limitation of RTM

Peer Command "users-info": Tell someone all of the local users' info.

onRoomCommand("enter", ({ userUUID: senderID, peers }) => {
    if (peers.includes(this.userUUID)) {
        rtm.sendPeerCommand("users-info", {
            roomUUID: this.roomUUID,
            users: getAllLocalUsers(),
        }, senderID)
    }
})

// The return value is the same as the /room/info/users server API.
declare function getAllLocalUsers(): {
    [userUUID: string]: {
        rtcUID: number,
        name: string,
        avatarURL: string,
    }
}

onPeerCommand("users-info", ({ users }) => {
    usersStore.cacheUsers(users)
})

- only fetch minimal users info once on initialize, which includes the owner and on stage users
- only fetch other users info when open users panel
- flat-components: add login shortcuts in dev mode
- flat-components: lift up windows system buttons
- flat-stores: fetch raise hand users info when necessary
- flat-stores: ignore self "enter" command
@hyrious hyrious marked this pull request as ready for review June 2, 2023 02:06
@hyrious hyrious requested review from syt-honey and crimx June 5, 2023 07:11
@hyrious hyrious merged commit d93ecc1 into netless-io:main Jun 5, 2023
2 checks passed
@hyrious hyrious deleted the main branch June 5, 2023 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants