-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Every time a window becomes active, fetch invite links so that we can display the most recent version without requesting too often. Ultimately, we would like to have a mechanism where every invite link change results in updates being sent to interested clients. Depends on D8239 Test Plan: Check if actions are dispatched when the window becomes active. Modify website responder so that an empty invite links store is returned. Check if the links are updated after successful result is returned from the server when a window becomes active. Reviewers: bartek, kamil, inka Reviewed By: kamil Subscribers: ashoat Differential Revision: https://phab.comm.dev/D8246
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// @flow | ||
|
||
import * as React from 'react'; | ||
|
||
import { | ||
fetchPrimaryInviteLinkActionTypes, | ||
fetchPrimaryInviteLinks, | ||
} from 'lib/actions/link-actions.js'; | ||
import { isLoggedIn } from 'lib/selectors/user-selectors.js'; | ||
import { | ||
useDispatchActionPromise, | ||
useServerCall, | ||
} from 'lib/utils/action-utils.js'; | ||
|
||
import { useSelector } from '../redux/redux-utils.js'; | ||
|
||
function InviteLinksRefresher(): React.Node { | ||
const isActive = useSelector(state => state.windowActive); | ||
const loggedIn = useSelector(isLoggedIn); | ||
const callFetchPrimaryLinks = useServerCall(fetchPrimaryInviteLinks); | ||
const dispatchActionPromise = useDispatchActionPromise(); | ||
|
||
React.useEffect(() => { | ||
if (!isActive || !loggedIn) { | ||
return; | ||
} | ||
dispatchActionPromise( | ||
fetchPrimaryInviteLinkActionTypes, | ||
callFetchPrimaryLinks(), | ||
); | ||
}, [callFetchPrimaryLinks, dispatchActionPromise, isActive, loggedIn]); | ||
|
||
return null; | ||
} | ||
|
||
export default InviteLinksRefresher; |