Update.
This commit is contained in:
parent
b4d1575329
commit
95f0dd7915
@ -1023,6 +1023,9 @@
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.currentSort = 'recent';
|
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() {
|
async connectedCallback() {
|
||||||
@ -1031,15 +1034,15 @@
|
|||||||
<loading-spinner message="Loading rants..."></loading-spinner>
|
<loading-spinner message="Loading rants..."></loading-spinner>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
eventBus.on('sort-changed', (sort) => this.handleSortChange(sort));
|
eventBus.on('sort-changed', this.handleSortChange);
|
||||||
eventBus.on('refresh-view', () => this.loadFeed());
|
eventBus.on('refresh-view', this.handleRefreshView);
|
||||||
|
|
||||||
await this.loadFeed();
|
await this.loadFeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
eventBus.off('sort-changed', this.handleSortChange);
|
eventBus.off('sort-changed', this.handleSortChange);
|
||||||
eventBus.off('refresh-view', this.loadFeed);
|
eventBus.off('refresh-view', this.handleRefreshView);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(sort) {
|
handleSortChange(sort) {
|
||||||
@ -1047,6 +1050,10 @@
|
|||||||
this.loadFeed();
|
this.loadFeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleRefreshView() {
|
||||||
|
this.loadFeed();
|
||||||
|
}
|
||||||
|
|
||||||
async loadFeed() {
|
async loadFeed() {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
sort: this.currentSort,
|
sort: this.currentSort,
|
||||||
@ -1070,9 +1077,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.appendChild(container);
|
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