summarylogtreecommitdiffstats
path: root/0001-feat-universal-provider-Auto-sync-after-adding.patch
blob: d92fcd8cef7dcc250e2be04e566ff090f9ebceab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
From bdb9ed5723064f9cc63c0dd42ab31b45fad65a9d Mon Sep 17 00:00:00 2001
From: Hu Butui <hot123tea123@gmail.com>
Date: Sun, 3 May 2026 11:54:11 +0800
Subject: [PATCH 1/2] feat(universal-provider): Auto-sync after adding and drop
 unused addSuccess i18n key

Signed-off-by: Hu Butui <hot123tea123@gmail.com>
---
 .../providers/AddProviderDialog.tsx           | 32 ++++++++++++++-----
 src/i18n/locales/en.json                      |  2 +-
 src/i18n/locales/ja.json                      |  2 +-
 src/i18n/locales/zh.json                      |  2 +-
 4 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/components/providers/AddProviderDialog.tsx b/src/components/providers/AddProviderDialog.tsx
index 3ee783e3..99361fd4 100644
--- a/src/components/providers/AddProviderDialog.tsx
+++ b/src/components/providers/AddProviderDialog.tsx
@@ -59,14 +59,6 @@ export function AddProviderDialog({
     async (provider: UniversalProvider) => {
       try {
         await universalProvidersApi.upsert(provider);
-        toast.success(
-          t("universalProvider.addSuccess", {
-            defaultValue: "统一供应商添加成功",
-          }),
-        );
-        setUniversalFormOpen(false);
-        setSelectedUniversalPreset(null);
-        onOpenChange(false);
       } catch (error) {
         console.error(
           "[AddProviderDialog] Failed to save universal provider",
@@ -77,7 +69,31 @@ export function AddProviderDialog({
             defaultValue: "统一供应商添加失败",
           }),
         );
+        return;
       }
+
+      try {
+        await universalProvidersApi.sync(provider.id);
+        toast.success(
+          t("universalProvider.addedAndSynced", {
+            defaultValue: "统一供应商已添加并同步",
+          }),
+        );
+      } catch (error) {
+        console.error(
+          "[AddProviderDialog] Provider saved but sync failed",
+          error,
+        );
+        toast.warning(
+          t("universalProvider.addedButSyncFailed", {
+            defaultValue: "统一供应商已添加,但同步失败",
+          }),
+        );
+      }
+
+      setUniversalFormOpen(false);
+      setSelectedUniversalPreset(null);
+      onOpenChange(false);
     },
     [t, onOpenChange],
   );
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index 558191e8..ce32651a 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -2400,9 +2400,9 @@
     "noAppsEnabled": "No apps enabled",
     "added": "Universal provider added",
     "addedAndSynced": "Universal provider added and synced",
+    "addedButSyncFailed": "Universal provider added, but sync failed",
     "updated": "Universal provider updated",
     "deleted": "Universal provider deleted",
-    "addSuccess": "Universal provider added successfully",
     "addFailed": "Failed to add universal provider",
     "hint": "Cross-app unified config, auto-sync to Claude/Codex/Gemini",
     "manage": "Manage",
diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json
index 6bf13ac3..8bd19090 100644
--- a/src/i18n/locales/ja.json
+++ b/src/i18n/locales/ja.json
@@ -2400,9 +2400,9 @@
     "noAppsEnabled": "有効なアプリがありません",
     "added": "統合プロバイダーを追加しました",
     "addedAndSynced": "統合プロバイダーを追加して同期しました",
+    "addedButSyncFailed": "統合プロバイダーを追加しましたが、同期に失敗しました",
     "updated": "統合プロバイダーを更新しました",
     "deleted": "統合プロバイダーを削除しました",
-    "addSuccess": "統合プロバイダーを追加しました",
     "addFailed": "統合プロバイダーの追加に失敗しました",
     "hint": "クロスアプリ統合設定。Claude/Codex/Gemini に自動同期します",
     "manage": "管理",
diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json
index 2b1bffbd..e53fc418 100644
--- a/src/i18n/locales/zh.json
+++ b/src/i18n/locales/zh.json
@@ -2400,9 +2400,9 @@
     "noAppsEnabled": "未启用任何应用",
     "added": "统一供应商已添加",
     "addedAndSynced": "统一供应商已添加并同步",
+    "addedButSyncFailed": "统一供应商已添加,但同步失败",
     "updated": "统一供应商已更新",
     "deleted": "统一供应商已删除",
-    "addSuccess": "统一供应商添加成功",
     "addFailed": "统一供应商添加失败",
     "hint": "跨应用统一配置,自动同步到 Claude/Codex/Gemini",
     "manage": "管理",
-- 
2.54.0