Skip to content

👤 simplify user profile updates; refactor push notif registration - #1210

Merged
JGreenlee merged 2 commits into
e-mission:masterfrom
JGreenlee:refactor-profile-push
Aug 4, 2025
Merged

👤 simplify user profile updates; refactor push notif registration#1210
JGreenlee merged 2 commits into
e-mission:masterfrom
JGreenlee:refactor-profile-push

Conversation

@JGreenlee

Copy link
Copy Markdown
Member

👤 simplify user profile updates; refactor push notif registration

Before this change, we would make 2 calls to profile/update every time the UI is initialized: one for push notification registration and another to store device settings.
We also had a lot of unecessary complexity in all these places (event listeners everywhere!)

All we really need to do on UI init, iff onboarding is done:

  1. call profile/get on the server to get the current user profile
  2. perform push notif registration
  3. get current device settings
  4. based on the results of the above, determine what fields need to be updated and call profile/update on server if needed

1, 2, and 3 can be executed in any order/ in parallel (with Promise.all / Promise.allSettled). Added a file userProfile to handle this.

The added benefit of this is that we have access to the value of the current profile. We can keep it as state in AppContext allowing it to be used anywhere in the UI (this can simplify how custom labels are retrieved + used; and it may be useful for users to know their "last synced ts", for example)
When the profile is updated from the UI, we have to keep the the local state in sync so instead of directly calling commHelper updateUser directly, we expose updateUserProfile from AppContext

In removing the complexity, I moved remoteNotifyHandler into pushNotifySettings

Updated tests for all changes


prevent duplicate updateAllUnprocessedInputs call

TimelineContext loadTimelineEntries retrieves the pipeline range, calls updateAllUnprocessedInputs for that range, and then sets the pipeline range as state via setPipelineRange.
Then in LabelTab, we have a useEffect: when pipelineRange changes, we call updateAllUnprocessedInputs (again!)
setPipelineRange is not called from anywhere else, meaning that this duplicate scenario is the time this useEffect gets called. We can remove it.

tested recording new labels, refreshing the page, and changing to different dates, and labels still get matched properly

@codecov

codecov Bot commented Aug 1, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.80952% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.10%. Comparing base (d34f263) to head (9982d14).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
www/js/splash/pushNotifySettings.ts 76.47% 16 Missing ⚠️
www/js/App.tsx 0.00% 7 Missing ⚠️
www/js/control/EditSyncConfigModal.tsx 0.00% 4 Missing ⚠️
www/js/onboarding/onboardingHelper.ts 0.00% 3 Missing ⚠️
www/js/control/ProfileSettings.tsx 0.00% 1 Missing ⚠️
www/js/splash/storeDeviceSettings.ts 80.00% 1 Missing ⚠️
www/js/usePermissionStatus.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1210      +/-   ##
==========================================
- Coverage   31.67%   31.10%   -0.58%     
==========================================
  Files         124      125       +1     
  Lines        4792     4816      +24     
  Branches     1132     1147      +15     
==========================================
- Hits         1518     1498      -20     
- Misses       3272     3308      +36     
- Partials        2       10       +8     
Flag Coverage Δ
unit 31.10% <73.80%> (-0.58%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
www/js/TimelineContext.ts 53.29% <100.00%> (+0.28%) ⬆️
www/js/diary/LabelTab.tsx 0.00% <ø> (ø)
www/js/diary/timelineHelper.ts 91.02% <100.00%> (+0.03%) ⬆️
www/js/splash/notifScheduler.ts 98.37% <100.00%> (ø)
www/js/splash/startprefs.ts 95.34% <100.00%> (-0.40%) ⬇️
www/js/splash/userProfile.ts 100.00% <100.00%> (ø)
www/js/control/ProfileSettings.tsx 0.00% <0.00%> (ø)
www/js/splash/storeDeviceSettings.ts 80.00% <80.00%> (-13.75%) ⬇️
www/js/usePermissionStatus.ts 0.00% <0.00%> (ø)
www/js/onboarding/onboardingHelper.ts 0.00% <0.00%> (-41.03%) ⬇️
... and 3 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Before this change, we would make 2 calls to `profile/update` every time the UI is initialized: one for push notification registration and another to store device settings.
We also had a lot of unecessary complexity in all these places (event listeners everywhere!)

All we really need to do on UI init, iff onboarding is done:
1. call `profile/get` on the server to get the current user profile
2. perform push notif registration
3. get current device settings
4. based on the results of the above, determine what fields need to be updated and call `profile/update` on server if needed

1, 2, and 3 can be executed in any order/ in parallel (with Promise.all / Promise.allSettled). Added a file userProfile to handle this.

The added benefit of this is that we have access to the value of the current profile. We can keep it as state in AppContext allowing it to be used anywhere in the UI (this can simplify how custom labels are retrieved + used; and it may be useful for users to know their "last synced ts", for example)
When the profile is updated from the UI, we have to keep the the local state in sync so instead of directly calling commHelper updateUser directly, we expose `updateUserProfile` from AppContext

In removing the complexity, I moved remoteNotifyHandler into pushNotifySettings

Updated tests for all changes
TimelineContext loadTimelineEntries retrieves the pipeline range, calls updateAllUnprocessedInputs for that range, and then sets the pipeline range as state via setPipelineRange.
Then in LabelTab, we have a useEffect: when pipelineRange changes, we call updateAllUnprocessedInputs (again!)
setPipelineRange is not called from anywhere else, meaning that this duplicate scenario is the time this useEffect gets called. We can remove it.

tested recording new labels, refreshing the page, and changing to different dates, and labels still get matched properly
@JGreenlee
JGreenlee force-pushed the refactor-profile-push branch from 0ce83af to 9982d14 Compare August 4, 2025 15:22
@JGreenlee
JGreenlee merged commit e57a5ee into e-mission:master Aug 4, 2025
4 checks passed
@github-project-automation github-project-automation Bot moved this to Tasks completed in OpenPATH Tasks Overview Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Tasks completed

Development

Successfully merging this pull request may close these issues.

1 participant