Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

Tasks no longer appear after going back to the main site and going to the task again

Open kostiak opened this issue 2 years ago • 4 comments

image

Reproduction:

  1. On the website, choose a task type and click on it.
  2. Go back
  3. Click on the same task again

kostiak avatar Jan 03 '23 22:01 kostiak

Can you see anything going on by checking the backend's docker logs?

fozziethebeat avatar Jan 04 '23 03:01 fozziethebeat

I don't think it's on the backend. It looks like when I first enter, the website calls the API for a task, but when I exit and enter the same task again, I don't see a call to the API.

kostiak avatar Jan 04 '23 07:01 kostiak

I know what's going on. Its the fact that we're using useSWRImmutable. One way we can fix this is by adding in

useEffect(() => {
  if (tasks.length == 0) {
    mutate();
  }
}, [tasks]);

To all the task pages. That would handle the case where we navigate to a task page, go home, then go back to the task page and the tasks get thrown away.

The other way is to investigate other variants of useSWR. The one issue I had with useSWR is that it kept re-fetching when switching tabs which is something we don't want.

Can I assign this to you @kostiak to test out?

fozziethebeat avatar Jan 04 '23 08:01 fozziethebeat

@fozziethebeat Sure, I'll test it out and let you know what I find.

kostiak avatar Jan 04 '23 08:01 kostiak

@fozziethebeat wasn't able to getuseSWR to work reliability but I did test your suggestion and it works.

kostiak avatar Jan 04 '23 21:01 kostiak

Alright, let's go with whatever works! Can you send that out as a PR? I'll review it high priority

fozziethebeat avatar Jan 05 '23 00:01 fozziethebeat

Confirmed fixed

fozziethebeat avatar Jan 05 '23 00:01 fozziethebeat