Skip to content

[PB-6681] change getUser to async - #2095

Merged
TamaraFinogina merged 15 commits into
masterfrom
get_user_async
Aug 20, 2026
Merged

[PB-6681] change getUser to async#2095
TamaraFinogina merged 15 commits into
masterfrom
get_user_async

Conversation

@TamaraFinogina

@TamaraFinogina TamaraFinogina commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

Makes getUser async and fully switches to the encrypted version of the user

Related Issues

Relates to PB-6681

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

Check that:

  1. Login works
  2. Sign up works
  3. Guest sign up works
  4. Sharing item with a non-user works (sharing with invitation)
  5. Inviting a non-user to a workspace works
  6. Download/upload of files and folders works
  7. Download of backup keys works
  8. Video streaming of a large video file works
  9. Purchasing plan works

Additional Notes

PR on top of another PR because together it's too many changes

@TamaraFinogina
TamaraFinogina requested review from a team, CandelR, larryrider and xabg2 as code owners August 4, 2026 15:06
@TamaraFinogina TamaraFinogina self-assigned this Aug 4, 2026
@TamaraFinogina
TamaraFinogina requested a review from sg-gs August 4, 2026 15:07
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6197f49
Status: ✅  Deploy successful!
Preview URL: https://03deb857.drive-web.pages.dev
Branch Preview URL: https://get-user-async.drive-web.pages.dev

View logs

sg-gs
sg-gs previously approved these changes Aug 4, 2026

@sg-gs sg-gs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Just reviewed the network part.

CandelR
CandelR previously requested changes Aug 7, 2026
Comment thread src/views/Login/OAuthLinkView.tsx Outdated
Comment on lines 31 to 37
}, [isUserLoaded, user]);

if (!isUserLoaded || !user) return <></>;

useEffect(() => {
if (!user) {
const params = urlParams.toString();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will crash, remember to test all that changes. no add hooks after conditional returns https://react.dev/warnings/invalid-hook-call-warning#breaking-rules-of-hooks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was dead code; removed it

Comment on lines +44 to +54
const initializeThunk = createAsyncThunk<void, undefined, { state: RootState }>(
'user/initialize',
async (_, { dispatch }) => {
const user = await encryptedStorageService.getUser();
if (user) {
dispatch(userActions.setUser(user));
}
dispatch(userActions.setIsUserInitialized(true));
},
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initializeThunk uses the same string ‘user/initialize’ as initializeUserThunk. As extraReducers are matched by action.type, the addCase(initializeUserThunk.pending/fulfilled/rejected, …) calls are also triggered when initializeThunk is executed in the bootstrap (index.tsx). If that fails, the error message is displayed and the user is redirected to /login for no real reason. Change the prefix of initializeThunk to something unique

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the prefix


const handleGoToLogin = () => {
dispatch(userThunks.logoutThunk());
authService.logOut();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the effect of this logout is the same as the userThunks logout?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I revert this change just to be safe

Comment on lines +104 to 111
let sessionRef: VideoStreamingSession | undefined;
setupStreaming().then((session) => {
sessionRef = session;
});

return () => {
session.destroy();
sessionRef?.destroy();
setCanPlay(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessionRef is assigned within the .then() of setupStreaming(). If the effect is cleared (video change, unmount) before that promise resolves, the cleanup runs whilst sessionRef is still undefined and .destroy() is never called, consequently, the streaming session becomes orphaned. A ‘cancelled’ flag is needed to destroy the session if it is terminated prematurely

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added canceled flag

@TamaraFinogina
TamaraFinogina requested a review from CandelR August 14, 2026 09:55
try {
metaService.trackPurchase();
gaService.trackPurchase();
await gaService.trackPurchase();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to await this call. Can be resolved later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the last line removePaymentsStorage(); cleans up payment storage and if trackPurchase puts data after that, it won't be cleaned, no?

Base automatically changed from set_user_async to master August 19, 2026 11:32
@TamaraFinogina
TamaraFinogina dismissed sg-gs’s stale review August 19, 2026 11:32

The base branch was changed.

@TamaraFinogina
TamaraFinogina requested review from sg-gs and xabg2 August 19, 2026 11:57
@sonarqubecloud

Copy link
Copy Markdown

@TamaraFinogina
TamaraFinogina dismissed CandelR’s stale review August 20, 2026 07:53

All comments are addressed; QA passed

@TamaraFinogina
TamaraFinogina merged commit 8c85af8 into master Aug 20, 2026
10 of 12 checks passed
@TamaraFinogina
TamaraFinogina deleted the get_user_async branch August 20, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants