Skip to content

Commit

Permalink
Merge branch 'main' into fix/54035-invoice-thread-isn't-removed-when-…
Browse files Browse the repository at this point in the history
…dismissing-create-error
  • Loading branch information
bernhardoj committed Dec 17, 2024
2 parents ffbd184 f69d05b commit f3917b7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 1722,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-keyboard-controller (1.14.4):
- react-native-keyboard-controller (1.15.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -3242,7 3242,7 @@ SPEC CHECKSUMS:
react-native-geolocation: b9bd12beaf0ebca61a01514517ca8455bd26fa06
react-native-image-picker: f8a13ff106bcc7eb00c71ce11fdc36aac2a44440
react-native-key-command: aae312752fcdfaa2240be9a015fc41ce54087546
react-native-keyboard-controller: 97bb7b48fa427c7455afdc8870c2978efd9bfa3a
react-native-keyboard-controller: 3428e4761623fd6a242d9bf3573112f8ebe92238
react-native-launch-arguments: 5f41e0abf88a15e3c5309b8875d6fd5ac43df49d
react-native-netinfo: fb5112b1fa754975485884ae85a3fb6a684f49d5
react-native-pager-view: abc5ef92699233eb726442c7f452cac82f73d0cb
Expand Down
8 changes: 4 additions & 4 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 @@ -154,7 154,7 @@
"react-native-image-picker": "^7.0.3",
"react-native-image-size": "git https://github.com/Expensify/react-native-image-size#cb392140db4953a283590d7cf93b4d0461baa2a9",
"react-native-key-command": "^1.0.8",
"react-native-keyboard-controller": "1.14.4",
"react-native-keyboard-controller": "1.15.0",
"react-native-launch-arguments": "^4.0.2",
"react-native-localize": "^2.2.6",
"react-native-modal": "^13.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardAvoidingView/index.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 2,8 @@
* The KeyboardAvoidingView is only used on ios
*/
import React from 'react';
import type {KeyboardAvoidingViewProps} from 'react-native-keyboard-controller';
import {KeyboardAvoidingView as KeyboardAvoidingViewComponent} from 'react-native-keyboard-controller';
import type {KeyboardAvoidingViewProps} from './types';

function KeyboardAvoidingView(props: KeyboardAvoidingViewProps) {
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down
21 changes: 21 additions & 0 deletions src/hooks/useRestoreInputFocus.ts
Original file line number Diff line number Diff line change
@@ -0,0 1,21 @@
import {useEffect, useRef} from 'react';
import {InteractionManager, Keyboard} from 'react-native';
import {KeyboardController} from 'react-native-keyboard-controller';

const useRestoreInputFocus = (isLostFocus: boolean) => {
const keyboardVisibleBeforeLoosingFocusRef = useRef(false);

useEffect(() => {
if (isLostFocus) {
keyboardVisibleBeforeLoosingFocusRef.current = Keyboard.isVisible();
}

if (!isLostFocus && keyboardVisibleBeforeLoosingFocusRef.current) {
InteractionManager.runAfterInteractions(() => {
KeyboardController.setFocusTo('current');
});
}
}, [isLostFocus]);
};

export default useRestoreInputFocus;
20 changes: 12 additions & 8 deletions src/libs/Pusher/pusher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 70,14 @@ Onyx.connect({
});

let socket: PusherWithAuthParams | null;
let pusherSocketID = '';
let pusherSocketID: string | undefined;
const socketEventCallbacks: SocketEventCallback[] = [];
let customAuthorizer: ChannelAuthorizerGenerator;

let initPromise: Promise<void>;
let resolveInitPromise: () => void;
let initPromise = new Promise<void>((resolve) => {
resolveInitPromise = resolve;
});

const eventsBoundToChannels = new Map<Channel, Set<PusherEventName>>();

Expand All @@ -90,7 93,7 @@ function callSocketEventCallbacks(eventName: SocketEventName, data?: EventCallba
* @returns resolves when Pusher has connected
*/
function init(args: Args, params?: unknown): Promise<void> {
initPromise = new Promise((resolve) => {
return new Promise<void>((resolve) => {
if (socket) {
resolve();
return;
Expand Down Expand Up @@ -129,7 132,7 @@ function init(args: Args, params?: unknown): Promise<void> {
});

socket?.connection.bind('connected', () => {
pusherSocketID = socket?.connection.socket_id ?? '';
pusherSocketID = socket?.connection.socket_id;
callSocketEventCallbacks('connected');
resolve();
});
Expand All @@ -141,9 144,7 @@ function init(args: Args, params?: unknown): Promise<void> {
socket?.connection.bind('state_change', (states: States) => {
callSocketEventCallbacks('state_change', states);
});
});

return initPromise;
}).then(resolveInitPromise);
}

/**
Expand Down Expand Up @@ -394,6 395,9 @@ function disconnect() {
socket.disconnect();
socket = null;
pusherSocketID = '';
initPromise = new Promise((resolve) => {
resolveInitPromise = resolve;
});
}

/**
Expand All @@ -410,7 414,7 @@ function reconnect() {
socket.connect();
}

function getPusherSocketID(): string {
function getPusherSocketID(): string | undefined {
return pusherSocketID;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 16,7 @@ import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePaginatedReportActions from '@hooks/usePaginatedReportActions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useRestoreInputFocus from '@hooks/useRestoreInputFocus';
import useStyleUtils from '@hooks/useStyleUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
Expand Down Expand Up @@ -268,6 269,7 @@ function BaseReportActionContextMenu({
},
{isActive: shouldEnableArrowNavigation && shouldEnableContextMenuEnterShortcut, shouldPreventDefault: false},
);
useRestoreInputFocus(isVisible);

const openOverflowMenu = (event: GestureResponderEvent | MouseEvent, anchorRef: MutableRefObject<View | null>) => {
showContextMenu(
Expand Down

0 comments on commit f3917b7

Please sign in to comment.