Update.
This commit is contained in:
parent
b4d1575329
commit
95f0dd7915
@ -1023,6 +1023,9 @@
|
||||
constructor() {
|
||||
super();
|
||||
this.currentSort = 'recent';
|
||||
// Bind methods to ensure proper reference for event removal
|
||||
this.handleSortChange = this.handleSortChange.bind(this);
|
||||
this.handleRefreshView = this.handleRefreshView.bind(this);
|
||||
}
|
||||
|
||||
async connectedCallback() {
|
||||
@ -1031,15 +1034,15 @@
|
||||
<loading-spinner message="Loading rants..."></loading-spinner>
|
||||
`;
|
||||
|
||||
eventBus.on('sort-changed', (sort) => this.handleSortChange(sort));
|
||||
eventBus.on('refresh-view', () => this.loadFeed());
|
||||
eventBus.on('sort-changed', this.handleSortChange);
|
||||
eventBus.on('refresh-view', this.handleRefreshView);
|
||||
|
||||
await this.loadFeed();
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
eventBus.off('sort-changed', this.handleSortChange);
|
||||
eventBus.off('refresh-view', this.loadFeed);
|
||||
eventBus.off('refresh-view', this.handleRefreshView);
|
||||
}
|
||||
|
||||
handleSortChange(sort) {
|
||||
@ -1047,6 +1050,10 @@
|
||||
this.loadFeed();
|
||||
}
|
||||
|
||||
handleRefreshView() {
|
||||
this.loadFeed();
|
||||
}
|
||||
|
||||
async loadFeed() {
|
||||
const params = new URLSearchParams({
|
||||
sort: this.currentSort,
|
||||
@ -1070,9 +1077,6 @@
|
||||
});
|
||||
|
||||
this.appendChild(container);
|
||||
|
||||
// Re-add event listener after re-render
|
||||
eventBus.on('sort-changed', (sort) => this.handleSortChange(sort));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user