Fixed invalid cursor iteration within the connection history
parent
253f537bb2
commit
7601ac2e07
|
@ -479,35 +479,30 @@ export class ConnectionHistory {
|
||||||
const transaction = this.database.transaction(["attempt-history"], "readonly");
|
const transaction = this.database.transaction(["attempt-history"], "readonly");
|
||||||
const store = transaction.objectStore("attempt-history");
|
const store = transaction.objectStore("attempt-history");
|
||||||
|
|
||||||
const cursor = await new Promise<IDBCursorWithValue | null>((resolve, reject) => {
|
|
||||||
const cursor = store.index(targetType === "server-unique-id" ? "serverUniqueId" : "targetAddress").openCursor(target, "prev");
|
const cursor = store.index(targetType === "server-unique-id" ? "serverUniqueId" : "targetAddress").openCursor(target, "prev");
|
||||||
|
while(true) {
|
||||||
|
const entry = await new Promise<IDBCursorWithValue | null>((resolve, reject) => {
|
||||||
cursor.onsuccess = () => resolve(cursor.result);
|
cursor.onsuccess = () => resolve(cursor.result);
|
||||||
cursor.onerror = () => reject(cursor.error);
|
cursor.onerror = () => reject(cursor.error);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!cursor) {
|
if(!entry) {
|
||||||
/* We did not find any entry */
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(true) {
|
if(entry.value.serverUniqueId === kUnknownHistoryServerUniqueId && onlySucceeded) {
|
||||||
if(!cursor.value) {
|
entry.continue();
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cursor.value.serverUniqueId === kUnknownHistoryServerUniqueId && onlySucceeded) {
|
|
||||||
cursor.continue();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: cursor.value.id,
|
id: entry.value.id,
|
||||||
timestamp: cursor.value.timestamp,
|
timestamp: entry.value.timestamp,
|
||||||
serverUniqueId: cursor.value.serverUniqueId,
|
serverUniqueId: entry.value.serverUniqueId,
|
||||||
|
|
||||||
nickname: cursor.value.nickname,
|
nickname: entry.value.nickname,
|
||||||
hashedPassword: cursor.value.hashedPassword,
|
hashedPassword: entry.value.hashedPassword,
|
||||||
targetAddress: cursor.value.targetAddress,
|
targetAddress: entry.value.targetAddress,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue