@taruvi/navkit 0.0.40 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.tsx +4 -4
- package/src/NavkitContext.tsx +6 -1
- package/src/types.ts +1 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -13,9 +13,9 @@ import taruviLogoWhite from "./assets/taruvi-logo-white.png";
|
|
|
13
13
|
import type { Client } from "@taruvi/sdk"
|
|
14
14
|
|
|
15
15
|
const NavkitContent = () => {
|
|
16
|
-
const { isUserAuthenticated, siteSettings, appSettings, appName, userData, jwtToken, themeMode } = useNavigation();
|
|
16
|
+
const { isUserAuthenticated, siteSettings, appSettings, appSettingsLoaded, appName, userData, jwtToken, themeMode } = useNavigation();
|
|
17
17
|
const resolvedAppName = appName || appSettings?.displayName
|
|
18
|
-
const showTaruviLogo = !resolvedAppName && !appSettings?.icon
|
|
18
|
+
const showTaruviLogo = appSettingsLoaded && !resolvedAppName && !appSettings?.icon
|
|
19
19
|
const styles = getAppStyles(themeMode)
|
|
20
20
|
const [showAppLauncher, setShowAppLauncher] = useState<boolean>(false)
|
|
21
21
|
const [showProfileMenu, setShowProfileMenu] = useState<boolean>(false)
|
|
@@ -40,7 +40,7 @@ const NavkitContent = () => {
|
|
|
40
40
|
<Box component={"a"} href="/" sx={styles.leftSection}>
|
|
41
41
|
{showTaruviLogo ? (
|
|
42
42
|
<Box component="img" src={taruviLogoWhite} sx={styles.taruviSpaceLogo} />
|
|
43
|
-
) : (
|
|
43
|
+
) : appSettingsLoaded ? (
|
|
44
44
|
<>
|
|
45
45
|
{appSettings?.icon ? <Box component="img" src={appSettings?.icon} sx={styles.logo} /> : <></>}
|
|
46
46
|
{resolvedAppName &&
|
|
@@ -49,7 +49,7 @@ const NavkitContent = () => {
|
|
|
49
49
|
</Typography>
|
|
50
50
|
}
|
|
51
51
|
</>
|
|
52
|
-
)}
|
|
52
|
+
) : null}
|
|
53
53
|
</Box>
|
|
54
54
|
<Box component={"div"} sx={styles.rightSection}>
|
|
55
55
|
<Shortcuts showChat={setShowChat} onMenuToggle={() => setShowShortcutsMenu(!showShortcutsMenu)} />
|
package/src/NavkitContext.tsx
CHANGED
|
@@ -32,6 +32,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
|
|
|
32
32
|
enableDarkMode: false,
|
|
33
33
|
})
|
|
34
34
|
const [appSettings, setAppSettings] = useState<AppSettings>({})
|
|
35
|
+
const [appSettingsLoaded, setAppSettingsLoaded] = useState<boolean>(false)
|
|
35
36
|
|
|
36
37
|
const [isDesk, setIsDesk] = useState<boolean>(false)
|
|
37
38
|
const [appsList, setAppsList] = useState<AppData[]>([])
|
|
@@ -86,6 +87,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
|
|
|
86
87
|
|
|
87
88
|
// Fetch app settings to get the app name
|
|
88
89
|
try {
|
|
90
|
+
setAppSettingsLoaded(false)
|
|
89
91
|
const { data } = appName ? { data: { display_name: appName } } : await new App(client).settings().execute() as { data: { display_name?: string, icon?: string, primary_color?: string, secondary_color?: string } }
|
|
90
92
|
setAppSettings({
|
|
91
93
|
displayName: data?.display_name,
|
|
@@ -95,6 +97,9 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
|
|
|
95
97
|
})
|
|
96
98
|
} catch {
|
|
97
99
|
// App settings not available, continue without app settings
|
|
100
|
+
setAppSettings({})
|
|
101
|
+
} finally {
|
|
102
|
+
setAppSettingsLoaded(true)
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
const rawSettings = (fetchedSettings?.data ?? fetchedSettings)?.settings ?? {}
|
|
@@ -169,7 +174,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
|
|
|
169
174
|
}, [themeMode, onThemeChange])
|
|
170
175
|
|
|
171
176
|
return (
|
|
172
|
-
<NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, appSettings, appName, jwtToken, isUserAuthenticated, client, auth, themeMode, toggleTheme }}>
|
|
177
|
+
<NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, appSettings, appSettingsLoaded, appName, jwtToken, isUserAuthenticated, client, auth, themeMode, toggleTheme }}>
|
|
173
178
|
{children}
|
|
174
179
|
</NavigationContext.Provider>
|
|
175
180
|
)
|