fixed a logic error within lastConnectInfo

master
WolverinDEV 2021-06-11 12:10:38 +02:00
parent ebc5b178e0
commit 338212f84b
1 changed files with 15 additions and 14 deletions

View File

@ -479,29 +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 = store.index(targetType === "server-unique-id" ? "serverUniqueId" : "targetAddress").openCursor(target, "prev"); const cursor = await new Promise<IDBCursorWithValue | null>((resolve, reject) => {
while(true) { const cursor = store.index(targetType === "server-unique-id" ? "serverUniqueId" : "targetAddress").openCursor(target, "prev");;
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(!entry) { while(true) {
if(!cursor.value) {
return undefined; return undefined;
} }
if(entry.value.serverUniqueId === kUnknownHistoryServerUniqueId && onlySucceeded) { if(cursor.value.serverUniqueId === kUnknownHistoryServerUniqueId && onlySucceeded) {
cursor.continue();
continue; continue;
} }
return { return {
id: entry.value.id, id: cursor.value.id,
timestamp: entry.value.timestamp, timestamp: cursor.value.timestamp,
serverUniqueId: entry.value.serverUniqueId, serverUniqueId: cursor.value.serverUniqueId,
nickname: entry.value.nickname, nickname: cursor.value.nickname,
hashedPassword: entry.value.hashedPassword, hashedPassword: cursor.value.hashedPassword,
targetAddress: entry.value.targetAddress, targetAddress: cursor.value.targetAddress,
}; };
} }
} }