Skip to content
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

feat: add background task to flush SequentialQueue #51268

Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
</array>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>UIFileSharingEnabled</key>
Expand Down
18 changes: 18 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ PODS:
- ExpoModulesCore
- ExpoAsset (10.0.10):
- ExpoModulesCore
- ExpoBackgroundFetch (12.0.1):
- ExpoModulesCore
- ExpoImage (1.12.15):
- ExpoModulesCore
- libavif/libdav1d
Expand Down Expand Up @@ -73,6 +75,9 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- EXTaskManager (11.8.2):
- ExpoModulesCore
- UMAppLoader
- FBLazyVector (0.75.2)
- Firebase/Analytics (8.8.0):
- Firebase/Core
Expand Down Expand Up @@ -2695,6 +2700,7 @@ PODS:
- SDWebImage/Core (~> 5.17)
- SocketRocket (0.7.0)
- Turf (2.8.0)
- UMAppLoader (4.6.0)
- VisionCamera (4.0.0-beta.13):
- DoubleConversion
- glog
Expand Down Expand Up @@ -2727,9 +2733,11 @@ DEPENDENCIES:
- EXImageLoader (from `../node_modules/expo-image-loader/ios`)
- Expo (from `../node_modules/expo`)
- ExpoAsset (from `../node_modules/expo-asset/ios`)
- ExpoBackgroundFetch (from `../node_modules/expo-background-fetch/ios`)
- ExpoImage (from `../node_modules/expo-image/ios`)
- ExpoImageManipulator (from `../node_modules/expo-image-manipulator/ios`)
- ExpoModulesCore (from `../node_modules/expo-modules-core`)
- EXTaskManager (from `../node_modules/expo-task-manager/ios`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
- "FullStory (from `{:http=>\"https://ios-releases.fullstory.com/fullstory-1.52.0-xcframework.tar.gz\"}`)"
Expand Down Expand Up @@ -2838,6 +2846,7 @@ DEPENDENCIES:
- RNShare (from `../node_modules/react-native-share`)
- RNSound (from `../node_modules/react-native-sound`)
- RNSVG (from `../node_modules/react-native-svg`)
- UMAppLoader (from `../node_modules/unimodules-app-loader/ios`)
- VisionCamera (from `../node_modules/react-native-vision-camera`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

Expand Down Expand Up @@ -2897,12 +2906,16 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo"
ExpoAsset:
:path: "../node_modules/expo-asset/ios"
ExpoBackgroundFetch:
:path: "../node_modules/expo-background-fetch/ios"
ExpoImage:
:path: "../node_modules/expo-image/ios"
ExpoImageManipulator:
:path: "../node_modules/expo-image-manipulator/ios"
ExpoModulesCore:
:path: "../node_modules/expo-modules-core"
EXTaskManager:
:path: "../node_modules/expo-task-manager/ios"
FBLazyVector:
:path: "../node_modules/react-native/Libraries/FBLazyVector"
fmt:
Expand Down Expand Up @@ -3116,6 +3129,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-sound"
RNSVG:
:path: "../node_modules/react-native-svg"
UMAppLoader:
:path: "../node_modules/unimodules-app-loader/ios"
VisionCamera:
:path: "../node_modules/react-native-vision-camera"
Yoga:
Expand All @@ -3137,9 +3152,11 @@ SPEC CHECKSUMS:
EXImageLoader: ab589d67d6c5f2c33572afea9917304418566334
Expo: 4773e11951abd0f666f67023f0cb1d48c3e8a32b
ExpoAsset: 323700f291684f110fb55f0d4022a3362ea9f875
ExpoBackgroundFetch: a06c553ecaf0bade0acd691042d996b9ce926327
ExpoImage: f77df382153d716f332f974438a803c4527f60b0
ExpoImageManipulator: aea99205c66043a00a0af90e345395637b9902fa
ExpoModulesCore: 335282d855cc34fb5540e170204e729a51464bbb
EXTaskManager: 9c3520305c3aa1b4a12a7c6d1e3f85f2779c06e9
FBLazyVector: 38bb611218305c3bc61803e287b8a81c6f63b619
Firebase: 629510f1a9ddb235f3a7c5c8ceb23ba887f0f814
FirebaseABTesting: 10cbce8db9985ae2e3847ea44e9947dd18f94e10
Expand Down Expand Up @@ -3280,6 +3297,7 @@ SPEC CHECKSUMS:
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Turf: aa2ede4298009639d10db36aba1a7ebaad072a5e
UMAppLoader: f17a5ee8e85b536ace0fc254b447a37ed198d57e
VisionCamera: c6c8aa4b028501fc87644550fbc35a537d4da3fb
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8

Expand Down
28 changes: 28 additions & 0 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 @@ -111,6 +111,7 @@
"expensify-common": "2.0.106",
"expo": "51.0.31",
"expo-av": "14.0.7",
"expo-background-fetch": "^12.0.1",
"expo-image": "1.12.15",
"expo-image-manipulator": "12.0.5",
"fast-equals": "^4.0.3",
Expand Down Expand Up @@ -359,7 +360,6 @@
"expo": {
"autolinking": {
"exclude": [
"expo-constants",
szymonrybczak marked this conversation as resolved.
Show resolved Hide resolved
"expo-file-system",
"expo-font",
"@react-native-google-signin/google-signin",
Expand Down
4 changes: 4 additions & 0 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import PopoverReportActionContextMenu from './pages/home/report/ContextMenu/Popo
import * as ReportActionContextMenu from './pages/home/report/ContextMenu/ReportActionContextMenu';
import type {Route} from './ROUTES';
import ROUTES from './ROUTES';
import {registerBackgroundFetch} from './setup/backgroundTask';
import SplashScreenStateContext from './SplashScreenStateContext';
import type {ScreenShareRequest} from './types/onyx';

Expand Down Expand Up @@ -208,6 +209,9 @@ function Expensify() {
Report.openReportFromDeepLink(state.url);
});

// Register background fetch task to flush the SequentialQueue
registerBackgroundFetch();

return () => {
if (!appStateChangeListener.current) {
return;
Expand Down
19 changes: 19 additions & 0 deletions src/setup/backgroundTask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as BackgroundFetch from 'expo-background-fetch';
import {defineTask} from 'expo-task-manager';
import * as SequentialQueue from '@libs/Network/SequentialQueue';

const BACKGROUND_FETCH_TASK = 'FLUSH-SEQUENTIAL-QUEUE-BACKGROUND-FETCH';

defineTask(BACKGROUND_FETCH_TASK, () => {
SequentialQueue.flush();
});

function registerBackgroundFetch() {
return BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
minimumInterval: 60 * 15, // 15 minutes
stopOnTerminate: false,
startOnBoot: true,
});
}

export {BACKGROUND_FETCH_TASK, registerBackgroundFetch};
Loading