Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit aa2b7c2

Browse files
committed
Prefer favourite ciphers over last used / name
1 parent 8d528c2 commit aa2b7c2

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

apps/browser/src/vault/popup/components/vault/current-tab.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
292292
});
293293

294294
this.loginCiphers = this.loginCiphers.sort((a, b) =>
295-
this.cipherService.sortCiphersByLastUsedThenName(a, b),
295+
this.cipherService.sortCiphersByFavouriteThenLastUsedThenName(a, b),
296296
);
297297
this.isLoading = this.loaded = true;
298298
}

apps/browser/src/vault/popup/components/vault/vault-filter.component.ts

+6
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
219219
this.ciphers = this.ciphers.filter(
220220
(c) => !this.vaultFilterService.filterCipherForSelectedVault(c),
221221
);
222+
this.ciphers = this.ciphers.sort((a, b) =>
223+
this.cipherService.sortCiphersByFavouriteThenLastUsedThenName(a, b),
224+
);
222225
return;
223226
}
224227
this.searchPending = true;
@@ -236,6 +239,9 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
236239
this.ciphers = this.ciphers.filter(
237240
(c) => !this.vaultFilterService.filterCipherForSelectedVault(c),
238241
);
242+
this.ciphers = this.ciphers.sort((a, b) =>
243+
this.cipherService.sortCiphersByFavouriteThenLastUsedThenName(a, b),
244+
);
239245
this.searchPending = false;
240246
}, timeout);
241247
}

libs/common/src/vault/abstractions/cipher.service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export abstract class CipherService {
7474
deleteAttachmentWithServer: (id: string, attachmentId: string) => Promise<void>;
7575
sortCiphersByLastUsed: (a: CipherView, b: CipherView) => number;
7676
sortCiphersByLastUsedThenName: (a: CipherView, b: CipherView) => number;
77+
sortCiphersByFavouriteThenLastUsedThenName: (a: CipherView, b: CipherView) => number;
7778
getLocaleSortingFunction: () => (a: CipherView, b: CipherView) => number;
7879
softDelete: (id: string | string[]) => Promise<any>;
7980
softDeleteWithServer: (id: string, asAdmin?: boolean) => Promise<any>;

libs/common/src/vault/services/cipher.service.ts

+10
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,16 @@ export class CipherService implements CipherServiceAbstraction {
825825
return this.getLocaleSortingFunction()(a, b);
826826
}
827827

828+
sortCiphersByFavouriteThenLastUsedThenName(a: CipherView, b: CipherView): number {
829+
if (a.favorite && !b.favorite) {
830+
return -1;
831+
}
832+
if (!a.favorite && b.favorite) {
833+
return 1;
834+
}
835+
return this.sortCiphersByLastUsedThenName(a, b);
836+
}
837+
828838
getLocaleSortingFunction(): (a: CipherView, b: CipherView) => number {
829839
return (a, b) => {
830840
let aName = a.name;

0 commit comments

Comments
 (0)