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 * https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0 * SPDX-License-Identifier: MPL-2.0
*/ */
@ -2124,7 +2124,7 @@ xrf.navigator.init = () => {
xrf.navigator.URI = xrfragment.URI.parse(document.location.href) xrf.navigator.URI = xrfragment.URI.parse(document.location.href)
window.addEventListener('popstate', function (event){ 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(/.*\?/,'') ) xrf.navigator.to( document.location.href.replace(/.*\?/,'') )
} }
}) })
@ -2191,9 +2191,10 @@ xrf.navigator.reactifyHash = ( obj ) => {
get(me,k) { return me[k] }, get(me,k) { return me[k] },
set(me,k,v){ set(me,k,v){
me[k] = v me[k] = v
if( xrf.navigator.reactifyHash.enabled ){ if( xrf.navigator.updateHash.active ){
xrf.navigator.to( "#" + this.toString(me) ) xrf.navigator.to( "#" + this.toString(me) )
} }
xrf.navigator.URI.fragment = this.toString(me)
}, },
toString(me){ toString(me){
let parts = [] let parts = []
@ -2204,7 +2205,6 @@ xrf.navigator.reactifyHash = ( obj ) => {
} }
}) })
} }
xrf.navigator.reactifyHash.enabled = true
/** /**
* *
* navigation, portals & mutations * 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 * https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0 * SPDX-License-Identifier: MPL-2.0
*/ */
@ -2122,7 +2122,7 @@ xrf.navigator.init = () => {
xrf.navigator.URI = xrfragment.URI.parse(document.location.href) xrf.navigator.URI = xrfragment.URI.parse(document.location.href)
window.addEventListener('popstate', function (event){ 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(/.*\?/,'') ) xrf.navigator.to( document.location.href.replace(/.*\?/,'') )
} }
}) })
@ -2189,9 +2189,10 @@ xrf.navigator.reactifyHash = ( obj ) => {
get(me,k) { return me[k] }, get(me,k) { return me[k] },
set(me,k,v){ set(me,k,v){
me[k] = v me[k] = v
if( xrf.navigator.reactifyHash.enabled ){ if( xrf.navigator.updateHash.active ){
xrf.navigator.to( "#" + this.toString(me) ) xrf.navigator.to( "#" + this.toString(me) )
} }
xrf.navigator.URI.fragment = this.toString(me)
}, },
toString(me){ toString(me){
let parts = [] let parts = []
@ -2202,7 +2203,6 @@ xrf.navigator.reactifyHash = ( obj ) => {
} }
}) })
} }
xrf.navigator.reactifyHash.enabled = true
/** /**
* *
* navigation, portals & mutations * navigation, portals & mutations

View file

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

View file

@ -96,7 +96,7 @@ xrf.navigator.init = () => {
xrf.navigator.URI = xrfragment.URI.parse(document.location.href) xrf.navigator.URI = xrfragment.URI.parse(document.location.href)
window.addEventListener('popstate', function (event){ 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(/.*\?/,'') ) xrf.navigator.to( document.location.href.replace(/.*\?/,'') )
} }
}) })
@ -163,9 +163,10 @@ xrf.navigator.reactifyHash = ( obj ) => {
get(me,k) { return me[k] }, get(me,k) { return me[k] },
set(me,k,v){ set(me,k,v){
me[k] = v me[k] = v
if( xrf.navigator.reactifyHash.enabled ){ if( xrf.navigator.updateHash.active ){
xrf.navigator.to( "#" + this.toString(me) ) xrf.navigator.to( "#" + this.toString(me) )
} }
xrf.navigator.URI.fragment = this.toString(me)
}, },
toString(me){ toString(me){
let parts = [] 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}`) 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.last = v.string // remember
xrf.frag.pos.lastVector3 = camera.position.clone() xrf.frag.pos.lastVector3 = camera.position.clone()