Skip to content

Commit

Permalink
fix: remember media browser root position
Browse files Browse the repository at this point in the history
fixes #217
  • Loading branch information
punxaphil committed Nov 27, 2023
1 parent 0567078 commit 3758469
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sections/media-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { MediaPlayer } from '../model/media-player';
import { indexOfWithoutSpecialChars } from '../utils/media-browser-utils';

const LOCAL_STORAGE_CURRENT_DIR = 'custom-sonos-card_currentDir';
const LOCAL_STORAGE_BROWSE = 'custom-sonos-card_browse';

export class MediaBrowser extends LitElement {
@property() store!: Store;
Expand Down Expand Up @@ -63,6 +64,8 @@ export class MediaBrowser extends LitElement {
this.browse = true;
this.dispatchBrowseState();
}
} else {
this.browse = !!localStorage.getItem(LOCAL_STORAGE_BROWSE);
}
return html`
<sonos-media-browser-header .config=${this.config}></sonos-media-browser-header>
Expand Down Expand Up @@ -102,6 +105,12 @@ export class MediaBrowser extends LitElement {
this.setCurrentDir(undefined);
} else {
this.browse = !this.browse;

if (this.browse) {
localStorage.setItem(LOCAL_STORAGE_BROWSE, 'true');
} else {
localStorage.removeItem(LOCAL_STORAGE_BROWSE);
}
this.dispatchBrowseState();
}
}
Expand Down

0 comments on commit 3758469

Please sign in to comment.