mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-27 16:10:32 +00:00
migrate to data attributes for micron parser links
This commit is contained in:
parent
7c20529d62
commit
d7080c8ca1
1 changed files with 23 additions and 4 deletions
|
|
@ -177,18 +177,21 @@ export default {
|
|||
};
|
||||
},
|
||||
beforeUnmount() {
|
||||
|
||||
// stop listening for websocket messages
|
||||
WebSocketConnection.off("message", this.onWebsocketMessage);
|
||||
|
||||
// stop listening for element clicks
|
||||
window.document.removeEventListener('click', this.onElementClick);
|
||||
|
||||
},
|
||||
mounted() {
|
||||
|
||||
// listen for websocket messages
|
||||
WebSocketConnection.on("message", this.onWebsocketMessage);
|
||||
|
||||
// fixme: this is called by the micron-parser.js
|
||||
window.onNodePageUrlClick = (url, options = null) => {
|
||||
this.onNodePageUrlClick(url, options);
|
||||
};
|
||||
// listen for element clicks
|
||||
window.document.addEventListener('click', this.onElementClick);
|
||||
|
||||
// load nomadnetwork node if a destination hash was provided on page load
|
||||
if(this.destinationHash){
|
||||
|
|
@ -203,6 +206,22 @@ export default {
|
|||
|
||||
},
|
||||
methods: {
|
||||
onElementClick(event) {
|
||||
|
||||
// find the closest ancestor (or the clicked element itself) with data-action="openNode"
|
||||
const element = event.target.closest('[data-action="openNode"]');
|
||||
if(!element){
|
||||
return;
|
||||
}
|
||||
|
||||
// get the destination and fields
|
||||
const destination = element.getAttribute("data-destination");
|
||||
const fields = element.getAttribute("data-fields");
|
||||
|
||||
// navigate to destination
|
||||
this.onNodePageUrlClick(destination, fields);
|
||||
|
||||
},
|
||||
async onWebsocketMessage(message) {
|
||||
const json = JSON.parse(message.data);
|
||||
switch(json.type){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue