-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-1520 Add some logic for redirection to 'Notifications' page
- Loading branch information
1 parent
c4c9a9c
commit 0d60833
Showing
12 changed files
with
238 additions
and
117 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
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,22 @@ | ||
import { useEffect } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
|
||
import { ScreensEnum } from 'src/navigator/enums/screens.enum'; | ||
import { useNavigation } from 'src/navigator/hooks/use-navigation.hook'; | ||
import { setShouldRedirectToNotificationsAction } from 'src/store/notifications/notifications-actions'; | ||
import { useShouldRedirectToNotificationsSelector } from 'src/store/notifications/notifications-selectors'; | ||
|
||
export const useNotificationRedirection = (isLocked: boolean, isAuthorised: boolean) => { | ||
const { navigate } = useNavigation(); | ||
const dispatch = useDispatch(); | ||
const shouldRedirectToNotifications = useShouldRedirectToNotificationsSelector(); | ||
|
||
useEffect(() => { | ||
if (isLocked || !isAuthorised || !shouldRedirectToNotifications) { | ||
return; | ||
} | ||
|
||
dispatch(setShouldRedirectToNotificationsAction(false)); | ||
navigate(ScreensEnum.Notifications); | ||
}, [dispatch, isAuthorised, isLocked, navigate, shouldRedirectToNotifications]); | ||
}; |
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
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
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,15 +1,18 @@ | ||
import { NotificationInterface } from '../../interfaces/notification.interface'; | ||
import { NotificationInterface } from 'src/interfaces/notification.interface'; | ||
|
||
import { createEntity } from '../create-entity'; | ||
import { LoadableEntityState } from '../types'; | ||
|
||
export interface NotificationsState { | ||
startFromTime: number; | ||
list: LoadableEntityState<NotificationInterface[]>; | ||
isNewsEnabled: boolean; | ||
shouldRedirectToNotifications: boolean; | ||
} | ||
|
||
export const notificationsInitialState: NotificationsState = { | ||
startFromTime: new Date().getTime(), | ||
list: createEntity([]), | ||
isNewsEnabled: true | ||
isNewsEnabled: true, | ||
shouldRedirectToNotifications: false | ||
}; |
Oops, something went wrong.