-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added mac endpoints and stream
- Loading branch information
1 parent
a4a6fd3
commit d8d53d0
Showing
2 changed files
with
22 additions
and
12 deletions.
There are no files selected for viewing
21 changes: 15 additions & 6 deletions
21
apps/meteor/client/hooks/omnichannel/useIsOverMacLimit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
// @ts-nocheck | ||
// import { useEndpoint } from '@rocket.chat/ui-contexts'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useEndpoint, useStream } from '@rocket.chat/ui-contexts'; | ||
import { useQuery, useQueryClient } from '@tanstack/react-query'; | ||
import { useEffect } from 'react'; | ||
|
||
export const useIsOverMacLimit = (): boolean => { | ||
const getMacLimit = () => Promise.resolve(true); // useEndpoint('GET', '/v1/livechat/mac'); // TODO: add the correct endpoint | ||
const { data: isOverMacLimit } = useQuery(['omnichannel', '/v1/livechat/mac'], () => getMacLimit()); | ||
return isOverMacLimit; | ||
const queryClient = useQueryClient(); | ||
const notifyLogged = useStream('notify-logged'); | ||
const getMacLimit = useEndpoint('GET', '/v1/omnichannel/mac/check'); | ||
const { data: isOverMacLimit } = useQuery(['/v1/omnichannel/mac/check'], () => getMacLimit()); | ||
|
||
useEffect(() => { | ||
return notifyLogged(`mac.limit`, ({ limitReached }) => { | ||
limitReached && queryClient.invalidateQueries(['/v1/omnichannel/mac/check']); | ||
}); | ||
}, [notifyLogged, queryClient]); | ||
|
||
return !!isOverMacLimit; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters