This repository has been archived by the owner on Jul 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic remote behaviour to client scripts
this commit adds the ability to read the sameAs attribute of portal.json portal.sameAs is an array of portal dat:// addresses that state that this portal is the same as those portals, and that we should load their messages under our name this makes it possible to effectively post to the same account from different machines note: port_1 needs to have port_2 in its sameAs array, and port_2 needs to have port_1 in its sameAs array, i.e. the relationship needs to be mutual
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36969fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rotonde-client/scripts/portal.js
Lines 71 to 75 in e563661
If I understand this right, this attempts to connect to all remotes at once. While this is faster than what we're doing normally and won't hurt with a good network connection, IMO it would still be better to queue and iterate through them (similarly to how it's being done in
portal.connect
/Home.js
).Also, I've never seen
start()
being used on any other portal than our own, but it should be fine in this case :)36969fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think it's good to move to a queue-based process when everything works as a whole, but as it is there are still wrinkles to iron out.
not sure if you saw my message on rotonde, but if you look at portal.js you'll see that i change the name of the remotes
rotonde-client/scripts/portal.js
Lines 79 to 80 in 698079e
the issue being that name is reset upon a refresh, caused by e.g. a new dat or message being added. do you know what's going on there? i suspect the portal's data is being reloaded, to fetch any changes done in the meantime, but i am not sure.
36969fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got your message on Rotonde and sent a response, but went offline a few minutes afterwards 😅
Regarding the name being reset: You're right,
portal.refresh
can occur on a few occasions and that redownloadsportal.json
. One of such occasions is wheneverhome.save
invokes a delayedfeed.refresh
(refresh portals to poll the entries, then refresh entries in feed). Another one is hitting F5 / the refresh button in the Portals tab / theportals_refresh
command.Possible solution:
onparse
"event" for portals which gets fired after parsingportal.json
instart
/connect
/refresh
. "sameAs"-resolved portals can then listen for the event and change the name afterportal.json
gets parsed.For our intents and purposes, we don't even need to mimic an event, but instead just set a default
this.onparse = json => {};
inPortal.js
and then later inload_remotes
, setWe could also "queue" an
onparse
into the connection queue. That'd make it possible for us to just throw all remote URLs + a matchingonparse
into the queue and reuse all the existing code.If you don't mind, I'll try to rework
sameAs
towards that in my own repo and then send a PR :) I'll try to get it finished today as I'll be away during the weekend.36969fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha yeah, i think we've been talking past each other. as soon as i saw your message on rotonde i realized how to fix it!
in portal.js's refresh method:
rotonde-client/scripts/portal.js
Lines 164 to 169 in 7eb4355
i wouldn't mind moving to an event-based structure though :) so feel free to rework sameAs! (make sure you've got the latest updates tho, since i've fixed a few issues that i came across while testing)