Fix using permalink on new page
This commit is contained in:
parent
0a44b8363d
commit
e8fc755083
@ -89,7 +89,12 @@
|
||||
.then(tick)
|
||||
.then(async () => {
|
||||
// Initialize the actual app
|
||||
if (lastHash) {
|
||||
addrInputValue;
|
||||
updateAddr(wasm.call.EncodedAddress.from_address(addrInputValue), true);
|
||||
} else {
|
||||
updateAddr(wasm.call.EncodedAddress.from_coordinate(coordinateInputValue), true);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Erroring');
|
||||
@ -168,6 +173,29 @@
|
||||
}
|
||||
};
|
||||
|
||||
const checkHash = () => {
|
||||
if ($url && $url.hash) {
|
||||
let hash = decodeURI($url.hash.substr(1))
|
||||
.replaceAll(/-|\+|\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
let updatedFromHash = false;
|
||||
if (hash !== lastHash) {
|
||||
updatedFromHash = true;
|
||||
addrInputValue = hash;
|
||||
if (lastHash) {
|
||||
// If this is the first time we call this function, don't update the address
|
||||
// Because wasm is not yet defined
|
||||
addressInput();
|
||||
}
|
||||
}
|
||||
|
||||
lastHash = hash;
|
||||
|
||||
return updatedFromHash;
|
||||
}
|
||||
};
|
||||
|
||||
let mapIsVisible = false;
|
||||
|
||||
$: {
|
||||
@ -177,16 +205,7 @@
|
||||
let lastHash;
|
||||
$: {
|
||||
if ($url && $url.hash) {
|
||||
let hash = decodeURI($url.hash.substr(1))
|
||||
.replaceAll(/-|\+|\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
if (hash !== lastHash) {
|
||||
addrInputValue = hash;
|
||||
addressInput();
|
||||
}
|
||||
|
||||
lastHash = hash;
|
||||
checkHash();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user