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

[FIX] VOIP CallContext snapshot infinite loop #25947

Merged
merged 4 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions apps/meteor/client/contexts/CallContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ export const useIsCallEnabled = (): boolean => {
return enabled;
};

let callerInfo: VoIpCallerInfo;

export const useIsCallReady = (): boolean => {
const { ready } = useContext(CallContext);
const context = useContext(CallContext);

if (isCallContextReady(context)) {
callerInfo = context.voipClient.callerInfo;
}

return Boolean(ready);
return !!context.ready;
};

export const useIsCallError = (): boolean => {
Expand Down Expand Up @@ -99,7 +105,10 @@ export const useCallerInfo = (): VoIpCallerInfo => {
},
[voipClient],
);
return useSyncExternalStore(subscribe, (): VoIpCallerInfo => voipClient.callerInfo);

const getSnapshot = (): VoIpCallerInfo => callerInfo;

return useSyncExternalStore(subscribe, getSnapshot);
};

export const useCallCreateRoom = (): CallContextReady['createRoom'] => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
"@rocket.chat/forked-matrix-appservice-bridge": "^4.0.1",
"@rocket.chat/forked-matrix-bot-sdk": "^0.6.0-beta.2",
"@rocket.chat/fuselage": "0.32.0-dev.49",
"@rocket.chat/fuselage-hooks": "~0.31.14-dev.7",
"@rocket.chat/fuselage-hooks": "~0.31.14-dev.9",
"@rocket.chat/fuselage-polyfills": "~0.31.12",
"@rocket.chat/fuselage-toastbar": "^0.32.0-dev.22",
"@rocket.chat/fuselage-tokens": "~0.31.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-contexts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"devDependencies": {
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "^0.31.11",
"@rocket.chat/fuselage-hooks": "~0.31.14-dev.7",
"@rocket.chat/fuselage-hooks": "~0.31.14-dev.9",
"@rocket.chat/rest-typings": "workspace:^",
"@types/jest": "^27.4.1",
"@types/mongodb": "~3.6.10",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3529,15 +3529,15 @@ __metadata:
languageName: node
linkType: hard

"@rocket.chat/fuselage-hooks@npm:~0.31.14-dev.7":
version: 0.31.14-dev.7
resolution: "@rocket.chat/fuselage-hooks@npm:0.31.14-dev.7"
"@rocket.chat/fuselage-hooks@npm:~0.31.14-dev.9":
version: 0.31.14-dev.9
resolution: "@rocket.chat/fuselage-hooks@npm:0.31.14-dev.9"
dependencies:
use-sync-external-store: ~1.2.0
peerDependencies:
"@rocket.chat/fuselage-tokens": "*"
react: ^17.0.2
checksum: ad2a1a61189d694e5e70ab73dfc20a7bea7ad0686be97993b24c6053b5cfa027e6b70690b75b5e9c1e8712a2b41f7d031a416c5e6781e9c4b31b5c0a40529ea0
checksum: fa79c8c8a5b56d0c5ccd2118735a6eef5aaf99f1392161d90e72da4dc0cd1dc9007387df71ab428545f72a3c5c8c1648c086078724cb4698ec05044a0462e0b6
languageName: node
linkType: hard

Expand Down Expand Up @@ -3819,7 +3819,7 @@ __metadata:
"@rocket.chat/forked-matrix-appservice-bridge": ^4.0.1
"@rocket.chat/forked-matrix-bot-sdk": ^0.6.0-beta.2
"@rocket.chat/fuselage": 0.32.0-dev.49
"@rocket.chat/fuselage-hooks": ~0.31.14-dev.7
"@rocket.chat/fuselage-hooks": ~0.31.14-dev.9
"@rocket.chat/fuselage-polyfills": ~0.31.12
"@rocket.chat/fuselage-toastbar": ^0.32.0-dev.22
"@rocket.chat/fuselage-tokens": ~0.31.12
Expand Down Expand Up @@ -4239,7 +4239,7 @@ __metadata:
dependencies:
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/emitter": ^0.31.11
"@rocket.chat/fuselage-hooks": ~0.31.14-dev.7
"@rocket.chat/fuselage-hooks": ~0.31.14-dev.9
"@rocket.chat/rest-typings": "workspace:^"
"@types/jest": ^27.4.1
"@types/mongodb": ~3.6.10
Expand Down