NEAR-DevHub / neardevhub-contract

DevHub Portal Product Contract (Hosted on NEAR Blockchain) – Includes other instances (e.g. Infrastructure, Events)
https://neardevhub.org
19 stars 15 forks source link

Use preloads from socialdb for Web4 frontend scripts #146

Closed petersalomonsen closed 2 months ago

petersalomonsen commented 2 months ago

Today we have the script scroll_comment_into_view.js referenced in src/web4/handler.rs.

The scroll_comment_into_view.js is a copy of scripts/web4browserclient.js from the frontend repo.

From a maintenance perspective it is unfortunate to store the same content in two different repositories. There should be one source. The frontend version is also one step ahead of the file stored in the contract, since it also can support scrolling linked community announcements into the view.

I've considered to use a cdn that can fetch files directly from github repositiories, but there is a risk of caching older versions in browser clients when the same URL is used.

So after some consideration, I'm proposing using web4 preloads for this javascript file. The frontend should then deploy the javascript file to socialdb, and the web4 preload should then fetch it. This can be done the same way as we fetch metadata in handler.rs. It also means that the frontend should write the javascript file to socialdb as part of deployment.

It would also be preferable if the script is given a dedicated URL on the web4 gateway, so that we can use it for serving iframe contents to BOS as well ( instead of having iframe source code in a string in the BOS component ).

frol commented 2 months ago

Sounds good to me

petersalomonsen commented 2 months ago

This is ready for review. Also see the Pull Request for the frontend repo which is essential for uploading the frontend scripts to social db: https://github.com/NEAR-DevHub/neardevhub-bos/pull/933