Просмотр исходного кода

Merge pull request #1097 from System233/patch-setting-done

Fix settings done button with unsaved changes
Matt Rubens 10 месяцев назад
Родитель
Сommit
259c2195e2

+ 0 - 5
.changeset/twenty-rice-own.md

@@ -1,5 +0,0 @@
----
-"roo-cline": patch
----
-
-Fix settings done button with unsaved changes

+ 8 - 11
webview-ui/src/App.tsx

@@ -28,16 +28,13 @@ const App = () => {
 	const [tab, setTab] = useState<Tab>("chat")
 	const settingsRef = useRef<SettingsViewRef>(null)
 
-	const switchTab = useCallback(
-		(newTab: Tab) => {
-			if (tab === "settings" && settingsRef.current?.checkUnsaveChanges) {
-				settingsRef.current.checkUnsaveChanges(() => setTab(newTab))
-			} else {
-				setTab(newTab)
-			}
-		},
-		[tab],
-	)
+	const switchTab = useCallback((newTab: Tab) => {
+		if (settingsRef.current?.checkUnsaveChanges) {
+			settingsRef.current.checkUnsaveChanges(() => setTab(newTab))
+		} else {
+			setTab(newTab)
+		}
+	}, [])
 
 	const onMessage = useCallback(
 		(e: MessageEvent) => {
@@ -73,7 +70,7 @@ const App = () => {
 		<WelcomeView />
 	) : (
 		<>
-			{tab === "settings" && <SettingsView ref={settingsRef} onDone={() => switchTab("chat")} />}
+			{tab === "settings" && <SettingsView ref={settingsRef} onDone={() => setTab("chat")} />}
 			{tab === "history" && <HistoryView onDone={() => switchTab("chat")} />}
 			{tab === "mcp" && <McpView onDone={() => switchTab("chat")} />}
 			{tab === "prompts" && <PromptsView onDone={() => switchTab("chat")} />}

+ 2 - 5
webview-ui/src/components/settings/SettingsView.tsx

@@ -173,6 +173,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
 				text: currentApiConfigName,
 				apiConfiguration,
 			})
+			// onDone()
 			setChangeDetected(false)
 		}
 	}
@@ -216,11 +217,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
 
 	const onConfirmDialogResult = useCallback((confirm: boolean) => {
 		if (confirm) {
-			setChangeDetected(false)
-			// Wait for the change detection to be updated
-			setTimeout(() => {
-				confirmDialogHandler.current?.()
-			}, 100)
+			confirmDialogHandler.current?.()
 		}
 	}, [])