Skip to content

Commit

Permalink
Merge pull request #34449 from dukenv0307/fix/34371
Browse files Browse the repository at this point in the history
[CP Staging] Only apply interaction for desktop
  • Loading branch information
mountiny authored Jan 15, 2024
2 parents 86794fe + 7ed7b59 commit 2c44394
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/libs/DoInteractionTask/index.desktop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {InteractionManager} from 'react-native';

// For desktop, we should call the callback after all interactions to prevent freezing. See more detail in https://github.com/Expensify/App/issues/28916
function doInteractionTask(callback: () => void) {
return InteractionManager.runAfterInteractions(() => {
callback();
});
}

export default doInteractionTask;
6 changes: 6 additions & 0 deletions src/libs/DoInteractionTask/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function doInteractionTask(callback: () => void) {
callback();
return null;
}

export default doInteractionTask;
12 changes: 9 additions & 3 deletions src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {InteractionManager, View} from 'react-native';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import KeyboardAvoidingView from '@components/KeyboardAvoidingView';
Expand All @@ -15,6 +15,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import compose from '@libs/compose';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import doInteractionTask from '@libs/DoInteractionTask';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as ReportUtils from '@libs/ReportUtils';
import variables from '@styles/variables';
Expand Down Expand Up @@ -209,11 +210,16 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i
}, [reports, personalDetails, searchTerm]);

useEffect(() => {
const interactionTask = InteractionManager.runAfterInteractions(() => {
const interactionTask = doInteractionTask(() => {
setDidScreenTransitionEnd(true);
});

return interactionTask.cancel;
return () => {
if (!interactionTask) {
return;
}
interactionTask.cancel();
};
}, []);

useEffect(() => {
Expand Down

0 comments on commit 2c44394

Please sign in to comment.