Commit 42e1231ace038af3cf1e77ca9f6972a97e42f545

Authored by 权海
1 parent 77d971c0

feat(ui):增加设置主题成功后通知watch刷新

@@ -190,27 +190,27 @@ class WatchThemePreviewController extends GetxController { @@ -190,27 +190,27 @@ class WatchThemePreviewController extends GetxController {
190 } 190 }
191 } 191 }
192 192
193 - var syncSuccess = false;  
194 try { 193 try {
195 final result = await _themeApi.applyTheme(themeId); 194 final result = await _themeApi.applyTheme(themeId);
196 if (result is! AppSuccess<void>) { 195 if (result is! AppSuccess<void>) {
197 - syncSuccess =  
198 - await AppWearEngineHostApi().syncWatchTheme(downloadedTheme);  
199 - isApplying.value = false;  
200 AppToast.show(l10n.watchThemeApplyFailed); 196 AppToast.show(l10n.watchThemeApplyFailed);
201 return false; 197 return false;
202 } 198 }
  199 +
  200 + final syncSuccess =
  201 + await WearEngineHostApi().syncWatchTheme(downloadedTheme);
  202 + if (!syncSuccess) {
  203 + AppToast.show(l10n.watchThemeWatchSyncFailed);
  204 + return false;
  205 + }
  206 +
203 selectedThemeItem.value = themeItem; 207 selectedThemeItem.value = themeItem;
204 - isApplying.value = false;  
205 return true; 208 return true;
206 } catch (_) { 209 } catch (_) {
207 - // The active theme is already saved on the server.  
208 - syncSuccess = false;  
209 - }  
210 - isApplying.value = false;  
211 - if (!syncSuccess) {  
212 - AppToast.show(l10n.watchThemeWatchSyncFailed); 210 + AppToast.show(l10n.watchThemeApplyFailed);
  211 + return false;
  212 + } finally {
  213 + isApplying.value = false;
213 } 214 }
214 - return syncSuccess;  
215 } 215 }
216 } 216 }