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

Make API.read wait on all requests on the SequentialQueue to respond #12219

Merged
merged 27 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0bc6d78
call process/finally before makeRequestWithSideEffects
jasperhuangg Oct 28, 2022
99aa8e8
whitespace
jasperhuangg Oct 28, 2022
2b4577d
Merge branch 'main' of github.com:Expensify/App into jasper-readPromi…
jasperhuangg Oct 31, 2022
dca802b
wip
jasperhuangg Oct 31, 2022
38553d8
wip, almost working
jasperhuangg Oct 31, 2022
826e2ea
working!
jasperhuangg Oct 31, 2022
a7bd2b8
remove unused and fix style
jasperhuangg Oct 31, 2022
e84e2f5
whitespace
jasperhuangg Oct 31, 2022
8e0453d
remove unused
jasperhuangg Oct 31, 2022
6de781d
only use the isDonePromise if the SequentialQueue is running
jasperhuangg Oct 31, 2022
4714865
fix early return to be more readable
jasperhuangg Oct 31, 2022
e03b3ee
whitespace
jasperhuangg Oct 31, 2022
0052403
remove unused
jasperhuangg Oct 31, 2022
417e5fe
use single promise
jasperhuangg Nov 2, 2022
43e7635
use single promise
jasperhuangg Nov 2, 2022
306185f
remove unused
jasperhuangg Nov 2, 2022
f3f69ad
comment
jasperhuangg Nov 2, 2022
7bc24e0
Merge branch 'main' of github.com:Expensify/App into jasper-readPromi…
jasperhuangg Nov 2, 2022
132add7
rename function
jasperhuangg Nov 3, 2022
4c48dbf
directly use promise
jasperhuangg Nov 3, 2022
0984812
revert unneeded
jasperhuangg Nov 3, 2022
42e2912
Delete WorkspaceSettings.xcsettings
jasperhuangg Nov 3, 2022
2cb1fa6
Delete contents.xcworkspacedata
jasperhuangg Nov 3, 2022
c653d1a
make comment more succinct
jasperhuangg Nov 3, 2022
a7e3e6c
Merge branch 'jasper-readPromiseSeqQueue' of github.com:Expensify/App…
jasperhuangg Nov 3, 2022
0885f91
Update src/libs/Network/SequentialQueue.js
jasperhuangg Nov 3, 2022
a656dae
Merge branch 'main' of github.com:Expensify/App into jasper-readPromi…
jasperhuangg Nov 3, 2022
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
2 changes: 1 addition & 1 deletion src/libs/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function makeRequestWithSideEffects(command, apiCommandParameters = {}, onyxData
* @param {Object} [onyxData.failureData] - Onyx instructions that will be passed to Onyx.update() when the response has jsonCode !== 200.
*/
function read(command, apiCommandParameters, onyxData) {
makeRequestWithSideEffects(command, apiCommandParameters, onyxData, CONST.API_REQUEST_TYPE.READ);
SequentialQueue.getIsReadyPromise().then(() => makeRequestWithSideEffects(command, apiCommandParameters, onyxData, CONST.API_REQUEST_TYPE.READ));
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
}

export {
Expand Down
12 changes: 12 additions & 0 deletions src/libs/Network/SequentialQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,21 @@ function getCurrentRequest() {
return currentRequest;
}

/**
* Returns a promise that resolves when the last request on the queue responds.
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
* @returns {Promise}
*/
function getIsReadyPromise() {
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
if (!isSequentialQueueRunning) {
return Promise.resolve();
}
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
return isReadyPromise;
}

export {
flush,
getCurrentRequest,
isRunning,
push,
getIsReadyPromise,
};