1- import { useState , useCallback , useEffect } from "react" ;
1+ import { useState , useCallback } from "react" ;
22import { usePlugin } from "./PluginContext" ;
3- import { Notice } from "obsidian" ;
3+ import { Notice , setIcon } from "obsidian" ;
44import { updateUsername } from "~/utils/supabaseContext" ;
55import { initializeSupabaseSync } from "~/utils/syncDgNodesToSupabase" ;
66import { nextRoot } from "@repo/utils/execContext" ;
@@ -14,18 +14,6 @@ export const AdminPanelSettings = () => {
1414 const [ username , setUsername ] = useState < string > (
1515 plugin . settings . username || "" ,
1616 ) ;
17- const [ isLoggedIn , setIsLoggedIn ] = useState ( false ) ;
18- useEffect ( ( ) => {
19- if ( syncModeEnabled ) {
20- const checkLogin = async ( ) => {
21- const client = await getLoggedInClient ( plugin ) ;
22- setIsLoggedIn ( client !== null ) ;
23- } ;
24- void checkLogin ( ) ;
25- } else {
26- setIsLoggedIn ( false ) ;
27- }
28- } , [ syncModeEnabled , plugin ] ) ;
2917
3018 const handleSyncModeToggle = useCallback (
3119 async ( newValue : boolean ) => {
@@ -57,14 +45,17 @@ export const AdminPanelSettings = () => {
5745
5846 const handleLoginHandoff = async ( ) => {
5947 const client = await getLoggedInClient ( plugin ) ;
60- if ( ! client ) return ;
48+ if ( ! client ) {
49+ new Notice ( "Failed to connect to the database" , 3000 ) ;
50+ return ;
51+ }
6152 const sessionData = await client . auth . getSession ( ) ;
6253 if ( ! sessionData . data . session ) return ;
6354 /* eslint-disable @typescript-eslint/naming-convention */
6455 const { access_token, refresh_token } = sessionData . data . session ;
6556 const { data, error } = await client . rpc ( "create_secret_token" , {
6657 v_payload : JSON . stringify ( { access_token, refresh_token } ) ,
67- expiry_interval : "10s " ,
58+ expiry_interval : "45s " ,
6859 } ) ;
6960 /* eslint-enable @typescript-eslint/naming-convention */
7061 if ( error || typeof data !== "string" ) return ;
@@ -110,7 +101,11 @@ export const AdminPanelSettings = () => {
110101 />
111102 </ div >
112103 </ div >
113- < div className = { "setting-item " + ( isLoggedIn ? "" : "hidden" ) } >
104+ < div
105+ className = {
106+ "setting-item " + ( plugin . settings . syncModeEnabled ? "" : "hidden" )
107+ }
108+ >
114109 < div className = "setting-item-info" >
115110 < div className = "setting-item-name" > Group management</ div >
116111 < div className = "setting-item-description" >
@@ -124,6 +119,10 @@ export const AdminPanelSettings = () => {
124119 } }
125120 >
126121 Manage groups
122+ < span
123+ className = "icon"
124+ ref = { ( el ) => ( el && setIcon ( el , "arrow-up-right" ) ) || undefined }
125+ />
127126 </ button >
128127 </ div >
129128 </ div >
0 commit comments