mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
return only eventId from findFirstOrLastOccurringEventId
This commit is contained in:
parent
7852f31f7e
commit
c9aaa18151
@ -162,7 +162,7 @@ export default class TimelineEventStore {
|
|||||||
* @param {string[]} eventIds
|
* @param {string[]} eventIds
|
||||||
* @return {Function<Promise>}
|
* @return {Function<Promise>}
|
||||||
*/
|
*/
|
||||||
// performance comment from above refers to the fact that their *might*
|
// performance comment from above refers to the fact that there *might*
|
||||||
// be a correlation between event_id sorting order and chronology.
|
// be a correlation between event_id sorting order and chronology.
|
||||||
// In that case we could avoid running over all eventIds, as the reported order by findExistingKeys
|
// In that case we could avoid running over all eventIds, as the reported order by findExistingKeys
|
||||||
// would match the order of eventIds. That's why findLast is also passed as backwards to keysExist.
|
// would match the order of eventIds. That's why findLast is also passed as backwards to keysExist.
|
||||||
@ -171,7 +171,7 @@ export default class TimelineEventStore {
|
|||||||
const byEventId = this._timelineStore.index("byEventId");
|
const byEventId = this._timelineStore.index("byEventId");
|
||||||
const keys = eventIds.map(eventId => [roomId, eventId]);
|
const keys = eventIds.map(eventId => [roomId, eventId]);
|
||||||
const results = new Array(keys.length);
|
const results = new Array(keys.length);
|
||||||
let firstFoundEventId;
|
let firstFoundKey;
|
||||||
|
|
||||||
// find first result that is found and has no undefined results before it
|
// find first result that is found and has no undefined results before it
|
||||||
function firstFoundAndPrecedingResolved() {
|
function firstFoundAndPrecedingResolved() {
|
||||||
@ -189,11 +189,11 @@ export default class TimelineEventStore {
|
|||||||
await byEventId.findExistingKeys(keys, findLast, (key, found) => {
|
await byEventId.findExistingKeys(keys, findLast, (key, found) => {
|
||||||
const index = keys.indexOf(key);
|
const index = keys.indexOf(key);
|
||||||
results[index] = found;
|
results[index] = found;
|
||||||
firstFoundEventId = firstFoundAndPrecedingResolved();
|
firstFoundKey = firstFoundAndPrecedingResolved();
|
||||||
return !!firstFoundEventId;
|
return !!firstFoundKey;
|
||||||
});
|
});
|
||||||
|
// key of index is [roomId, eventId], so pick out eventId
|
||||||
return firstFoundEventId;
|
return firstFoundKey && firstFoundKey[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inserts a new entry into the store. The combination of roomId and eventKey should not exist yet, or an error is thrown.
|
/** Inserts a new entry into the store. The combination of roomId and eventKey should not exist yet, or an error is thrown.
|
||||||
|
Loading…
Reference in New Issue
Block a user