mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-04 09:01:01 +01:00
control applying saved state and when to show groupings
This commit is contained in:
parent
0cdc343ce0
commit
bc5cec82cc
@ -59,7 +59,6 @@ export class AppComponent implements OnInit {
|
||||
});
|
||||
|
||||
private lastActivity: number = null;
|
||||
private previousUrl: string = '';
|
||||
|
||||
constructor(private angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics, private analytics: Angulartics2,
|
||||
private toasterService: ToasterService, private storageService: StorageService,
|
||||
@ -124,14 +123,15 @@ export class AppComponent implements OnInit {
|
||||
this.router.events.subscribe((event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
const url = event.urlAfterRedirects || event.url || '';
|
||||
if (url.startsWith('/tabs/') && this.previousUrl.startsWith('/tabs/')) {
|
||||
if (url.startsWith('/tabs/') && (window as any).previousPopupUrl != null &&
|
||||
(window as any).previousPopupUrl.startsWith('/tabs/')) {
|
||||
this.stateService.remove('GroupingsComponent');
|
||||
this.stateService.remove('CiphersComponent');
|
||||
}
|
||||
if (url.startsWith('/tabs/')) {
|
||||
this.stateService.remove('addEditCipher');
|
||||
}
|
||||
this.previousUrl = url;
|
||||
(window as any).previousPopupUrl = url;
|
||||
|
||||
// Clear route direction after animation (400ms)
|
||||
if ((window as any).routeDirection != null) {
|
||||
|
@ -16,7 +16,8 @@
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<content [ngClass]="{'stacked-boxes': nestedFolders && nestedFolders.length || nestedCollections && nestedCollections.length}">
|
||||
<content [ngClass]="{'stacked-boxes': showGroupings()}">
|
||||
<ng-container *ngIf="showGroupings()">
|
||||
<div class="box list" *ngIf="nestedFolders && nestedFolders.length">
|
||||
<div class="box-header">
|
||||
{{'folders' | i18n}}
|
||||
@ -50,6 +51,7 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="(!isPaging() ? ciphers : pagedCiphers) as filteredCiphers">
|
||||
<div class="no-items" *ngIf="!filteredCiphers.length">
|
||||
<i class="fa fa-spinner fa-spin fa-3x" *ngIf="!loaded"></i>
|
||||
|
@ -56,6 +56,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
|
||||
private selectedTimeout: number;
|
||||
private preventSelected = false;
|
||||
private pageSize = 100;
|
||||
private applySavedState = true;
|
||||
|
||||
constructor(searchService: SearchService, private route: ActivatedRoute,
|
||||
private router: Router, private location: Location,
|
||||
@ -66,6 +67,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
|
||||
private analytics: Angulartics2, private platformUtilsService: PlatformUtilsService) {
|
||||
super(searchService);
|
||||
this.pageSize = platformUtilsService.isEdge() ? 25 : 100;
|
||||
this.applySavedState = (window as any).previousPopupUrl != null &&
|
||||
!(window as any).previousPopupUrl.startsWith('/ciphers');
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
@ -120,11 +123,14 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
|
||||
}
|
||||
|
||||
this.loadMore();
|
||||
if (this.applySavedState) {
|
||||
this.state = (await this.stateService.get<any>(ComponentId)) || {};
|
||||
if (this.state.searchText) {
|
||||
this.searchText = this.state.searchText;
|
||||
}
|
||||
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0);
|
||||
}
|
||||
this.stateService.remove(ComponentId);
|
||||
});
|
||||
|
||||
this.broadcasterService.subscribe(ComponentId, (message: any) => {
|
||||
@ -209,6 +215,12 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
|
||||
this.didScroll = this.pagedCiphers.length > this.pageSize;
|
||||
}
|
||||
|
||||
showGroupings() {
|
||||
return !this.isSearching() &&
|
||||
((this.nestedFolders && this.nestedFolders.length) ||
|
||||
(this.nestedCollections && this.nestedCollections.length));
|
||||
}
|
||||
|
||||
isSearching() {
|
||||
return !this.searchPending && this.searchService.isSearchable(this.searchText);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user