Skip to content

Commit

Permalink
Merge pull request #3161 from Expensify/main
Browse files Browse the repository at this point in the history
  • Loading branch information
OSBotify authored May 26, 2021
2 parents 23c56a3 + e0881ce commit b04131e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001005402
versionName "1.0.54-2"
versionCode 1001005403
versionName "1.0.54-3"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCash/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.0.54.2</string>
<string>1.0.54.3</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCashTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.54.2</string>
<string>1.0.54.3</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion 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
@@ -1,6 +1,6 @@
{
"name": "expensify.cash",
"version": "1.0.54-2",
"version": "1.0.54-3",
"author": "Expensify, Inc.",
"homepage": "https://expensify.cash",
"description": "Expensify.cash is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
14 changes: 12 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Timing from './Timing';
import * as API from '../API';
import CONST from '../../CONST';
import Log from '../Log';
import {isReportMessageAttachment} from '../reportUtils';
import {isReportMessageAttachment, sortReportsByLastVisited} from '../reportUtils';
import Timers from '../Timers';
import {dangerouslyGetReportActionsMaxSequenceNumber, isReportMissingActions} from './ReportActions';

Expand Down Expand Up @@ -919,10 +919,20 @@ function fetchAllReports(
// content and improve chat switching experience by only downloading content we don't have yet.
// This improves performance significantly when reconnecting by limiting API requests and unnecessary
// data processing by Onyx.
const reportIDsToFetchActions = _.filter(returnedReportIDs, id => (
const reportIDsWithMissingActions = _.filter(returnedReportIDs, id => (
isReportMissingActions(id, reportMaxSequenceNumbers[id])
));

// Once we have the reports that are missing actions we will find the intersection between the most
// recently accessed reports and reports missing actions. Then we'll fetch the history for a small
// set to avoid making too many network requests at once.
const reportIDsToFetchActions = _.chain(sortReportsByLastVisited(allReports))
.map(report => report.reportID)
.reverse()
.intersection(reportIDsWithMissingActions)
.slice(0, 10)
.value();

if (_.isEmpty(reportIDsToFetchActions)) {
console.debug('[Report] Local reportActions up to date. Not fetching additional actions.');
return;
Expand Down
20 changes: 15 additions & 5 deletions src/libs/reportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,32 @@ function isReportMessageAttachment(reportMessageText) {
}

/**
* Given a collection of reports returns the most recently accessed one
* Given a collection of reports returns them sorted by last visited
*
* @param {Record<String, {lastVisitedTimestamp, reportID}>|Array<{lastVisitedTimestamp, reportID}>} reports
* @returns {Object}
* @param {Object} reports
* @returns {Array}
*/
function findLastAccessedReport(reports) {
function sortReportsByLastVisited(reports) {
return _.chain(reports)
.toArray()
.filter(report => report && report.reportID)
.sortBy('lastVisitedTimestamp')
.last()
.value();
}

/**
* Given a collection of reports returns the most recently accessed one
*
* @param {Record<String, {lastVisitedTimestamp, reportID}>|Array<{lastVisitedTimestamp, reportID}>} reports
* @returns {Object}
*/
function findLastAccessedReport(reports) {
return _.last(sortReportsByLastVisited(reports));
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
findLastAccessedReport,
sortReportsByLastVisited,
};

0 comments on commit b04131e

Please sign in to comment.