expensify-common 2.0.127 → 2.0.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CONST.js +1 -1
- package/dist/ReportHistoryStore.d.ts +7 -0
- package/dist/ReportHistoryStore.js +20 -1
- package/package.json +1 -1
package/dist/CONST.js
CHANGED
|
@@ -393,7 +393,7 @@ const CONST = {
|
|
|
393
393
|
*
|
|
394
394
|
* @type RegExp
|
|
395
395
|
*/
|
|
396
|
-
EMOJI_RULE: /[\p{Extended_Pictographic}](\u200D[\p{Extended_Pictographic}]|[\u{1F3FB}-\u{1F3FF}]|[\u{E0020}-\u{E007F}]|\uFE0F|\u20E3)*|[\u{1F1E6}-\u{1F1FF}]{2}|[#*0-9]\uFE0F?\u20E3/gu,
|
|
396
|
+
EMOJI_RULE: /[\p{Extended_Pictographic}\uE000-\uF8FF\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}](\u200D[\p{Extended_Pictographic}]|[\u{1F3FB}-\u{1F3FF}]|[\u{E0020}-\u{E007F}]|\uFE0F|\u20E3)*|[\u{1F1E6}-\u{1F1FF}]{2}|[#*0-9]\uFE0F?\u20E3/gu,
|
|
397
397
|
/**
|
|
398
398
|
* Regex to match a piece of text or @here, needed for both shortMention and userMention
|
|
399
399
|
*/
|
|
@@ -35,6 +35,13 @@ export default class ReportHistoryStore {
|
|
|
35
35
|
* @param {Object[]} newHistory
|
|
36
36
|
*/
|
|
37
37
|
mergeHistoryByTimestamp(reportID: number, newHistory: Object[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Merges history items by reportActionID into the cache and creates it if it doesn't yet exist.
|
|
40
|
+
*
|
|
41
|
+
* @param {Number} reportID
|
|
42
|
+
* @param {Object[]} newHistory
|
|
43
|
+
*/
|
|
44
|
+
mergeHistoryByReportActionID(reportID: number, newHistory: Object[]): void;
|
|
38
45
|
/**
|
|
39
46
|
* Gets the history.
|
|
40
47
|
*
|
|
@@ -180,6 +180,25 @@ class ReportHistoryStore {
|
|
|
180
180
|
// Sort items in case they have become out of sync
|
|
181
181
|
this.cache[reportID] = newCache.sort((a, b) => b.reportActionTimestamp - a.reportActionTimestamp);
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Merges history items by reportActionID into the cache and creates it if it doesn't yet exist.
|
|
185
|
+
*
|
|
186
|
+
* @param {Number} reportID
|
|
187
|
+
* @param {Object[]} newHistory
|
|
188
|
+
*/
|
|
189
|
+
mergeHistoryByReportActionID(reportID, newHistory) {
|
|
190
|
+
if (newHistory.length === 0) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const newCache = newHistory.reverse().reduce((prev, curr) => {
|
|
194
|
+
if (!prev.some((item) => item.reportActionID === curr.reportActionID)) {
|
|
195
|
+
prev.unshift(curr);
|
|
196
|
+
}
|
|
197
|
+
return prev;
|
|
198
|
+
}, this.cache[reportID] || []);
|
|
199
|
+
// Sort items in case they have become out of sync
|
|
200
|
+
this.cache[reportID] = newCache.sort((a, b) => b.reportActionTimestamp - a.reportActionTimestamp);
|
|
201
|
+
}
|
|
183
202
|
/**
|
|
184
203
|
* Gets the history.
|
|
185
204
|
*
|
|
@@ -230,7 +249,7 @@ class ReportHistoryStore {
|
|
|
230
249
|
})
|
|
231
250
|
.done((recentHistory) => {
|
|
232
251
|
// Update history with new items fetched
|
|
233
|
-
this.
|
|
252
|
+
this.mergeHistoryByReportActionID(reportID, recentHistory);
|
|
234
253
|
// Return history for this report
|
|
235
254
|
promise.resolve(this.cache[reportID]);
|
|
236
255
|
})
|