@@ -12,8 +12,6 @@ import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";
1212import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings" ;
1313import { AppText as Text } from "../../components/ui/AppText" ;
1414import { mobilePreferencesAtom , updateMobilePreferencesAtom } from "../../state/preferences" ;
15- import { serverEnvironment } from "../../state/server" ;
16- import { useAtomCommand } from "../../state/use-atom-command" ;
1715import { SettingsSection } from "./components/SettingsSection" ;
1816import { SettingsProjectOverridesSection } from "./components/SettingsProjectOverridesSection" ;
1917import { SettingsSwitchRow } from "./components/SettingsSwitchRow" ;
@@ -24,6 +22,7 @@ import {
2422} from "./components/SettingsEnvironmentFilterHeader" ;
2523import { planAutoSettleSettingsSync , type AutoSettleSettings } from "./autoSettleSettingsSync" ;
2624import { useSettingsEnvironmentFilter } from "./settings-environment-filter" ;
25+ import { useSettingsWriter } from "./useSettingsWriter" ;
2726import {
2827 planMobileScopedSettingsClear ,
2928 planMobileScopedSettingsPatch ,
@@ -67,10 +66,7 @@ function AutoSettleSettingsRows() {
6766 const [ pendingTargets , setPendingTargets ] = useState <
6867 readonly ScopedMobileSettingsTarget [ ] | null
6968 > ( null ) ;
70- const updateSettings = useAtomCommand ( serverEnvironment . updateSettings , {
71- label : "server settings update" ,
72- reportFailure : true ,
73- } ) ;
69+ const writeSettings = useSettingsWriter ( ) ;
7470
7571 const syncEnvironments = selectedTargets . filter ( supportsSharedSettingsSync ) ;
7672 const syncTargets = resolveMobileSettingsTargets (
@@ -107,11 +103,7 @@ function AutoSettleSettingsRows() {
107103 writeInFlight . current = true ;
108104 setPendingTargets ( syncTargets ) ;
109105 setPendingWrites ( ( count ) => count + 1 ) ;
110- void Promise . allSettled (
111- writes . map ( ( entry ) =>
112- updateSettings ( { environmentId : entry . environmentId , input : { patch : entry . patch } } ) ,
113- ) ,
114- ) . finally ( ( ) => {
106+ void writeSettings ( syncTargets , writes ) . finally ( ( ) => {
115107 writeInFlight . current = false ;
116108 setPendingTargets ( null ) ;
117109 setPendingWrites ( ( count ) => count - 1 ) ;
@@ -161,11 +153,7 @@ function AutoSettleSettingsRows() {
161153 writeInFlight . current = true ;
162154 setPendingTargets ( syncTargets ) ;
163155 setPendingWrites ( ( count ) => count + 1 ) ;
164- void Promise . allSettled (
165- writes . map ( ( entry ) =>
166- updateSettings ( { environmentId : entry . environmentId , input : { patch : entry . patch } } ) ,
167- ) ,
168- ) . finally ( ( ) => {
156+ void writeSettings ( syncTargets , writes ) . finally ( ( ) => {
169157 writeInFlight . current = false ;
170158 setPendingTargets ( null ) ;
171159 setPendingWrites ( ( count ) => count - 1 ) ;
0 commit comments