Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Async Tasks data cache issue #997

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions frontend/src/static/js/components/webstatus-overview-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {consume} from '@lit/context';
import {Task, TaskStatus} from '@lit/task';
import {LitElement, type TemplateResult, html} from 'lit';
import {customElement, state} from 'lit/decorators.js';
import {customElement, state, property} from 'lit/decorators.js';
import {type components} from 'webstatus.dev-backend';

import {
Expand Down Expand Up @@ -55,9 +55,12 @@ export class OverviewPage extends LitElement {
data: null,
};

@state()
@property({type: Object})
location!: {search: string}; // Set by router.

@state()
currentLocation?: {search: string};

constructor() {
super();

Expand All @@ -67,7 +70,17 @@ export class OverviewPage extends LitElement {
task: async ([apiClient, routerLocation]): Promise<
components['schemas']['FeaturePage']
> => {
return this._fetchFeatures(apiClient, routerLocation);
if (this.location.search !== this.currentLocation?.search) {
// Reset taskTracker here due to a Task data cache issue.
this.taskTracker = {
status: TaskStatus.INITIAL,
error: null,
data: null,
};
this.currentLocation = this.location;
return this._fetchFeatures(apiClient, routerLocation);
}
return {} as components['schemas']['FeaturePage'];
KyleJu marked this conversation as resolved.
Show resolved Hide resolved
},
onComplete: page => {
this.taskTracker = {
Expand Down
Loading