Skip to content

Commit

Permalink
fix(fe-bookmarks-delete): when delete from bookmarks search results f…
Browse files Browse the repository at this point in the history
…orce page reload

Not optimal but not that of an usual use case...
  • Loading branch information
adixchen committed Jul 7, 2021
1 parent 3cfa53b commit eb44c04
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
2 changes: 2 additions & 0 deletions frontend/src/app/search-results/search-results.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
[bookmarks$]="searchResults$"
[queryText]="searchText"
[userData$]="userData$"
[isSearchResultsPage]="true"
[showFilterBox]="false">
</app-async-bookmark-list>
</div>
Expand Down Expand Up @@ -71,6 +72,7 @@
[bookmarks$]="searchResults$"
[queryText]="searchText"
[userData$]="userData$"
[isSearchResultsPage]="true"
[showFilterBox]="false">
</app-async-bookmark-list>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[userData$]="userData$"
[queryText]="queryText"
[filterText]="filterText"
[isSearchResultsPage]="isSearchResultsPage"
>
</app-bookmark-list-element>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export class AsyncBookmarkListComponent extends TagFollowingBaseComponent implem
@Input()
showPagination = true;

@Input()
isSearchResultsPage = false;

@Output()
bookmarkDeleted = new EventEmitter<boolean>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export class BookmarkListElementComponent extends TagFollowingBaseComponent impl
@Input()
isDetailsPage = false;

@Input()
isSearchResultsPage = false;

@Input()
filterText = '';

Expand All @@ -77,7 +80,7 @@ export class BookmarkListElementComponent extends TagFollowingBaseComponent impl
super(loginDialog, userDataWatchedTagsStore);

// START force reload on same root - solution taken from https://github.com/angular/angular/issues/13831
this.router.routeReuseStrategy.shouldReuseRoute = function(){
this.router.routeReuseStrategy.shouldReuseRoute = function () {
return false;
}

Expand Down Expand Up @@ -198,16 +201,23 @@ export class BookmarkListElementComponent extends TagFollowingBaseComponent impl
this.bookmarkDeleted.emit(true);
this.publicBookmarksStore.removeBookmarkFromPublicStore(bookmark);
this.feedStore.removeFromFeedBookmarks(bookmark);
if (this.isSearchResultsPage) {
location.reload();
}
});
} else {
this.personalBookmarksService.deleteBookmark(bookmark).subscribe(() => {
this.bookmarkDeleted.emit(true);
this.publicBookmarksStore.removeBookmarkFromPublicStore(bookmark);
this.userDataStore.removeFromStoresAtDeletion(bookmark);
this.myBookmarksStore.removeFromStoresAtDeletion(bookmark);
this.feedStore.removeFromFeedBookmarks(bookmark);
if (this.isDetailsPage) {
this.navigateToHomePage();
if (this.isSearchResultsPage) {
location.reload();
} else {
this.bookmarkDeleted.emit(true);
this.publicBookmarksStore.removeBookmarkFromPublicStore(bookmark);
this.userDataStore.removeFromStoresAtDeletion(bookmark);
this.myBookmarksStore.removeFromStoresAtDeletion(bookmark);
this.feedStore.removeFromFeedBookmarks(bookmark);
if (this.isDetailsPage) {
this.navigateToHomePage();
}
}
});
}
Expand Down

0 comments on commit eb44c04

Please sign in to comment.