Fixing share link
This commit is contained in:
16
src/main.tsx
16
src/main.tsx
@ -13,11 +13,20 @@ $appSettings.set(savedSettings);
|
||||
function loadFromURL() {
|
||||
if (window.location.hash) {
|
||||
try {
|
||||
const decoded = atob(window.location.hash.substring(1));
|
||||
const hash = window.location.hash.substring(1);
|
||||
console.log('Loading from URL hash:', hash);
|
||||
|
||||
const decoded = atob(hash);
|
||||
console.log('Decoded data:', decoded);
|
||||
|
||||
try {
|
||||
const shareData = JSON.parse(decoded);
|
||||
setShaderCode(shareData.code);
|
||||
console.log('Parsed share data:', shareData);
|
||||
|
||||
if (shareData.code) {
|
||||
setShaderCode(shareData.code);
|
||||
}
|
||||
|
||||
$appSettings.set({
|
||||
resolution: shareData.resolution || savedSettings.resolution,
|
||||
fps: shareData.fps || savedSettings.fps,
|
||||
@ -28,7 +37,10 @@ function loadFromURL() {
|
||||
? shareData.uiOpacity
|
||||
: savedSettings.uiOpacity,
|
||||
});
|
||||
|
||||
console.log('Settings updated from URL');
|
||||
} catch (jsonError) {
|
||||
console.log('JSON parse failed, falling back to old format');
|
||||
// Fall back to old format (just code as string)
|
||||
setShaderCode(decoded);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user