-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [IOPID-2050] Add session refresh Feature Flag (#6045)
> [!Warning] > This PR depends on pagopa/io-services-metadata#815 > When pagopa/io-services-metadata#815 will be released i need to change the version into the "content_specs" in package.json ## List of changes proposed in this pull request - Edit package.json with correct version of io-services-metadata - Add selector to remote FF (`fastLoginSessionRefreshFFEnabled`) - Add selector to control if fast login is active (`isFastLoginSessionRefreshEnabledSelector`) - Add toggle to enabled/disabled this feature (this toggle now is visible only if the remote FF is active because otherwise it would not display the feature, so it will be displayed in the next pr (is controlled using`isFastLoginSessionRefreshToggleActiveSelector` -> is a persisted value) ## How to test - Run the application using the latest version of the io-dev-api-server - delete [this line](https://github.com/pagopa/io-app/blob/128dfab2bfdcc7bc7ba1783daf7eb05ccfa18b23/ts/screens/profile/DeveloperModeSection.tsx#L368) to see the toggle - follow the video ## Demo <video src="https://github.com/user-attachments/assets/d937f98f-6e0c-4ea9-b285-42c8b0d8b2a2"/> --------- Co-authored-by: Fabio Bombardi <[email protected]>
- Loading branch information
1 parent
8c0fe6b
commit e36579b
Showing
9 changed files
with
148 additions
and
7 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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { fastLoginOptInActions } from "./optInActions"; | ||
import { SecurityAdviceActions } from "./securityAdviceActions"; | ||
import { automaticSessionRefreshActions } from "./sessionRefreshActions"; | ||
import { FastLoginTokenRefreshActions } from "./tokenRefreshActions"; | ||
|
||
export type FastLoginActions = | ||
| fastLoginOptInActions | ||
| automaticSessionRefreshActions | ||
| FastLoginTokenRefreshActions | ||
| SecurityAdviceActions; |
10 changes: 10 additions & 0 deletions
10
ts/features/fastLogin/store/actions/sessionRefreshActions.ts
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,10 @@ | ||
import { ActionType, createStandardAction } from "typesafe-actions"; | ||
import { AutomaticSessionRefreshState } from "../reducers/sessionRefreshReducer"; | ||
|
||
export const setAutomaticSessionRefresh = createStandardAction( | ||
"SET_AUTOMATIC_SESSION_REFRESH_AFTER_TWO_MIN_BACKGROUND" | ||
)<AutomaticSessionRefreshState>(); | ||
|
||
export type automaticSessionRefreshActions = ActionType< | ||
typeof setAutomaticSessionRefresh | ||
>; |
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
50 changes: 50 additions & 0 deletions
50
ts/features/fastLogin/store/reducers/sessionRefreshReducer.ts
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,50 @@ | ||
import AsyncStorage from "@react-native-async-storage/async-storage"; | ||
import { PersistConfig, persistReducer } from "redux-persist"; | ||
import { getType } from "typesafe-actions"; | ||
import { setAutomaticSessionRefresh } from "../actions/sessionRefreshActions"; | ||
import { Action } from "../../../../store/actions/types"; | ||
import { | ||
logoutFailure, | ||
logoutSuccess | ||
} from "../../../../store/actions/authentication"; | ||
|
||
export type AutomaticSessionRefreshState = { | ||
enabled: boolean | undefined; | ||
}; | ||
|
||
export const automaticSessionRefreshInitialState: AutomaticSessionRefreshState = | ||
{ | ||
enabled: undefined | ||
}; | ||
|
||
const AutomaticSessionRefreshReducer = ( | ||
state: AutomaticSessionRefreshState = automaticSessionRefreshInitialState, | ||
action: Action | ||
): AutomaticSessionRefreshState => { | ||
switch (action.type) { | ||
case getType(logoutSuccess): | ||
case getType(logoutFailure): | ||
return automaticSessionRefreshInitialState; | ||
case getType(setAutomaticSessionRefresh): | ||
return { | ||
...state, | ||
enabled: action.payload.enabled | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
const CURRENT_REDUX_SESSION_REFRESH_STORE_VERSION = -1; | ||
|
||
const persistConfig: PersistConfig = { | ||
key: "sessionRefresh", | ||
storage: AsyncStorage, | ||
version: CURRENT_REDUX_SESSION_REFRESH_STORE_VERSION, | ||
whitelist: ["enabled"] | ||
}; | ||
|
||
export const automaticSessionRefreshPersistor = persistReducer< | ||
AutomaticSessionRefreshState, | ||
Action | ||
>(persistConfig, AutomaticSessionRefreshReducer); |
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