Skip to content

Commit

Permalink
[FIX] Show call icon only when user has extension associated (#24752)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored and sampaiodiego committed Mar 21, 2022
1 parent a23cfa8 commit 057768b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/lib/server/functions/getFullUserData.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const defaultFields = {
reason: 1,
statusText: 1,
avatarETag: 1,
extension: 1,
};

const fullFields = {
Expand All @@ -30,7 +31,6 @@ const fullFields = {
requirePasswordChange: 1,
requirePasswordChangeReason: 1,
roles: 1,
extension: 1,
};

let publicCustomFields = {};
Expand Down
1 change: 1 addition & 0 deletions app/utils/server/functions/getDefaultUserFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export const getDefaultUserFields = (): DefaultUserFields => ({
'oauth.authorizedClients': 1,
'_updatedAt': 1,
'avatarETag': 1,
'extension': 1,
});
7 changes: 7 additions & 0 deletions client/providers/CallProvider/CallProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ export const CallProvider: FC = ({ children }) => {
};
}

if (!user?.extension) {
return {
enabled: false,
ready: false,
};
}

if (isUseVoipClientResultError(result)) {
return {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion client/providers/CallProvider/hooks/useVoipClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useVoipClient = (): UseVoipClientResult => {
const [result, setResult] = useSafely(useState<UseVoipClientResult>({}));

useEffect(() => {
if (!user || !user?._id || !voipEnabled) {
if (!user || !user?._id || !user?.extension || !voipEnabled) {
setResult({});
return;
}
Expand Down

0 comments on commit 057768b

Please sign in to comment.