@wix/himalaya-cli 0.1944.0 → 0.1945.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ecom/src/extensions.d.ts +27 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-ecom.mjs +16 -0
  3. package/dist/cli.mjs +1185 -644
  4. package/fixtures/wix-canned.json +6 -0
  5. package/guides/himi-json-output.md +8 -6
  6. package/guides/one-app-section-mappings.md +2 -2
  7. package/guides/one-app-to-himi-app.md +13 -4
  8. package/guides/release-notes.md +8 -0
  9. package/guides/sdk-reference.json +55 -0
  10. package/package.json +2 -2
  11. package/templates/bare-fashion/dev/index.ts +3 -1
  12. package/templates/bare-fashion/tier5-src/_shared/bare-fashion-product-card.ts +5 -4
  13. package/templates/bare-fashion/tier5-src/_shared/collection-service.ts +35 -15
  14. package/templates/bare-fashion/tier5-src/_shared/himi-store-saved.ts +275 -13
  15. package/templates/bare-fashion/tier5-src/himi-bare-fashion-cart/index.ts +19 -12
  16. package/templates/bare-fashion/tier5-src/himi-bare-fashion-collection/index.ts +9 -4
  17. package/templates/bare-fashion/tier5-src/himi-bare-fashion-home/index.ts +10 -4
  18. package/templates/bare-fashion/tier5-src/himi-bare-fashion-product/index.ts +17 -8
  19. package/templates/bare-fashion/tier5-src/himi-bare-fashion-products/index.ts +8 -4
  20. package/templates/bare-fashion/tier5-src/himi-bare-fashion-saved/index.ts +31 -12
  21. package/templates/bare-fashion/tier5-src/himi-bare-fashion-search/index.ts +8 -4
  22. package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +35 -15
  23. package/templates/beauty-salon/tier5-src/_shared/himi-store-facets.ts +4 -4
  24. package/templates/beauty-salon/tier5-src/_shared/himi-store-saved.ts +275 -13
  25. package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  26. package/templates/beauty-salon/tier5-src/himi-branded-lite-category/index.ts +6 -1
  27. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +6 -5
  28. package/templates/beauty-salon/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  29. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +7 -5
  30. package/templates/beauty-salon/tier5-src/himi-store-saved/index.ts +31 -12
  31. package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +35 -15
  32. package/templates/branded-lite/recipes/wishlist-grid.json +1 -1
  33. package/templates/branded-lite/tier5-src/_shared/collection-service.ts +42 -19
  34. package/templates/branded-lite/tier5-src/_shared/himi-store-facets.ts +4 -4
  35. package/templates/branded-lite/tier5-src/_shared/himi-store-saved.ts +275 -13
  36. package/templates/branded-lite/tier5-src/_shared/saved-products-section.ts +14 -8
  37. package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  38. package/templates/branded-lite/tier5-src/himi-branded-lite-category/index.ts +6 -1
  39. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +6 -5
  40. package/templates/branded-lite/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  41. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +32 -15
  42. package/templates/branded-lite/tier5-src/himi-store-saved/index.ts +31 -12
  43. package/templates/brandy/tier5-src/_shared/collection-service.ts +42 -19
  44. package/templates/brandy/tier5-src/_shared/himi-store-saved.ts +275 -13
  45. package/templates/brandy/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  46. package/templates/community-club/l10n/ar.json +5 -0
  47. package/templates/community-club/l10n/cs.json +5 -0
  48. package/templates/community-club/l10n/da.json +5 -0
  49. package/templates/community-club/l10n/de.json +5 -0
  50. package/templates/community-club/l10n/el.json +5 -0
  51. package/templates/community-club/l10n/es.json +5 -0
  52. package/templates/community-club/l10n/fi.json +5 -0
  53. package/templates/community-club/l10n/fr.json +5 -0
  54. package/templates/community-club/l10n/he.json +4 -0
  55. package/templates/community-club/l10n/hu.json +5 -0
  56. package/templates/community-club/l10n/id.json +5 -0
  57. package/templates/community-club/l10n/it.json +5 -0
  58. package/templates/community-club/l10n/ja.json +5 -0
  59. package/templates/community-club/l10n/ko.json +5 -0
  60. package/templates/community-club/l10n/lt.json +5 -0
  61. package/templates/community-club/l10n/nl.json +5 -0
  62. package/templates/community-club/l10n/no.json +5 -0
  63. package/templates/community-club/l10n/pl.json +5 -0
  64. package/templates/community-club/l10n/pt.json +5 -0
  65. package/templates/community-club/l10n/ru.json +5 -0
  66. package/templates/community-club/l10n/sv.json +5 -0
  67. package/templates/community-club/l10n/th.json +5 -0
  68. package/templates/community-club/l10n/tr.json +5 -0
  69. package/templates/community-club/l10n/uk.json +5 -0
  70. package/templates/community-club/l10n/vi.json +5 -0
  71. package/templates/community-club/l10n/zh.json +5 -0
  72. package/templates/community-club/tier5-src/_shared/collection-service.ts +35 -15
  73. package/templates/community-club/tier5-src/_shared/himi-store-saved.ts +275 -13
  74. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +6 -5
  75. package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +35 -15
  76. package/templates/conference/tier5-src/_shared/collection-service.ts +35 -15
  77. package/templates/events-meetups/l10n/ar.json +5 -0
  78. package/templates/events-meetups/l10n/cs.json +5 -0
  79. package/templates/events-meetups/l10n/da.json +5 -0
  80. package/templates/events-meetups/l10n/de.json +5 -0
  81. package/templates/events-meetups/l10n/el.json +5 -0
  82. package/templates/events-meetups/l10n/es.json +5 -0
  83. package/templates/events-meetups/l10n/fi.json +5 -0
  84. package/templates/events-meetups/l10n/fr.json +5 -0
  85. package/templates/events-meetups/l10n/he.json +4 -0
  86. package/templates/events-meetups/l10n/hu.json +5 -0
  87. package/templates/events-meetups/l10n/id.json +5 -0
  88. package/templates/events-meetups/l10n/it.json +5 -0
  89. package/templates/events-meetups/l10n/ja.json +5 -0
  90. package/templates/events-meetups/l10n/ko.json +5 -0
  91. package/templates/events-meetups/l10n/lt.json +5 -0
  92. package/templates/events-meetups/l10n/nl.json +5 -0
  93. package/templates/events-meetups/l10n/no.json +5 -0
  94. package/templates/events-meetups/l10n/pl.json +5 -0
  95. package/templates/events-meetups/l10n/pt.json +5 -0
  96. package/templates/events-meetups/l10n/ru.json +5 -0
  97. package/templates/events-meetups/l10n/sv.json +5 -0
  98. package/templates/events-meetups/l10n/th.json +5 -0
  99. package/templates/events-meetups/l10n/tr.json +5 -0
  100. package/templates/events-meetups/l10n/uk.json +5 -0
  101. package/templates/events-meetups/l10n/vi.json +5 -0
  102. package/templates/events-meetups/l10n/zh.json +5 -0
  103. package/templates/events-meetups/tier5-src/_shared/collection-service.ts +35 -15
  104. package/templates/events-meetups/tier5-src/_shared/himi-store-saved.ts +275 -13
  105. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +6 -5
  106. package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +35 -15
  107. package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +35 -15
  108. package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +35 -15
  109. package/templates/gym-fitness/tier5-src/_shared/himi-store-facets.ts +4 -4
  110. package/templates/gym-fitness/tier5-src/_shared/himi-store-saved.ts +275 -13
  111. package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  112. package/templates/gym-fitness/tier5-src/himi-branded-lite-category/index.ts +6 -1
  113. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +6 -5
  114. package/templates/gym-fitness/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  115. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +7 -5
  116. package/templates/gym-fitness/tier5-src/himi-store-saved/index.ts +31 -12
  117. package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +35 -15
  118. package/templates/medical-services/tier5-src/_shared/collection-service.ts +35 -15
  119. package/templates/nonprofit-cause/l10n/ar.json +5 -0
  120. package/templates/nonprofit-cause/l10n/cs.json +5 -0
  121. package/templates/nonprofit-cause/l10n/da.json +5 -0
  122. package/templates/nonprofit-cause/l10n/de.json +5 -0
  123. package/templates/nonprofit-cause/l10n/el.json +5 -0
  124. package/templates/nonprofit-cause/l10n/es.json +5 -0
  125. package/templates/nonprofit-cause/l10n/fi.json +5 -0
  126. package/templates/nonprofit-cause/l10n/fr.json +5 -0
  127. package/templates/nonprofit-cause/l10n/he.json +4 -0
  128. package/templates/nonprofit-cause/l10n/hu.json +5 -0
  129. package/templates/nonprofit-cause/l10n/id.json +5 -0
  130. package/templates/nonprofit-cause/l10n/it.json +5 -0
  131. package/templates/nonprofit-cause/l10n/ja.json +5 -0
  132. package/templates/nonprofit-cause/l10n/ko.json +5 -0
  133. package/templates/nonprofit-cause/l10n/lt.json +5 -0
  134. package/templates/nonprofit-cause/l10n/nl.json +5 -0
  135. package/templates/nonprofit-cause/l10n/no.json +5 -0
  136. package/templates/nonprofit-cause/l10n/pl.json +5 -0
  137. package/templates/nonprofit-cause/l10n/pt.json +5 -0
  138. package/templates/nonprofit-cause/l10n/ru.json +5 -0
  139. package/templates/nonprofit-cause/l10n/sv.json +5 -0
  140. package/templates/nonprofit-cause/l10n/th.json +5 -0
  141. package/templates/nonprofit-cause/l10n/tr.json +5 -0
  142. package/templates/nonprofit-cause/l10n/uk.json +5 -0
  143. package/templates/nonprofit-cause/l10n/vi.json +5 -0
  144. package/templates/nonprofit-cause/l10n/zh.json +5 -0
  145. package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +35 -15
  146. package/templates/nonprofit-cause/tier5-src/_shared/himi-store-saved.ts +275 -13
  147. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +6 -5
  148. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +35 -15
  149. package/templates/owner-lite/tier5-src/_shared/collection-service.ts +35 -15
  150. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-service.ts +35 -15
  151. package/templates/podcast-creator/l10n/ar.json +5 -0
  152. package/templates/podcast-creator/l10n/cs.json +5 -0
  153. package/templates/podcast-creator/l10n/da.json +5 -0
  154. package/templates/podcast-creator/l10n/de.json +5 -0
  155. package/templates/podcast-creator/l10n/el.json +5 -0
  156. package/templates/podcast-creator/l10n/es.json +5 -0
  157. package/templates/podcast-creator/l10n/fi.json +5 -0
  158. package/templates/podcast-creator/l10n/fr.json +5 -0
  159. package/templates/podcast-creator/l10n/he.json +4 -0
  160. package/templates/podcast-creator/l10n/hu.json +5 -0
  161. package/templates/podcast-creator/l10n/id.json +5 -0
  162. package/templates/podcast-creator/l10n/it.json +5 -0
  163. package/templates/podcast-creator/l10n/ja.json +5 -0
  164. package/templates/podcast-creator/l10n/ko.json +5 -0
  165. package/templates/podcast-creator/l10n/lt.json +5 -0
  166. package/templates/podcast-creator/l10n/nl.json +5 -0
  167. package/templates/podcast-creator/l10n/no.json +5 -0
  168. package/templates/podcast-creator/l10n/pl.json +5 -0
  169. package/templates/podcast-creator/l10n/pt.json +5 -0
  170. package/templates/podcast-creator/l10n/ru.json +5 -0
  171. package/templates/podcast-creator/l10n/sv.json +5 -0
  172. package/templates/podcast-creator/l10n/th.json +5 -0
  173. package/templates/podcast-creator/l10n/tr.json +5 -0
  174. package/templates/podcast-creator/l10n/uk.json +5 -0
  175. package/templates/podcast-creator/l10n/vi.json +5 -0
  176. package/templates/podcast-creator/l10n/zh.json +5 -0
  177. package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +35 -15
  178. package/templates/podcast-creator/tier5-src/_shared/himi-store-saved.ts +275 -13
  179. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +6 -5
  180. package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +35 -15
  181. package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +35 -15
  182. package/templates/portfolio-creative/tier5-src/_shared/himi-store-facets.ts +4 -4
  183. package/templates/portfolio-creative/tier5-src/_shared/himi-store-saved.ts +275 -13
  184. package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  185. package/templates/portfolio-creative/tier5-src/himi-branded-lite-category/index.ts +6 -1
  186. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +6 -5
  187. package/templates/portfolio-creative/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  188. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +7 -5
  189. package/templates/portfolio-creative/tier5-src/himi-store-saved/index.ts +31 -12
  190. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +35 -15
  191. package/templates/professional-services/tier5-src/_shared/collection-service.ts +35 -15
  192. package/templates/restaurant/l10n/ar.json +5 -0
  193. package/templates/restaurant/l10n/cs.json +5 -0
  194. package/templates/restaurant/l10n/da.json +5 -0
  195. package/templates/restaurant/l10n/de.json +5 -0
  196. package/templates/restaurant/l10n/el.json +5 -0
  197. package/templates/restaurant/l10n/es.json +5 -0
  198. package/templates/restaurant/l10n/fi.json +5 -0
  199. package/templates/restaurant/l10n/fr.json +5 -0
  200. package/templates/restaurant/l10n/he.json +4 -0
  201. package/templates/restaurant/l10n/hu.json +5 -0
  202. package/templates/restaurant/l10n/id.json +5 -0
  203. package/templates/restaurant/l10n/it.json +5 -0
  204. package/templates/restaurant/l10n/ja.json +5 -0
  205. package/templates/restaurant/l10n/ko.json +5 -0
  206. package/templates/restaurant/l10n/lt.json +5 -0
  207. package/templates/restaurant/l10n/nl.json +5 -0
  208. package/templates/restaurant/l10n/no.json +5 -0
  209. package/templates/restaurant/l10n/pl.json +5 -0
  210. package/templates/restaurant/l10n/pt.json +5 -0
  211. package/templates/restaurant/l10n/ru.json +5 -0
  212. package/templates/restaurant/l10n/sv.json +5 -0
  213. package/templates/restaurant/l10n/th.json +5 -0
  214. package/templates/restaurant/l10n/tr.json +5 -0
  215. package/templates/restaurant/l10n/uk.json +5 -0
  216. package/templates/restaurant/l10n/vi.json +5 -0
  217. package/templates/restaurant/l10n/zh.json +5 -0
  218. package/templates/restaurant/tier5-src/_shared/collection-service.ts +35 -15
  219. package/templates/restaurant/tier5-src/_shared/himi-store-saved.ts +275 -13
  220. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +6 -5
  221. package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +35 -15
  222. package/templates/retail-store/tier5-src/_shared/collection-service.ts +42 -19
  223. package/templates/retail-store/tier5-src/_shared/himi-store-facets.ts +4 -4
  224. package/templates/retail-store/tier5-src/_shared/himi-store-saved.ts +275 -13
  225. package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  226. package/templates/retail-store/tier5-src/himi-branded-lite-category/index.ts +6 -1
  227. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +6 -5
  228. package/templates/retail-store/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  229. package/templates/retail-store/tier5-src/himi-store-product/index.ts +32 -15
  230. package/templates/retail-store/tier5-src/himi-store-saved/index.ts +31 -12
  231. package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +35 -15
  232. package/templates/salon-spa/tier5-src/_shared/collection-service.ts +35 -15
  233. package/templates/wholesale-store/dev/index.ts +2 -2
  234. package/templates/wholesale-store/tier5-src/_shared/collection-service.ts +42 -19
  235. package/templates/wholesale-store/tier5-src/_shared/himi-store-collection.ts +7 -3
  236. package/templates/wholesale-store/tier5-src/_shared/himi-store-saved.ts +275 -13
  237. package/templates/wholesale-store/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  238. package/templates/wholesale-store/tier5-src/himi-store-product/index.ts +32 -15
  239. package/templates/wholesale-store/tier5-src/himi-store-saved/index.ts +31 -12
  240. package/templates/wholesale-store/tier5-src/himi-wholesale-home/index.ts +19 -8
  241. package/templates/yoga-studio/l10n/ar.json +5 -0
  242. package/templates/yoga-studio/l10n/cs.json +5 -0
  243. package/templates/yoga-studio/l10n/da.json +5 -0
  244. package/templates/yoga-studio/l10n/de.json +5 -0
  245. package/templates/yoga-studio/l10n/el.json +5 -0
  246. package/templates/yoga-studio/l10n/es.json +5 -0
  247. package/templates/yoga-studio/l10n/fi.json +5 -0
  248. package/templates/yoga-studio/l10n/fr.json +5 -0
  249. package/templates/yoga-studio/l10n/he.json +4 -0
  250. package/templates/yoga-studio/l10n/hu.json +5 -0
  251. package/templates/yoga-studio/l10n/id.json +5 -0
  252. package/templates/yoga-studio/l10n/it.json +5 -0
  253. package/templates/yoga-studio/l10n/ja.json +5 -0
  254. package/templates/yoga-studio/l10n/ko.json +5 -0
  255. package/templates/yoga-studio/l10n/lt.json +5 -0
  256. package/templates/yoga-studio/l10n/nl.json +5 -0
  257. package/templates/yoga-studio/l10n/no.json +5 -0
  258. package/templates/yoga-studio/l10n/pl.json +5 -0
  259. package/templates/yoga-studio/l10n/pt.json +5 -0
  260. package/templates/yoga-studio/l10n/ru.json +5 -0
  261. package/templates/yoga-studio/l10n/sv.json +5 -0
  262. package/templates/yoga-studio/l10n/th.json +5 -0
  263. package/templates/yoga-studio/l10n/tr.json +5 -0
  264. package/templates/yoga-studio/l10n/uk.json +5 -0
  265. package/templates/yoga-studio/l10n/vi.json +5 -0
  266. package/templates/yoga-studio/l10n/zh.json +5 -0
  267. package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +35 -15
  268. package/templates/yoga-studio/tier5-src/_shared/himi-store-saved.ts +275 -13
  269. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +6 -5
  270. package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +35 -15
