Skip to content

Commit

Permalink
fix(pb-login): set userChanged on the event; pb-browse-docs: only ref…
Browse files Browse the repository at this point in the history
…resh the view if user has changed
  • Loading branch information
wolfgangmm committed Aug 14, 2020
1 parent 76ce23b commit 84a27ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pb-browse-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import '@cwmr/paper-autocomplete/paper-autocomplete-suggestions.js';
*
* @fires pb-collection - Sent to inform e.g. pb-upload about current collection
* @fires pb-search-resubmit - When received, set facet values as received from the event
* @fires pb-login - When received, check if user is allowed to modify the documents
* @fires pb-login - When received, refresh the view if the user changed
*
* @cssprop --pb-search-suggestions-background - Background for the autocomplete suggestions for the filter field
* @cssprop --pb-search-suggestions-color - Text color for the autocomplete suggestion for the filter field
Expand Down Expand Up @@ -127,7 +127,11 @@ export class PbBrowseDocs extends PbLoad {
this.collection = this.getParameter('collection');

this.subscribeTo('pb-search-resubmit', this._facets.bind(this));
this.subscribeTo('pb-login', this._facets.bind(this), []);
this.subscribeTo('pb-login', (ev) => {
if (ev.detail.userChanged) {
this._facets(ev);
}
}, []);
document.addEventListener('pb-i18n-update', () => {
// clear paper-listbox selection after language updates
const lb = this.shadowRoot.getElementById('sort-list');
Expand Down
2 changes: 2 additions & 0 deletions src/pb-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ export class PbLogin extends pbMixin(LitElement) {
_handleResponse() {
const resp = this._checkLogin.lastResponse;
if (resp.user && this._checkGroup(resp)) {
resp.userChanged = !this.loggedIn || this.user !== resp.user;
this.loggedIn = true;
this.user = resp.user;
this.groups = resp.groups;
this._invalid = false;
this._loginDialog.close();
} else {
resp.userChanged = this.loggedIn;
this.loggedIn = false;
this.password = null;
if (this._loginDialog.opened) {
Expand Down

0 comments on commit 84a27ea

Please sign in to comment.