mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
Add login launch data (#174)
* added launch time data to CipherView for autofill * removed unused code * fixed linter errors
This commit is contained in:
@@ -445,11 +445,15 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
|
||||
async getLastUsedForUrl(url: string): Promise<CipherView> {
|
||||
return this.getCipherForUrl(url, true);
|
||||
return this.getCipherForUrl(url, true, false);
|
||||
}
|
||||
|
||||
async getLastLaunchedForUrl(url: string): Promise<CipherView> {
|
||||
return this.getCipherForUrl(url, false, true);
|
||||
}
|
||||
|
||||
async getNextCipherForUrl(url: string): Promise<CipherView> {
|
||||
return this.getCipherForUrl(url, false);
|
||||
return this.getCipherForUrl(url, false, false);
|
||||
}
|
||||
|
||||
async updateLastUsedDate(id: string): Promise<void> {
|
||||
@@ -481,6 +485,35 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
async updateLastLaunchedDate(id: string): Promise<void> {
|
||||
let ciphersLocalData = await this.storageService.get<any>(Keys.localData);
|
||||
if (!ciphersLocalData) {
|
||||
ciphersLocalData = {};
|
||||
}
|
||||
|
||||
if (ciphersLocalData[id]) {
|
||||
ciphersLocalData[id].lastLaunched = new Date().getTime();
|
||||
} else {
|
||||
ciphersLocalData[id] = {
|
||||
lastUsedDate: new Date().getTime(),
|
||||
};
|
||||
}
|
||||
|
||||
await this.storageService.save(Keys.localData, ciphersLocalData);
|
||||
|
||||
if (this.decryptedCipherCache == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.decryptedCipherCache.length; i++) {
|
||||
const cached = this.decryptedCipherCache[i];
|
||||
if (cached.id === id) {
|
||||
cached.localData = ciphersLocalData[id];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async saveNeverDomain(domain: string): Promise<void> {
|
||||
if (domain == null) {
|
||||
return;
|
||||
@@ -1009,7 +1042,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
private async getCipherForUrl(url: string, lastUsed: boolean): Promise<CipherView> {
|
||||
private async getCipherForUrl(url: string, lastUsed: boolean, lastLaunched: boolean): Promise<CipherView> {
|
||||
if (!this.sortedCiphersCache.isCached(url)) {
|
||||
const ciphers = await this.getAllDecryptedForUrl(url);
|
||||
if (!ciphers) {
|
||||
@@ -1018,6 +1051,13 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
this.sortedCiphersCache.addCiphers(url, ciphers);
|
||||
}
|
||||
|
||||
return lastUsed ? this.sortedCiphersCache.getLastUsed(url) : this.sortedCiphersCache.getNext(url);
|
||||
if (lastLaunched) {
|
||||
return this.sortedCiphersCache.getLastLaunched(url);
|
||||
} else if (lastUsed) {
|
||||
return this.sortedCiphersCache.getLastUsed(url);
|
||||
}
|
||||
else {
|
||||
return this.sortedCiphersCache.getNext(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user