mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 11:37:47 +01:00
fix: prevent duplicate login success messages (#977)
* fix: prevent duplicate login success messages * refactor: i18n * refactor: update * docs: update changelog
This commit is contained in:
@@ -37,6 +37,7 @@ fix: fix page rapidly flickering issue #935
|
|||||||
fix(view extension): broken search bar UI when opening extensions via hotkey #938
|
fix(view extension): broken search bar UI when opening extensions via hotkey #938
|
||||||
fix: allow deletion after selecting all text #943
|
fix: allow deletion after selecting all text #943
|
||||||
fix: prevent shaking when switching between chat and search pages #955
|
fix: prevent shaking when switching between chat and search pages #955
|
||||||
|
fix: prevent duplicate login success messages #977
|
||||||
|
|
||||||
### ✈️ Improvements
|
### ✈️ Improvements
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { FC, memo, useCallback, useEffect, useState } from "react";
|
|||||||
import { Copy } from "lucide-react";
|
import { Copy } from "lucide-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
import { useDebounceFn } from "ahooks";
|
||||||
|
|
||||||
import { UserProfile } from "./UserProfile";
|
import { UserProfile } from "./UserProfile";
|
||||||
import { OpenURLWithBrowser } from "@/utils";
|
import { OpenURLWithBrowser } from "@/utils";
|
||||||
@@ -20,7 +21,6 @@ const ServiceAuth = memo(
|
|||||||
({ setRefreshLoading, refreshClick }: ServiceAuthProps) => {
|
({ setRefreshLoading, refreshClick }: ServiceAuthProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const language = useAppStore((state) => state.language);
|
|
||||||
const addError = useAppStore((state) => state.addError);
|
const addError = useAppStore((state) => state.addError);
|
||||||
const ssoRequestID = useAppStore((state) => state.ssoRequestID);
|
const ssoRequestID = useAppStore((state) => state.ssoRequestID);
|
||||||
const setSSORequestID = useAppStore((state) => state.setSSORequestID);
|
const setSSORequestID = useAppStore((state) => state.setSSORequestID);
|
||||||
@@ -61,19 +61,21 @@ const ServiceAuth = memo(
|
|||||||
[logoutServer]
|
[logoutServer]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { run: debouncedAuthSuccess } = useDebounceFn((event) => {
|
||||||
|
const { serverId } = event.payload;
|
||||||
|
if (serverId) {
|
||||||
|
refreshClick(serverId, () => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
addError(t("cloud.connect.hints.loginSuccess"), "info");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// handle oauth success event
|
// handle oauth success event
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unlistenOAuth = platformAdapter.listenEvent(
|
const unlistenOAuth = platformAdapter.listenEvent(
|
||||||
"oauth_success",
|
"oauth_success",
|
||||||
(event) => {
|
debouncedAuthSuccess
|
||||||
const { serverId } = event.payload;
|
|
||||||
if (serverId) {
|
|
||||||
refreshClick(serverId, () => {
|
|
||||||
setLoading(false);
|
|
||||||
});
|
|
||||||
addError(language === "zh" ? "登录成功" : "Login Success", "info");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -494,7 +494,10 @@
|
|||||||
"serverPlaceholder": "For example: https://coco.infini.cloud/",
|
"serverPlaceholder": "For example: https://coco.infini.cloud/",
|
||||||
"connecting": "Connecting...",
|
"connecting": "Connecting...",
|
||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"closeError": "Close error message"
|
"closeError": "Close error message",
|
||||||
|
"hints": {
|
||||||
|
"loginSuccess": "Login Successful"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"dataSource": {
|
"dataSource": {
|
||||||
"title": "Data Source",
|
"title": "Data Source",
|
||||||
|
|||||||
@@ -494,7 +494,10 @@
|
|||||||
"serverPlaceholder": "例如:https://coco.infini.cloud/",
|
"serverPlaceholder": "例如:https://coco.infini.cloud/",
|
||||||
"connecting": "连接中...",
|
"connecting": "连接中...",
|
||||||
"connect": "连接",
|
"connect": "连接",
|
||||||
"closeError": "关闭错误提示"
|
"closeError": "关闭错误提示",
|
||||||
|
"hints": {
|
||||||
|
"loginSuccess": "登录成功"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"dataSource": {
|
"dataSource": {
|
||||||
"title": "数据源",
|
"title": "数据源",
|
||||||
|
|||||||
Reference in New Issue
Block a user