Bladeren bron

Attempt to open apps from URL only if user is authenticated and desktop is loaded

Nariman Jelveh 9 maanden geleden
bovenliggende
commit
18cfef65b8
2 gewijzigde bestanden met toevoegingen van 24 en 25 verwijderingen
  1. 23 0
      src/gui/src/UI/UIDesktop.js
  2. 1 25
      src/gui/src/initgui.js

+ 23 - 0
src/gui/src/UI/UIDesktop.js

@@ -1022,6 +1022,29 @@ async function UIDesktop(options){
     // adjust window container to take into account the toolbar height
     $('.window-container').css('top', window.toolbar_height);
 
+
+    //--------------------------------------------------------------------------------------
+    // Determine if an app was launched from URL
+    // i.e. https://puter.com/app/<app_name>
+    //--------------------------------------------------------------------------------------
+    if(window.url_paths[0]?.toLocaleLowerCase() === 'app' && window.url_paths[1]){
+        window.app_launched_from_url = window.url_paths[1];
+        // get app metadata
+        try{
+            window.app_launched_from_url = await puter.apps.get(window.url_paths[1])
+            window.is_fullpage_mode = window.app_launched_from_url.metadata?.fullpage_on_landing ?? false;
+        }catch(e){
+            console.error(e);
+        }
+
+        // get query params, any param that doesn't start with 'puter.' will be passed to the app
+        window.app_query_params = {};
+        for (let [key, value] of window.url_query_params) {
+            if(!key.startsWith('puter.'))
+                window.app_query_params[key] = value;
+        }
+    }
+
     // ---------------------------------------------
     // Run apps from insta-login URL
     // ---------------------------------------------

+ 1 - 25
src/gui/src/initgui.js

@@ -188,30 +188,7 @@ window.initgui = async function(options){
     // will hold the result of the whoami API call
     let whoami;
 
-    const url_paths = window.location.pathname.split('/').filter(element => element);
-
-    //--------------------------------------------------------------------------------------
-    // Determine if an app was launched from URL
-    // i.e. https://puter.com/app/<app_name>
-    //--------------------------------------------------------------------------------------
-    if(url_paths[0]?.toLocaleLowerCase() === 'app' && url_paths[1]){
-        window.app_launched_from_url = url_paths[1];
-
-        // get app metadata
-        try{
-            window.app_launched_from_url = await puter.apps.get(window.app_launched_from_url)
-            window.is_fullpage_mode = window.app_launched_from_url.metadata?.fullpage_on_landing ?? false;
-        }catch(e){
-            console.error(e);
-        }
-
-        // get query params, any param that doesn't start with 'puter.' will be passed to the app
-        window.app_query_params = {};
-        for (let [key, value] of window.url_query_params) {
-            if(!key.startsWith('puter.'))
-                window.app_query_params[key] = value;
-        }
-    }
+    window.url_paths = window.location.pathname.split('/').filter(element => element);
 
     //--------------------------------------------------------------------------------------
     // Extract 'action' from URL
@@ -235,7 +212,6 @@ window.initgui = async function(options){
         window.is_fullpage_mode = true;
     }
 
-
     // Launch services before any UI is rendered
     await launch_services(options);