This commit is contained in:
retoor 2025-08-04 17:44:12 +02:00
parent b4d1575329
commit 95f0dd7915

View File

@ -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));
}
}
}