Powerfull richtext callback & cache

Hey guys,

Is there a callback when Powerfull richtext has finished fetching {{ components }}?

I need to calculate the reading time with the imported components more precisely than with a setTimeout.

Thanks!

Hey @sebastienwozny!

You can use this snippet to wait until the solution is done loading!

<script>
  window.fsAttributes = window.fsAttributes || [];
  window.fsAttributes.push([
    'richtext',
    (textInstances) => {
      console.log('richtext Successfully loaded!');
    },
  ]);
</script>

Let me know if this works!

Thanks @Support-Luis!
My “components” are CMS generated and I have sometimes cache related problems (I think?) after editing pictures or fields in the CMS. On the pages where I call the components, it’s not updated unless I clean my cache. Any idea?

Hey @sebastienwozny! This is the first time I hear about this, I am not really sure if we can do anything other than wait for the cache to refresh :thinking:

Yes, I’ve tried everything, modifying the CMS item of the “component”, modifying the CMS item of the article, adding no-cache tags, and so on.

What I do is relatively simple, I have a “Selection” collection, I add my images / texts and I call my component from other collections like this: {{selection="/selections/the-slug"}}

If I go to the https://domain/selections/the-slug it’s all good, all my elements are updated. The buggy part is on the page who call the selection.

Ok, I have news.
It was a Cloudflare issue. The IndexedDB is not refreshed for some reason.

The solution for us was to force the indexdb to refresh:

(function () {
    const dbName = document.documentElement.getAttribute('data-wf-site') || 'fs-attributes';
    const deleteIndexedDB = (dbName) => {
        return new Promise((resolve, reject) => {
            const request = indexedDB.deleteDatabase(dbName);
            request.onsuccess = () => {
                resolve();
            };
            request.onerror = () => {
                reject('Failed to delete IndexedDB');
            };
        });
    };
    deleteIndexedDB(dbName)
        .catch((error) => {
            console.error(error);
        });
})();

Maybe a data-no-indexeddb could help in this situation?

Thanks for sharing @sebastienwozny! I will share this with the team so we have it in mind for the update. :muscle:

1 Like