-
Notifications
You must be signed in to change notification settings - Fork 2.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
Automatically enable memory only keys when payload size of reconnectapp/openapp is too large #23831
Conversation
@arosiclair Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@tgolen Maybe you are on top of this already (sorry if so), but I think we're gonna want to add a test that if The original intention of the mode was that it would run before |
Thanks for spelling that out. I definitely didn't have that context, but it appears like this is already being handled:
|
It sounds like maybe I just need to update the testing instructions |
OK, I updated the tests and retested it. Thanks for noticing that! |
Bump for review @arosiclair |
Reviewer Checklist
Screenshots/VideosMobile Web - ChromeMobile Web - Safari |
LGTM though I'm still blocked on Android build issues so I can't test there atm |
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.
Couple small things, questions, overall - looks great
// Supports both the old format and the new format | ||
const onyxUpdates = _.isArray(responseData) ? responseData : responseData.onyxData; | ||
// If there is an OnyxUpdate for using memory only keys, enable them | ||
_.each(onyxUpdates, ({key, value}) => { |
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.
Nab - alternatively _.find() and stop iterating when we hit the key (probably marginal)
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.
Great idea
const memoryOnlyKeys = [ONYXKEYS.COLLECTION.REPORT, ONYXKEYS.COLLECTION.POLICY, ONYXKEYS.PERSONAL_DETAILS_LIST]; | ||
|
||
const enable = () => { | ||
console.debug('[MemoryOnlyKeys] enabled'); |
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.
Maybe this (and the one belwo) could be a Log.info()
? Could help show that someone enabled this mode if we are investigating server logs.
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.
That's a good idea
@@ -0,0 +1,12 @@ | |||
import * as MemoryOnlyKeys from '../MemoryOnlyKeys'; | |||
|
|||
const exposeGlobalMethods = () => { |
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 exposeGlobalMethods = () => { | |
const exposeGlobalMemoryOnlyKeysMethods = () => { |
}; | ||
}; | ||
|
||
export default exposeGlobalMethods; |
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.
export default exposeGlobalMethods; | |
export default exposeGlobalMemoryOnlyKeysMethods; |
/** | ||
* This is a no-op because the global methods will only work for web and desktop | ||
*/ | ||
const exposeGlobalMethods = () => {}; |
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 exposeGlobalMethods = () => {}; | |
const exposeGlobalMemoryOnlyKeysMethods = () => {}; |
*/ | ||
const exposeGlobalMethods = () => {}; | ||
|
||
export default exposeGlobalMethods; |
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.
export default exposeGlobalMethods; | |
export default exposeGlobalMemoryOnlyKeysMethods; |
src/libs/actions/User.js
Outdated
} | ||
|
||
MemoryOnlyKeys.enable(); | ||
}); |
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.
NAB, I thought maybe we were just sending these onyxUpdate
with this key via https? Is including the check here for Pusher updates sort of a future proofing?
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.
Yeah, you're right. This is a hold-over from my original testing/implementation but it doesn't need to be here and is a little confusing. I'll remove it.
Updated! |
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.
Android tests well 👍
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.
LGTM (but there's a lint issue to address)
Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
Updated! Sorry, all your reviews got dismissed. Next one to approve, please feel free to merge. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/tgolen in version: 1.3.56-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|
window.enableMemoryOnlyKeys = () => { | ||
MemoryOnlyKeys.enable(); | ||
}; | ||
window.disableMemoryOnlyKeys = () => { | ||
MemoryOnlyKeys.disable(); | ||
}; |
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.
What is it for? Hand-debugging via console, or what?
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're just adding typing for this part and I'm wondering if it's actually beneficial to expand the Window
interface, or maybe we don't need any typing for this if we don't intend to use it programmatically.
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.
Yes, it's a JS console thing. And no, it shouldn't really be used in the code anywhere. So I agree there is no point in getting crazy with the types for this.
cc @marcaaron
Details
This PR will listen for the server attempting to update the memory only keys feature. If there is an onyx update for that key, then the frontend will fully enable the feature.
Fixed Issues
Part of https://github.com/Expensify/Expensify/issues/300442
Tests
Note: this can only be fully tested by an internal engineering using the PR https://github.com/Expensify/Web-Expensify/pull/38491
Tests for anyone (web and desktop only)
enableMemoryOnlyKeys()
from the JS console[MemoryOnlyKeys] enabled
disableMemoryOnlyKeys()
from the JS console[MemoryOnlyKeys] disabled
Tests for an internal engineer (all platforms except mobile web)
MEMORYONLYKEYS_THRESHOLD
constant to be a negative number (like-1
)[MemoryOnlyKeys] enabled
report_
keys and nopolicy_
keys are savedOffline tests
None
QA Steps
You can perform the tests above in the
Tests for anyone (web and desktop only)
sectionPR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android