1
0
Эх сурвалжийг харах

place `available_templates` call in `update_auth_data` to guarantee that `user` object exists

Nariman Jelveh 10 сар өмнө
parent
commit
a9801fc10d

+ 4 - 2
src/gui/src/helpers.js

@@ -432,7 +432,7 @@ window.refresh_user_data = async (auth_token)=>{
     }
 }
 
-window.update_auth_data = (auth_token, user)=>{
+window.update_auth_data = async (auth_token, user)=>{
     window.auth_token = auth_token;
     localStorage.setItem('auth_token', auth_token);
 
@@ -493,6 +493,9 @@ window.update_auth_data = (auth_token, user)=>{
         $('.user-options-login-btn, .user-options-create-account-btn').hide();
         $('.user-options-menu-btn').show();
     }
+
+    // Search and store user templates
+    window.file_templates = await window.available_templates()
 }
 
 window.mutate_user_preferences = function(user_preferences_delta) {
@@ -838,7 +841,6 @@ window.create_file = async(options)=>{
 }
 
 window.available_templates = async () => {
-    console.log(window.user.username)
     const baseRoute = `/${window.user.username}`
     const keywords = ["template", "templates", i18n('template')]
     //make sure all its lowercase

+ 0 - 2
src/gui/src/initgui.js

@@ -108,8 +108,6 @@ const launch_services = async function (options) {
         const svc_process = globalThis.services.get('process');
         svc_process.get_init().chstatus(PROCESS_RUNNING);
     }
-    // Search and store user templates
-    window.file_templates = await window.available_templates()
 };
 
 // This code snippet addresses the issue flagged by Lighthouse regarding the use of