Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"react-native-key-command": "^1.0.1",
"react-native-localize": "^2.2.6",
"react-native-modal": "^13.0.0",
"react-native-onyx": "1.0.43",
"react-native-onyx": "1.0.50",
"react-native-pdf": "^6.6.2",
"react-native-performance": "^4.0.0",
"react-native-permissions": "^3.0.1",
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,7 @@ export default {

// Report ID of the last report the user viewed as anonymous user
LAST_OPENED_PUBLIC_ROOM_ID: 'lastOpenedPublicRoomID',

// Experimental memory only Onyx mode flag
IS_USING_MEMORY_ONLY_KEYS: 'isUsingMemoryOnlyKeys',
};
12 changes: 11 additions & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ const propTypes = {
/** The report ID of the last opened public room as anonymous user */
lastOpenedPublicRoomID: PropTypes.string,

/** Opt-in experimental mode that prevents certain Onyx keys from persisting to disk */
isUsingMemoryOnlyKeys: PropTypes.bool,

...windowDimensionsPropTypes,
};

const defaultProps = {
isUsingMemoryOnlyKeys: false,
session: {
email: null,
},
Expand Down Expand Up @@ -122,7 +126,10 @@ class AuthScreens extends React.Component {

// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
if (SessionUtils.didUserLogInDuringSession()) {
// Note: If a Guide has enabled the memory only key mode then we do want to run OpenApp as their app will not be rehydrated with
// the correct state on refresh. They are explicitly opting out of storing data they would need (i.e. reports_) to take advantage of
// the optimizations performed during ReconnectApp.
if (this.props.isUsingMemoryOnlyKeys || SessionUtils.didUserLogInDuringSession()) {
App.openApp();
} else {
App.reconnectApp();
Expand Down Expand Up @@ -308,5 +315,8 @@ export default compose(
lastOpenedPublicRoomID: {
key: ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID,
},
isUsingMemoryOnlyKeys: {
key: ONYXKEYS.IS_USING_MEMORY_ONLY_KEYS,
},
}),
)(AuthScreens);
13 changes: 13 additions & 0 deletions src/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ export default function () {
},
});

// When enabled we will skip persisting to disk any server-side downloaded objects (e.g. workspaces, chats, etc) that can hog up a user's resources.
window.enableMemoryOnlyKeys = () => {
// eslint-disable-next-line rulesdir/prefer-actions-set-data
Onyx.set(ONYXKEYS.IS_USING_MEMORY_ONLY_KEYS, true);
Onyx.setMemoryOnlyKeys([ONYXKEYS.COLLECTION.REPORT, ONYXKEYS.COLLECTION.POLICY, ONYXKEYS.PERSONAL_DETAILS_LIST]);
};

window.disableMemoryOnlyKeys = () => {
// eslint-disable-next-line rulesdir/prefer-actions-set-data
Onyx.set(ONYXKEYS.IS_USING_MEMORY_ONLY_KEYS, false);
Onyx.setMemoryOnlyKeys([]);
};

Device.setDeviceID();

// Force app layout to work left to right because our design does not currently support devices using this mode
Expand Down