hplush / slowreader

Web app to combine feeds from social networks and RSS and to help read more meaningful and deep content
https://dev.slowreader.app
GNU Affero General Public License v3.0
161 stars 37 forks source link

Value data from feeds/add/{data} doesn't passed directly to input where it was previously added #130

Closed dancetrain closed 6 months ago

dancetrain commented 7 months ago

Steps to reproduce:

kmpeeduwee commented 7 months ago

I want to take it

ai commented 7 months ago

Sure, it is your.

kmpeeduwee commented 7 months ago

@ai Hi! I found how to implement this. But something tells me that this is not quite the correct way to add this code to onMount in preview.ts. Can you comment on this approach?

onMount($candidates, () => {
  let page = router.get()
  page.route === 'add' && setPreviewUrl(page.params.url!)
  return $links.listen(() => {})
})
ai commented 7 months ago

Looks normal in terms of API. But I don’t understand why we have $links.listen(() => {})

Also, if we use router, we usually need to subscribe to it. Can you explain why we didn’t subscribe?

kmpeeduwee commented 7 months ago

@ai I apologize, but this was due to my not understanding the code well enough; it was a piece of old code. I propose this version, in which I subscribe to the router and return the unsubscribe function:

onMount($candidates, () => {
  let unsubscribeRouter = router.subscribe(page => {
    if (page.route === 'add') {
      setPreviewUrl(page.params.url!);
    }
  });

  return () => {
    unsubscribeRouter();
  };
});
ai commented 6 months ago

Fixed 506c628