Commit 8e5a26f198faaa08dcabe517f9ef8e23d5ef3e10

Authored by 权海
1 parent af9130ed

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

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