Skip to content

Commit 3c85bd5

Browse files
committed
Time goes forwards
1 parent 408407b commit 3c85bd5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/crypto/OlmDevice.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -581,25 +581,25 @@ OlmDevice.prototype.getSessionIdForDevice = async function(theirDeviceIdentityKe
581581
return null;
582582
}
583583
// Use the session that has most recently received a message
584-
let idxOfMin = 0;
584+
let idxOfBest = 0;
585585
for (let i = 1; i < sessionInfos.length; i++) {
586586
const thisSessInfo = sessionInfos[i];
587587
const thisLastReceived = thisSessInfo.lastReceivedMessageTs === undefined ?
588588
0 : thisSessInfo.lastReceivedMessageTs;
589589

590-
const minSessInfo = sessionInfos[idxOfMin];
591-
const minLastReceived = minSessInfo.lastReceivedMessageTs === undefined ?
592-
0 : minSessInfo.lastReceivedMessageTs;
590+
const bestSessInfo = sessionInfos[idxOfBest];
591+
const bestLastReceived = bestSessInfo.lastReceivedMessageTs === undefined ?
592+
0 : bestSessInfo.lastReceivedMessageTs;
593593
if (
594-
thisLastReceived < minLastReceived || (
595-
thisLastReceived === minLastReceived &&
596-
thisSessInfo.sessionId < minSessInfo.sessionId
594+
thisLastReceived > bestLastReceived || (
595+
thisLastReceived === bestLastReceived &&
596+
thisSessInfo.sessionId < bestSessInfo.sessionId
597597
)
598598
) {
599-
idxOfMin = i;
599+
idxOfBest = i;
600600
}
601601
}
602-
return sessionInfos[idxOfMin].sessionId;
602+
return sessionInfos[idxOfBest].sessionId;
603603
};
604604

605605
/**

0 commit comments

Comments
 (0)