diff --git a/src/components/Onboarding/OnboardingSwiper.tsx b/src/components/Onboarding/OnboardingSwiper.tsx
index 80e90fb3f..5f865c7ba 100644
--- a/src/components/Onboarding/OnboardingSwiper.tsx
+++ b/src/components/Onboarding/OnboardingSwiper.tsx
@@ -86,7 +86,7 @@ const OnboardingSwiper = inject(
}
const done = () => {
- wocky!.profile!.setOnboarded()
+ permissionStore!.setOnboarded(true)
Actions.logged()
}
diff --git a/src/components/Router.tsx b/src/components/Router.tsx
index 35d9c52da..27ed30cb3 100644
--- a/src/components/Router.tsx
+++ b/src/components/Router.tsx
@@ -46,10 +46,10 @@ import OnboardingSwiper from './Onboarding/OnboardingSwiper'
import {IAuthStore} from 'src/store/AuthStore'
import {IHomeStore} from 'src/store/HomeStore';
import MapOptions from './MapOptions'
-import {IPermissionStore} from 'src/store/PermissionStore'
import LocationSettingsModal, {Props as LocationSettingsProps} from './LiveLocation/LocationSettingsModal'
import { IFirebaseStore } from '../store/FirebaseStore'
import {ContactInviteListWithLoad} from './people-lists/ContactInviteList'
+import { usePermissionStore } from '../utils/injectors'
const iconClose = require('../../images/iconClose.png')
@@ -60,19 +60,19 @@ type Props = {
homeStore?: IHomeStore
iconStore?: IconStore
authStore?: IAuthStore
- permissionStore?: IPermissionStore
analytics?: any
firebaseStore?: IFirebaseStore
}
-const TinyRobotRouter = inject('wocky', 'permissionStore', 'locationStore', 'iconStore', 'analytics', 'homeStore', 'navStore', 'authStore', 'firebaseStore')(
- observer(({wocky, permissionStore, locationStore, navStore, homeStore, iconStore, authStore, analytics, firebaseStore}: Props) => {
+const TinyRobotRouter = inject('wocky', 'locationStore', 'iconStore', 'analytics', 'homeStore', 'navStore', 'authStore', 'firebaseStore')(
+ observer(({wocky, locationStore, navStore, homeStore, iconStore, authStore, analytics, firebaseStore}: Props) => {
+ const permissionStore = usePermissionStore()
useEffect(() => {
reaction(() => navStore!.scene, () => Keyboard.dismiss())
autorun(
() => {
- if (permissionStore!.onboarded && !locationStore!.alwaysOn && navStore!.scene !== 'locationWarning' && Actions.locationWarning) {
+ if (permissionStore.onboarded && !locationStore!.alwaysOn && navStore!.scene !== 'locationWarning' && Actions.locationWarning) {
Actions.locationWarning({afterLocationAlwaysOn: () => Actions.popTo('home')})
}
},
@@ -81,7 +81,7 @@ const TinyRobotRouter = inject('wocky', 'permissionStore', 'locationStore', 'ico
autorun(
() => {
- if (permissionStore!.onboarded && !permissionStore!.allowsAccelerometer && navStore!.scene !== 'motionWarning' && Actions.motionWarning) {
+ if (permissionStore.onboarded && !permissionStore.allowsAccelerometer && navStore!.scene !== 'motionWarning' && Actions.motionWarning) {
Actions.motionWarning()
}
},
@@ -189,7 +189,7 @@ const TinyRobotRouter = inject('wocky', 'permissionStore', 'locationStore', 'ico
wocky!.profile} success="checkHandle" failure="connect" />
wocky!.profile!.handle} success="checkOnboarded" failure="signUp" />
- permissionStore!.onboarded} success={() => {
+ permissionStore.onboarded} success={() => {
Actions.logged()
if (firebaseStore!.inviteCode) {
showSharingModal()
diff --git a/src/store/LocationStore.ts b/src/store/LocationStore.ts
index aae1b6a83..b989923f4 100644
--- a/src/store/LocationStore.ts
+++ b/src/store/LocationStore.ts
@@ -256,7 +256,7 @@ const LocationStore = types
}
})
.actions(self => {
- const {wocky} = getRoot(self)
+ const {wocky, permissionStore} = getRoot(self)
let reactions: IReactionDisposer[] = []
const init = flow(function*() {
@@ -281,7 +281,7 @@ const LocationStore = types
wocky.connected &&
wocky.profile &&
wocky.profile.hidden &&
- wocky.profile.clientData.onboarded &&
+ permissionStore.onboarded &&
self.alwaysOn
) {
try {
diff --git a/src/store/PermissionStore.ts b/src/store/PermissionStore.ts
index 76a8ab9f3..18e3b768d 100644
--- a/src/store/PermissionStore.ts
+++ b/src/store/PermissionStore.ts
@@ -10,6 +10,7 @@ export const PermissionStore = types
allowsLocation: false,
allowsContacts: false,
loaded: false,
+ onboarded: false,
})
.actions(self => ({
setAllowsNotification(value: boolean) {
@@ -27,6 +28,9 @@ export const PermissionStore = types
setLoaded(value: boolean) {
self.loaded = value
},
+ setOnboarded(value: boolean) {
+ self.onboarded = value
+ },
}))
.actions(self => ({
checkMotionPermissions: (): Promise =>
@@ -65,21 +69,8 @@ export const PermissionStore = types
})
},
}))
- .views(self => ({
- get onboarded() {
- const {wocky} = getParent(self)
- return (
- wocky &&
- wocky.profile &&
- wocky.profile.clientData.onboarded &&
- // self.allowsAccelerometer &&
- self.allowsNotification
- )
- },
- }))
- .postProcessSnapshot(() => {
- // No need to persist this store
- return {}
+ .postProcessSnapshot(({onboarded}) => {
+ return {onboarded}
})
export interface IPermissionStore extends Instance {}
diff --git a/src/store/store.ts b/src/store/store.ts
index 1adf780ff..def968a80 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -34,6 +34,7 @@ import {autorun} from 'mobx'
import {settings} from '../globals'
import AsyncStorage from '@react-native-community/async-storage'
import deviceInfoFetch, {TRDeviceInfo} from 'src/utils/deviceInfoFetch'
+import _ from 'lodash'
const jsVersion = require('../../package.json').version
const auth = firebase.auth()
@@ -48,7 +49,7 @@ export type IEnv = {
deviceInfo: TRDeviceInfo
}
-const cleanState = {
+export const cleanState = {
firebaseStore: {},
authStore: {},
locationStore: {},
@@ -111,10 +112,11 @@ export interface IStore extends Instance {}
* Return only the mstStore data needed to prevent logout
* @param data - serialized mstStore object
*/
-function getMinimalStoreData(data?: {authStore: object}): object {
+function getMinimalStoreData(data?: {authStore: object; permissionStore: object}): object {
log('loadMinimal', data)
return {
- authStore: data && data.authStore ? data.authStore : {},
+ authStore: _.get(data, 'authStore', cleanState.authStore),
+ permissionStore: _.get(data, 'permissionStore', cleanState.permissionStore),
}
}
@@ -170,6 +172,7 @@ export async function createStore() {
} catch (err) {
log('hydration error', err, storeData)
mstStore = Store.create({...cleanState, ...getMinimalStoreData(storeData), appInfo}, env)
+ // mstStore = Store.create({...cleanState, appInfo}, env)
}
const requestPushPermissions = initializePushNotifications(mstStore.wocky.enablePush)
diff --git a/third-party/wocky-client/src/model/ClientData.ts b/third-party/wocky-client/src/model/ClientData.ts
index 9966637f7..abbade5d7 100644
--- a/third-party/wocky-client/src/model/ClientData.ts
+++ b/third-party/wocky-client/src/model/ClientData.ts
@@ -44,7 +44,6 @@ export const ClientData = types
mapOptions: types.optional(MapOptions, MapOptionsEnum.AUTO),
sharePresencePrimed: false,
guestOnce: false,
- onboarded: false,
hidden: types.optional(Hidden, {}),
})
.views(self => ({
@@ -74,7 +73,7 @@ export const ClientData = types
clear: () => {
applySnapshot(self, {})
},
- flip: (property: 'sharePresencePrimed' | 'guestOnce' | 'onboarded') => {
+ flip: (property: 'sharePresencePrimed' | 'guestOnce') => {
self[property] = true
self.persist()
},
diff --git a/third-party/wocky-client/src/model/OwnProfile.ts b/third-party/wocky-client/src/model/OwnProfile.ts
index 1b76aecfd..85abd1620 100644
--- a/third-party/wocky-client/src/model/OwnProfile.ts
+++ b/third-party/wocky-client/src/model/OwnProfile.ts
@@ -138,9 +138,6 @@ export const OwnProfile = types
}
})
.actions(self => ({
- setOnboarded: () => {
- self.clientData.flip('onboarded')
- },
load({
avatar,
blocked = [],