share links optimisation

This commit is contained in:
Leon van Kammen 2024-06-26 11:17:14 +00:00
parent 9f59024e3f
commit 8258150405
5 changed files with 17 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/*
* v0.5.1 generated at Tue Jun 25 01:51:16 PM UTC 2024
* v0.5.1 generated at Wed Jun 26 11:16:30 AM UTC 2024
* https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0
*/
@ -2124,7 +2124,7 @@ xrf.navigator.init = () => {
xrf.navigator.URI = xrfragment.URI.parse(document.location.href)
window.addEventListener('popstate', function (event){
if( !xrf.navigator.updateHash.active ){ // ignore programmatic hash updates (causes infinite recursion)
if( xrf.navigator.updateHash.active ){ // ignore programmatic hash updates (causes infinite recursion)
xrf.navigator.to( document.location.href.replace(/.*\?/,'') )
}
})
@ -2191,9 +2191,10 @@ xrf.navigator.reactifyHash = ( obj ) => {
get(me,k) { return me[k] },
set(me,k,v){
me[k] = v
if( xrf.navigator.reactifyHash.enabled ){
if( xrf.navigator.updateHash.active ){
xrf.navigator.to( "#" + this.toString(me) )
}
xrf.navigator.URI.fragment = this.toString(me)
},
toString(me){
let parts = []
@ -2204,7 +2205,6 @@ xrf.navigator.reactifyHash = ( obj ) => {
}
})
}
xrf.navigator.reactifyHash.enabled = true
/**
*
* navigation, portals & mutations

View File

@ -1,5 +1,5 @@
/*
* v0.5.1 generated at Tue Jun 25 01:51:16 PM UTC 2024
* v0.5.1 generated at Wed Jun 26 11:16:30 AM UTC 2024
* https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0
*/
@ -2122,7 +2122,7 @@ xrf.navigator.init = () => {
xrf.navigator.URI = xrfragment.URI.parse(document.location.href)
window.addEventListener('popstate', function (event){
if( !xrf.navigator.updateHash.active ){ // ignore programmatic hash updates (causes infinite recursion)
if( xrf.navigator.updateHash.active ){ // ignore programmatic hash updates (causes infinite recursion)
xrf.navigator.to( document.location.href.replace(/.*\?/,'') )
}
})
@ -2189,9 +2189,10 @@ xrf.navigator.reactifyHash = ( obj ) => {
get(me,k) { return me[k] },
set(me,k,v){
me[k] = v
if( xrf.navigator.reactifyHash.enabled ){
if( xrf.navigator.updateHash.active ){
xrf.navigator.to( "#" + this.toString(me) )
}
xrf.navigator.URI.fragment = this.toString(me)
},
toString(me){
let parts = []
@ -2202,7 +2203,6 @@ xrf.navigator.reactifyHash = ( obj ) => {
}
})
}
xrf.navigator.reactifyHash.enabled = true
/**
*
* navigation, portals & mutations

View File

@ -284,10 +284,11 @@ window.frontend = (opts) => new Proxy({
updateHashPosition(randomize){
const pos = xrf.frag.pos.get()
xrf.navigator.reactifyHash.enabled = false // prevent teleport
xrf.navigator.updateHash.active = false // prevent teleport
xrf.navigator.URI.hash.pos = `${pos.x},${pos.y},${pos.z}`
xrf.navigator.reactifyHash.enabled = true
this.copyToClipboard( window.location.href );
document.location.hash = `#${xrf.navigator.URI.fragment}`
xrf.navigator.updateHash.active = true
return document.location.href
},
copyToClipboard(text){
@ -305,11 +306,8 @@ window.frontend = (opts) => new Proxy({
if( network.meetingLink && !xrf.navigator.URI.hash.meet ){
xrf.navigator.URI.hash.meet = network.meetingLink
}
if( !xrf.navigator.URI.hash.pos && (network.posName || network.pos) ){
xrf.navigator.URI.hash.pos = network.posName || network.pos
}else frontend.updateHashPosition()
let url = window.location.href
let url = frontend.updateHashPosition()
console.log(url)
if( opts.linkonly ) return url
this.copyToClipboard( url )
// End of *TODO*

View File

@ -96,7 +96,7 @@ xrf.navigator.init = () => {
xrf.navigator.URI = xrfragment.URI.parse(document.location.href)
window.addEventListener('popstate', function (event){
if( !xrf.navigator.updateHash.active ){ // ignore programmatic hash updates (causes infinite recursion)
if( xrf.navigator.updateHash.active ){ // ignore programmatic hash updates (causes infinite recursion)
xrf.navigator.to( document.location.href.replace(/.*\?/,'') )
}
})
@ -163,9 +163,10 @@ xrf.navigator.reactifyHash = ( obj ) => {
get(me,k) { return me[k] },
set(me,k,v){
me[k] = v
if( xrf.navigator.reactifyHash.enabled ){
if( xrf.navigator.updateHash.active ){
xrf.navigator.to( "#" + this.toString(me) )
}
xrf.navigator.URI.fragment = this.toString(me)
},
toString(me){
let parts = []
@ -176,4 +177,3 @@ xrf.navigator.reactifyHash = ( obj ) => {
}
})
}
xrf.navigator.reactifyHash.enabled = true

View File

@ -18,7 +18,6 @@ xrf.frag.pos = function(v, opts){
}
if( xrf.debug ) console.log(`#pos.js: setting camera to position ${pos.x},${pos.y},${pos.z}`)
xrf.frag.pos.last = v.string // remember
xrf.frag.pos.lastVector3 = camera.position.clone()