@@ -15,7 +15,10 @@ type MemberAvatarFactory = (changed: () => void) => {
15
15
 
16
16
  export interface CollectionSaving {
17
17
  read(): string[];
18
- write(ids: string[], rows: Record<string, unknown>[]): void;
18
+ /** May settle later (an account write); a rejection restores the selection and says so. */
19
+ write(ids: string[], rows: Record<string, unknown>[]): void | Promise<void>;
20
+ /** Re-read the saved ids `read` answers (an account list), before a load or refresh reads them. */
21
+ refresh?(): Promise<void>;
19
22
  }
20
23
  type State = Record<string, unknown>;
21
24
  interface BackendCollection {
@@ -263,19 +266,33 @@ export function decorateCollection(name: string, def: { state: State; actions?:
263
266
  const criteriaBefore = criteriaKey();
264
267
  const before = [...prefs.savedIds], undoBefore = lastUndo;
265
268
  update(arg, s);
269
+ const failed = () => {
270
+ prefs.savedIds = before; lastUndo = undoBefore;
271
+ saveMessage = copyParam('collection.saveError', 'Could not save this change. Try again.');
272
+ };
273
+ const finish = (settledLater: boolean) => {
274
+ persisted.write(prefs);
275
+ if (backend && config.backendQuery && criteriaBefore !== criteriaKey()) return backend.controller.query(criteria()).then(() => undefined);
276
+ // A write that settled later lands on the rows as they are now, not as they were when it began.
277
+ return derive(settledLater && backend ? backend.apply(s, backend.controller.getState()) : s);
278
+ };
266
279
  if (saving && JSON.stringify(before) !== JSON.stringify(prefs.savedIds)) {
280
+ let written: void | Promise<void>;
267
281
  try {
268
- saving.write(prefs.savedIds, Array.isArray(s[config.rows]) ? s[config.rows] as CollectionRow[] : []);
269
- saveMessage = '';
282
+ written = saving.write(prefs.savedIds, Array.isArray(s[config.rows]) ? s[config.rows] as CollectionRow[] : []);
270
283
  } catch {
271
- prefs.savedIds = before; lastUndo = undoBefore;
272
- saveMessage = copyParam('collection.saveError', 'Could not save this change. Try again.');
284
+ failed();
285
+ return finish(false);
286
+ }
287
+ if (written && typeof written.then === 'function') {
288
+ return written.then(() => { saveMessage = ''; return finish(true); }, () => { failed(); return finish(true); });
273
289
  }
290
+ saveMessage = '';
274
291
  }
275
- persisted.write(prefs);
276
- if (backend && config.backendQuery && criteriaBefore !== criteriaKey()) return backend.controller.query(criteria()).then(() => undefined);
277
- return derive(s);
292
+ return finish(false);
278
293
  };
294
+ /** Runs `then` once the saved ids are re-read (an account list); at once, in the same turn, when there is nothing to re-read. */
295
+ const afterSavingRefresh = (then: () => Promise<undefined>): Promise<undefined> => saving?.refresh ? saving.refresh().catch(() => undefined).then(then) : then();
279
296
  /** Filter and sort in ONE criteria change, so a tab that sets both runs one query, not two. */
280
297
  const setCriteria = (arg: unknown): void => {
281
298
  const input = object(arg);
@@ -329,15 +346,18 @@ export function decorateCollection(name: string, def: { state: State; actions?:
329
346
  if (backend) {
330
347
  actions.collectionDataChanged = s => derive(backend.apply(s, backend.controller.getState()));
331
348
  actions.load = (_s, arg) => {
332
- stashCopy(arg); syncSaved(); applyNavigationCriteria(arg, _s);
333
- const reset = backend.onLoad?.(arg);
334
- if (reset) { setCriteria(reset); persisted.write(prefs); }
335
- // A load of what the screen already shows is the screen coming back: it revalidates behind its rows.
336
- return backend.controller.query(criteria(), backend.restorePagesOnLoad, true).then(() => undefined);
349
+ stashCopy(arg);
350
+ return afterSavingRefresh(() => {
351
+ syncSaved(); applyNavigationCriteria(arg, _s);
352
+ const reset = backend.onLoad?.(arg);
353
+ if (reset) { setCriteria(reset); persisted.write(prefs); }
354
+ // A load of what the screen already shows is the screen coming back: it revalidates behind its rows.
355
+ return backend.controller.query(criteria(), backend.restorePagesOnLoad, true).then(() => undefined);
356
+ });
337
357
  };
338
358
  actions.refresh = (_s, arg) => {
339
- stashCopy(arg); syncSaved();
340
- return backend.controller.query(criteria()).then(() => undefined);
359
+ stashCopy(arg);
360
+ return afterSavingRefresh(() => { syncSaved(); return backend.controller.query(criteria()).then(() => undefined); });
341
361
  };
342
362
  actions.loadMore = () => backend.controller.loadMore().then(() => undefined);
343
363
  actions.retry = actions.collectionRetry = () => backend.controller.retry().then(() => undefined);
@@ -15,7 +15,10 @@ type MemberAvatarFactory = (changed: () => void) => {
15
15
 
16
16
  export interface CollectionSaving {
17
17
  read(): string[];
18
- write(ids: string[], rows: Record<string, unknown>[]): void;
18
+ /** May settle later (an account write); a rejection restores the selection and says so. */
19
+ write(ids: string[], rows: Record<string, unknown>[]): void | Promise<void>;
20
+ /** Re-read the saved ids `read` answers (an account list), before a load or refresh reads them. */
21
+ refresh?(): Promise<void>;
19
22
  }
20
23
  type State = Record<string, unknown>;
21
24
  interface BackendCollection {
@@ -263,19 +266,33 @@ export function decorateCollection(name: string, def: { state: State; actions?:
263
266
  const criteriaBefore = criteriaKey();
264
267
  const before = [...prefs.savedIds], undoBefore = lastUndo;
265
268
  update(arg, s);
269
+ const failed = () => {
270
+ prefs.savedIds = before; lastUndo = undoBefore;
271
+ saveMessage = copyParam('collection.saveError', 'Could not save this change. Try again.');
272
+ };
273
+ const finish = (settledLater: boolean) => {
274
+ persisted.write(prefs);
275
+ if (backend && config.backendQuery && criteriaBefore !== criteriaKey()) return backend.controller.query(criteria()).then(() => undefined);
276
+ // A write that settled later lands on the rows as they are now, not as they were when it began.
277
+ return derive(settledLater && backend ? backend.apply(s, backend.controller.getState()) : s);
278
+ };
266
279
  if (saving && JSON.stringify(before) !== JSON.stringify(prefs.savedIds)) {
280
+ let written: void | Promise<void>;
267
281
  try {
268
- saving.write(prefs.savedIds, Array.isArray(s[config.rows]) ? s[config.rows] as CollectionRow[] : []);
269
- saveMessage = '';
282
+ written = saving.write(prefs.savedIds, Array.isArray(s[config.rows]) ? s[config.rows] as CollectionRow[] : []);
270
283
  } catch {
271
- prefs.savedIds = before; lastUndo = undoBefore;
272
- saveMessage = copyParam('collection.saveError', 'Could not save this change. Try again.');
284
+ failed();
285
+ return finish(false);
286
+ }
287
+ if (written && typeof written.then === 'function') {
288
+ return written.then(() => { saveMessage = ''; return finish(true); }, () => { failed(); return finish(true); });
273
289
  }
290
+ saveMessage = '';
274
291
  }
275
- persisted.write(prefs);
276
- if (backend && config.backendQuery && criteriaBefore !== criteriaKey()) return backend.controller.query(criteria()).then(() => undefined);
277
- return derive(s);
292
+ return finish(false);
278
293
  };
294
+ /** Runs `then` once the saved ids are re-read (an account list); at once, in the same turn, when there is nothing to re-read. */
295
+ const afterSavingRefresh = (then: () => Promise<undefined>): Promise<undefined> => saving?.refresh ? saving.refresh().catch(() => undefined).then(then) : then();
279
296
  /** Filter and sort in ONE criteria change, so a tab that sets both runs one query, not two. */
280
297
  const setCriteria = (arg: unknown): void => {
281
298
  const input = object(arg);
@@ -329,15 +346,18 @@ export function decorateCollection(name: string, def: { state: State; actions?:
329
346
  if (backend) {
330
347
  actions.collectionDataChanged = s => derive(backend.apply(s, backend.controller.getState()));
331
348
  actions.load = (_s, arg) => {
332
- stashCopy(arg); syncSaved(); applyNavigationCriteria(arg, _s);
333
- const reset = backend.onLoad?.(arg);
334
- if (reset) { setCriteria(reset); persisted.write(prefs); }
335
- // A load of what the screen already shows is the screen coming back: it revalidates behind its rows.
336
- return backend.controller.query(criteria(), backend.restorePagesOnLoad, true).then(() => undefined);
349
+ stashCopy(arg);
350
+ return afterSavingRefresh(() => {
351
+ syncSaved(); applyNavigationCriteria(arg, _s);
352
+ const reset = backend.onLoad?.(arg);
353
+ if (reset) { setCriteria(reset); persisted.write(prefs); }
354
+ // A load of what the screen already shows is the screen coming back: it revalidates behind its rows.
355
+ return backend.controller.query(criteria(), backend.restorePagesOnLoad, true).then(() => undefined);
356
+ });
337
357
  };
338
358
  actions.refresh = (_s, arg) => {
339
- stashCopy(arg); syncSaved();
340
- return backend.controller.query(criteria()).then(() => undefined);
359
+ stashCopy(arg);
360
+ return afterSavingRefresh(() => { syncSaved(); return backend.controller.query(criteria()).then(() => undefined); });
341
361
  };
342
362
  actions.loadMore = () => backend.controller.loadMore().then(() => undefined);
343
363
  actions.retry = actions.collectionRetry = () => backend.controller.retry().then(() => undefined);
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "محدد",
2751
2751
  "origin": "machine"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "المنتج",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "إخفاء",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "vybráno",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produkt",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Skrýt",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "valgt",
2751
2751
  "origin": "machine"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produkt",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Skjul",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "ausgewählt",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produkt",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Ausblenden",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "επιλέχθηκαν",
2751
2751
  "origin": "machine"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Προϊόν",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Απόκρυψη",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "seleccionados",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Producto",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Ocultar",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "valittu",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Tuote",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Piilota",
@@ -2730,6 +2730,11 @@
2730
2730
  "translation": "sélectionné(s)",
2731
2731
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2732
2732
  },
2733
+ "h_dd3b86d1ef21": {
2734
+ "source": "Product",
2735
+ "translation": "Article",
2736
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2737
+ },
2733
2738
  "h_34d8b60fe253": {
2734
2739
  "source": "Hide",
2735
2740
  "translation": "Masquer",
@@ -2253,6 +2253,10 @@
2253
2253
  "source": "selected",
2254
2254
  "translation": "נבחר"
2255
2255
  },
2256
+ "h_dd3b86d1ef21": {
2257
+ "source": "Product",
2258
+ "translation": "מוצר"
2259
+ },
2256
2260
  "h_34d8b60fe253": {
2257
2261
  "source": "Hide",
2258
2262
  "translation": "הסתרה"
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "kijelölve",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Termék",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Elrejtés",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "dipilih",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produk",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Sembunyikan",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "selezionato",
2751
2751
  "origin": "machine"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Prodotto",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Nascondi",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "選択中",
2751
2751
  "origin": "one-app:mobile-apps-inbox:ARIA_BUSINESS_SELECTOR_SELECTED"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "商品",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "非表示",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "선택됨",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "제품",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "비공개",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "pasirinkta",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produktas",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Slėpti",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "geselecteerd",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Product",
2756
+ "origin": "machine"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Verbergen",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "valgte",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produkt",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Skjul",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "wybrano",
2751
2751
  "origin": "machine"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produkt",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Ukryj",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "selecionado",
2751
2751
  "origin": "machine"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produto",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Ocultar",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "выбрано",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Товар",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Скрыть",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "valda",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Produkt",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Dölj",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "เลือกแล้ว",
2751
2751
  "origin": "one-app:mobile-apps-inbox:ARIA_BUSINESS_SELECTOR_SELECTED"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "สินค้า",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "ซ่อน",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "seçili",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Ürün",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Gizle",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "обрано",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Товар",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Приховати",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "đã chọn",
2751
2751
  "origin": "one-app:wix-one-app-forms:FORMS_FIELD_COMPOSER_SELECTED_ITEMS"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "Sản phẩm",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "Ẩn",
@@ -2750,6 +2750,11 @@
2750
2750
  "translation": "已選擇",
2751
2751
  "origin": "one-app:mobile-apps-inbox:ARIA_BUSINESS_SELECTOR_SELECTED"
2752
2752
  },
2753
+ "h_dd3b86d1ef21": {
2754
+ "source": "Product",
2755
+ "translation": "產品",
2756
+ "origin": "one-app:wix-one-app-ecom-platform:merchant.ordersList.filters.products.heading"
2757
+ },
2753
2758
  "h_34d8b60fe253": {
2754
2759
  "source": "Hide",
2755
2760
  "translation": "隱藏",
@@ -15,7 +15,10 @@ type MemberAvatarFactory = (changed: () => void) => {
15
15
 
16
16
  export interface CollectionSaving {
17
17
  read(): string[];
18
- write(ids: string[], rows: Record<string, unknown>[]): void;
18
+ /** May settle later (an account write); a rejection restores the selection and says so. */
19
+ write(ids: string[], rows: Record<string, unknown>[]): void | Promise<void>;
20
+ /** Re-read the saved ids `read` answers (an account list), before a load or refresh reads them. */
21
+ refresh?(): Promise<void>;
19
22
  }
20
23
  type State = Record<string, unknown>;
21
24
  interface BackendCollection {
@@ -263,19 +266,33 @@ export function decorateCollection(name: string, def: { state: State; actions?:
263
266
  const criteriaBefore = criteriaKey();
264
267
  const before = [...prefs.savedIds], undoBefore = lastUndo;
265
268
  update(arg, s);
269
+ const failed = () => {
270
+ prefs.savedIds = before; lastUndo = undoBefore;
271
+ saveMessage = copyParam('collection.saveError', 'Could not save this change. Try again.');
272
+ };
273
+ const finish = (settledLater: boolean) => {
274
+ persisted.write(prefs);
275
+ if (backend && config.backendQuery && criteriaBefore !== criteriaKey()) return backend.controller.query(criteria()).then(() => undefined);
276
+ // A write that settled later lands on the rows as they are now, not as they were when it began.
277
+ return derive(settledLater && backend ? backend.apply(s, backend.controller.getState()) : s);
278
+ };
266
279
  if (saving && JSON.stringify(before) !== JSON.stringify(prefs.savedIds)) {
280
+ let written: void | Promise<void>;
267
281
  try {
268
- saving.write(prefs.savedIds, Array.isArray(s[config.rows]) ? s[config.rows] as CollectionRow[] : []);
269
- saveMessage = '';
282
+ written = saving.write(prefs.savedIds, Array.isArray(s[config.rows]) ? s[config.rows] as CollectionRow[] : []);
270
283
  } catch {
271
- prefs.savedIds = before; lastUndo = undoBefore;
272
- saveMessage = copyParam('collection.saveError', 'Could not save this change. Try again.');
284
+ failed();
285
+ return finish(false);
286
+ }
287
+ if (written && typeof written.then === 'function') {
288
+ return written.then(() => { saveMessage = ''; return finish(true); }, () => { failed(); return finish(true); });
273
289
  }
290
+ saveMessage = '';
274
291
  }
275
- persisted.write(prefs);
276
- if (backend && config.backendQuery && criteriaBefore !== criteriaKey()) return backend.controller.query(criteria()).then(() => undefined);
277
- return derive(s);
292
+ return finish(false);
278
293
  };
294
+ /** Runs `then` once the saved ids are re-read (an account list); at once, in the same turn, when there is nothing to re-read. */
295
+ const afterSavingRefresh = (then: () => Promise<undefined>): Promise<undefined> => saving?.refresh ? saving.refresh().catch(() => undefined).then(then) : then();
279
296
  /** Filter and sort in ONE criteria change, so a tab that sets both runs one query, not two. */
280
297
  const setCriteria = (arg: unknown): void => {
281
298
  const input = object(arg);
@@ -329,15 +346,18 @@ export function decorateCollection(name: string, def: { state: State; actions?:
329
346
  if (backend) {
330
347
  actions.collectionDataChanged = s => derive(backend.apply(s, backend.controller.getState()));
331
348
  actions.load = (_s, arg) => {
332
- stashCopy(arg); syncSaved(); applyNavigationCriteria(arg, _s);
333
- const reset = backend.onLoad?.(arg);
334
- if (reset) { setCriteria(reset); persisted.write(prefs); }
335
- // A load of what the screen already shows is the screen coming back: it revalidates behind its rows.
336
- return backend.controller.query(criteria(), backend.restorePagesOnLoad, true).then(() => undefined);
349
+ stashCopy(arg);
350
+ return afterSavingRefresh(() => {
351
+ syncSaved(); applyNavigationCriteria(arg, _s);
352
+ const reset = backend.onLoad?.(arg);
353
+ if (reset) { setCriteria(reset); persisted.write(prefs); }
354
+ // A load of what the screen already shows is the screen coming back: it revalidates behind its rows.
355
+ return backend.controller.query(criteria(), backend.restorePagesOnLoad, true).then(() => undefined);
356
+ });
337
357
  };
338
358
  actions.refresh = (_s, arg) => {
339
- stashCopy(arg); syncSaved();
340
- return backend.controller.query(criteria()).then(() => undefined);
359
+ stashCopy(arg);
360
+ return afterSavingRefresh(() => { syncSaved(); return backend.controller.query(criteria()).then(() => undefined); });
341
361
  };
342
362
  actions.loadMore = () => backend.controller.loadMore().then(() => undefined);
343
363
  actions.retry = actions.collectionRetry = () => backend.controller.retry().then(() => undefined);