Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dusken-client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EDB
dusken-client
Commits
78ec4693
Commit
78ec4693
authored
May 05, 2019
by
Nikolai R Kristiansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate redux-persist legacy data
parent
7cc2030e
Pipeline
#714
failed with stage
in 1 minute and 45 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
8 deletions
+51
-8
android/app/build.gradle
android/app/build.gradle
+1
-1
src/Dusken.js
src/Dusken.js
+23
-7
src/utils.js
src/utils.js
+27
-0
No files found.
android/app/build.gradle
View file @
78ec4693
...
...
@@ -106,7 +106,7 @@ android {
applicationId
"no.neuf.chateau"
minSdkVersion
rootProject
.
ext
.
minSdkVersion
targetSdkVersion
rootProject
.
ext
.
targetSdkVersion
versionCode
2
3
versionCode
2
4
versionName
"1.3.0"
}
splits
{
...
...
src/Dusken.js
View file @
78ec4693
import
React
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
Root
}
from
'
native-base
'
;
import
DuskenNavigation
from
'
./navigation
'
;
import
{
userDataSuccess
}
from
'
./actions
'
;
import
{
migrateReduxPersistFourToFive
}
from
'
./utils
'
;
const
DuskenContainer
=
({
setUserData
})
=>
{
useEffect
(()
=>
{
migrateReduxPersistFourToFive
(
setUserData
);
});
return
(
<
Root
>
<
DuskenNavigation
/>
<
/Root
>
);
};
const
DuskenContainer
=
()
=>
(
<
Root
>
<
DuskenNavigation
/>
<
/Root
>
);
const
mapDispatchToProps
=
{
setUserData
:
userDataSuccess
,
};
export
default
connect
()(
DuskenContainer
);
export
default
connect
(
null
,
mapDispatchToProps
)(
DuskenContainer
);
src/utils.js
View file @
78ec4693
/* global fetch */
import
AsyncStorage
from
'
@react-native-community/async-storage
'
;
export
function
snakeToCamelCase
(
val
)
{
return
val
.
replace
(
/_
([
a-z
])
/g
,
function
(
g
)
{
return
g
[
1
].
toUpperCase
();
...
...
@@ -13,3 +15,28 @@ export function fetchWithTimeout(url, options, timeout = 10000) {
new
Promise
((
_
,
reject
)
=>
setTimeout
(()
=>
reject
(
new
Error
(
'
Fetch request timed out
'
)),
timeout
)),
]);
}
export
async
function
migrateReduxPersistFourToFive
(
setUserData
)
{
const
authedKey
=
'
reduxPersist:isAuthenticated
'
;
const
userKey
=
'
reduxPersist:user
'
;
const
userTokenKey
=
'
reduxPersist:userToken
'
;
const
v4Keys
=
[
authedKey
,
userKey
,
userTokenKey
];
const
asyncStorageKeys
=
await
AsyncStorage
.
getAllKeys
();
if
(
v4Keys
.
some
((
key
)
=>
!
asyncStorageKeys
.
includes
(
key
)))
{
return
;
}
const
isAuthenticated
=
await
AsyncStorage
.
getItem
(
authedKey
);
console
.
log
(
authedKey
,
isAuthenticated
);
if
(
isAuthenticated
!==
'
true
'
)
{
await
AsyncStorage
.
multiRemove
(
v4Keys
);
return
;
}
const
user
=
await
AsyncStorage
.
getItem
(
userKey
);
console
.
log
(
userKey
,
user
,
JSON
.
parse
(
user
));
setUserData
(
JSON
.
parse
(
user
));
await
AsyncStorage
.
multiRemove
(
v4Keys
);
console
.
log
(
'
successfully migrated to new redux-persist
'
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment