diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index 0e405acf..ee9b2df2 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -17,6 +17,8 @@ Information about release notes of Coco Server is provided here. ### 🐛 Bug fix +- fix: fixed issue with incorrect login status #600 + ### ✈️ Improvements ## 0.5.1 (2025-05-31) diff --git a/src/components/Cloud/ServiceAuth.tsx b/src/components/Cloud/ServiceAuth.tsx index 16daf681..7859149d 100644 --- a/src/components/Cloud/ServiceAuth.tsx +++ b/src/components/Cloud/ServiceAuth.tsx @@ -1,4 +1,4 @@ -import { memo, useCallback, useEffect, useState } from "react"; +import { FC, memo, useCallback, useEffect, useState } from "react"; import { Copy } from "lucide-react"; import { useTranslation } from "react-i18next"; import { v4 as uuidv4 } from "uuid"; @@ -30,7 +30,9 @@ const ServiceAuth = memo( const addError = useAppStore((state) => state.addError); const currentService = useConnectStore((state) => state.currentService); - const setCurrentService = useConnectStore((state) => state.setCurrentService); + const setCurrentService = useConnectStore( + (state) => state.setCurrentService + ); const serverList = useConnectStore((state) => state.serverList); const setServerList = useConnectStore((state) => state.setServerList); @@ -63,7 +65,7 @@ const ServiceAuth = memo( emit("login_or_logout", false); // update server profile setCurrentService({ ...currentService, profile: null }); - const updatedServerList = serverList.map(server => + const updatedServerList = serverList.map((server) => server.id === id ? { ...server, profile: null } : server ); console.log("updatedServerList", updatedServerList); @@ -130,7 +132,6 @@ const ServiceAuth = memo( // Fetch the initial deep link intent useEffect(() => { - setLoading(false); // Function to handle pasted URL const handlePaste = (event: any) => { const pastedText = event.clipboardData.getData("text").trim(); @@ -172,6 +173,10 @@ const ServiceAuth = memo( }; }, [ssoRequestID]); + useEffect(() => { + setLoading(false); + }, [currentService]); + if (!currentService?.auth_provider?.sso?.url) { return null; } @@ -222,8 +227,14 @@ const ServiceAuth = memo( export default ServiceAuth; -const LoginButton = memo(({ LoginClick }: { LoginClick: () => void }) => { +interface LoginButtonProps { + LoginClick: () => void; +} + +const LoginButton: FC = memo((props) => { + const { LoginClick } = props; const { t } = useTranslation(); + return ( - -
- {t("cloud.manualCopyLink")} -
+interface LoadingStateProps { + onCancel: () => void; + onCopy: () => void; +} + +const LoadingState: FC = memo((props) => { + const { onCancel, onCopy } = props; + const { t } = useTranslation(); + + return ( +
+ + +
+ {t("cloud.manualCopyLink")}
- ); - } -); +
+ ); +}); diff --git a/src/components/Cloud/UserProfile.tsx b/src/components/Cloud/UserProfile.tsx index e2f02257..658ecb39 100644 --- a/src/components/Cloud/UserProfile.tsx +++ b/src/components/Cloud/UserProfile.tsx @@ -1,6 +1,7 @@ import { User, LogOut } from "lucide-react"; import { UserProfile as UserInfo } from "@/types/server"; +import { useState } from "react"; interface UserProfileProps { server: string; //server's id @@ -14,12 +15,21 @@ export function UserProfile({ server, userInfo, onLogout }: UserProfileProps) { console.log("Logout", server); }; + const [imageLoadError, setImageLoadError] = useState(false); + return (
- {userInfo?.avatar ? ( - + {userInfo?.avatar && !imageLoadError ? ( + { + setImageLoadError(true); + }} + /> ) : ( )}