Problem with refreshing data in solid


#1

Hello, I am stuck with a problem.

I am creating a chat application for solid, and any time I send a message, a turtle document is created and stored in a folder inside my POD. This works so far, but my idea is to update (or refresh) the feed anytime I send a message.

The way I load messages is pretty straight forward: I read the content of a folder, and then I load each turtle document into the array. Again, this is also working perfectly. The thing is, the changes are only seen when I refresh the page manually. If I call again the load function after sending the message no changes are detected unless the page is refreshed. Of course, this is not very practical.

I am using solid file manager, just so you know.


#2

Did you try window.location.reload()


#3

So your app is able to fetch the new turtle documents after sending a message?
If yes, I suppose your website isn’t responding to state changes. Are you using a framework for this (e.g. react, angular, …) or coded it manually? And I think without the particular code snippet for this, it is hard to give concise tips. In general I’d suggest to wrap the access to the message array into a function/object (function addMessage(message) {...}) which adds the message to the array and updates the UI accordingly.

I hope this helps :slight_smile:


#4

I am using Angular.

My app is able to send messages and receive the new turtle documents, and when I check my folder using the solid’s website I see that a new document is added. The thing is, my app only detects that change after I refresh the page.

For example:

  • loadMessages(); -> 3 messages are loaded

  • addMessage(“Hello”);

  • loadMessages(); -> 3 messages are loaded, however, I can see the new document in the folder

<< refresh >>

  • loadMessages(); -> 4 messages are loaded

#5

I’m experiencing a similar issue. My app uses the update manager to do changes in the web, but it seems the local store doesn’t get updated and when accessing the updated triple the app shows the old value. I could solve this problem by doing a Fetcher.load with the option force=true. Without this the fetcher doesn’t do a real fetch from the web.

I think this is maybe a bug in the rdflib, because according to the documentation of UpdateManager.update, if the web change was successful, the local store must be updated too. I’ll ask in github or create an issue for that.


#6

This is not in the published documentation but please take a look at node_modules/rdflib/src/update-manager.js

Its setRefreshHandler() documentation points to addDownstreamChangeListener()

Here’s the gist as I figured it:

  • fetcher.load() gets a doc from a POD and puts it in the store
  • updateManager.addDownstreamChangeListener() tells rdflib to listen for changes to the doc
  • and updates the store’s copy of the doc when a change happens
  • app reads the store again with store.statementsMatching() in the handler to addDownstreamListener()

Note: A websocket is created by addDownstreamChangeListener()


#7

You could subscribe to changes via websocket