-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First pass at a session handler #1850
Conversation
src/state/persisted/legacy.ts
Outdated
@@ -35,7 +35,7 @@ type LegacySchema = { | |||
description: string | |||
avatar: string | |||
} | |||
onboarding: { | |||
onboarding?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration was failing bc we've removed these mobx models now. We should be careful going forward to make sure we can resume from a partial migration. So far so good, and in the next release with these changes, it will be a full migration, so probably not a big deal...
// displayName: z.string().optional(), | ||
// aviUrl: z.string().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking that anything NOT returned from session response should be loaded with RQ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to have this information in logged out screens and in the account selector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can fetch every time
handle: z.string().optional(), | ||
displayName: z.string().optional(), | ||
aviUrl: z.string().optional(), | ||
handle: z.string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle is returned from session, and the resumeSession method actually requires it in types but still works without it
const next = persisted.get('onboarding').step | ||
// TODO we've introduced a footgun | ||
if (state.step !== next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe this was cyclically updating in the background. Wonder if we can protect against this better at a higher level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mm that was on me, I think the only way to solve it is to avoid fires in response to this event -- the type: set
needs a silent: true
param
src/view/com/auth/login/Login.tsx
Outdated
await login({ | ||
service: serviceUrl, | ||
identifier: fullIdent, | ||
password, | ||
}) | ||
await store.session.login({ | ||
service: serviceUrl, | ||
identifier: fullIdent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just dual-booting rn
@@ -303,10 +307,11 @@ export const SettingsScreen = withAuthRequired( | |||
accessibilityLabel={`Switch to ${account.handle}`} | |||
accessibilityHint="Switches the account you are logged in to"> | |||
<View style={styles.avi}> | |||
<UserAvatar size={40} avatar={account.aviUrl} /> | |||
{/*<UserAvatar size={40} avatar={account.aviUrl} />*/} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to get RQ in here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking like the right approach to me
// displayName: z.string().optional(), | ||
// aviUrl: z.string().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to have this information in logged out screens and in the account selector
[upsertAccount], | ||
) | ||
|
||
const logout = React.useCallback<ApiContext['logout']>(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should send the delete session request, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a method like this? I don't see one. Atm no, we just clear the tokens from memory and storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const next = persisted.get('onboarding').step | ||
// TODO we've introduced a footgun | ||
if (state.step !== next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mm that was on me, I think the only way to solve it is to avoid fires in response to this event -- the type: set
needs a silent: true
param
// displayName: z.string().optional(), | ||
// aviUrl: z.string().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can fetch every time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems good overall
) | ||
|
||
React.useEffect(() => { | ||
persisted.write('session', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note you probably don't want to do this after first render. So maybe:
- Keep a wrapper that sets a dirty flag in a ref
- In the Effect, if the dirty flag is true, persist and unset the flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to go ahead and merge so others can build off this. More will come in followup PRs. Good work @estrattonbailey
No description provided.