Commit a390930
RS Posts: Route mutations through PostService and improve UX (#22645)
* RS Posts: Show move-to-draft dialog when tapping a trashed post
Tapping a trashed post in the RS post list now shows a confirmation
dialog instead of opening the editor directly. On confirmation the
post is moved to draft status before the editor opens, matching the
behavior of the old post list.
The active tab is passed through the click callback chain rather than
the post status, since the status field may not be populated when the
user taps. A post on the TRASHED tab is always trashed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Reuse executePostAction in moveToDraftAndEdit and add loading indicator
Refactor moveToDraftAndEdit to use the shared executePostAction helper
with new onSuccess/onError callbacks instead of duplicating the pattern.
Show pull-to-refresh spinner on the Trashed tab during the network call.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Show toast when FluxC post not found after move-to-draft
If getFluxCPost returns null after successfully moving a trashed post
to draft, show a "Post moved to drafts" toast instead of failing
silently.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Route post mutations through PostService instead of WpApiClient
PostService (from wordpress-rs PR #1180) automatically updates
PostMetadataCollectionWithEditContext when posts are mutated, so
the list UI updates locally without needing optimistic removal
or a full tab refresh.
- Update wordpress-rs to trunk-a557060 which includes PR #1180
- Replace restClient.trashPost/deletePost/updatePostStatus with
postService.trashPost/deletePostPermanently/updatePost
- Rewrite moveToDraftAndEdit to use PostService directly
- Remove executePostAction, handleActionResult, removePostFromState,
and refreshAllTabs from the ViewModel
- Remove mutation methods and PostActionResult from PostRsRestClient
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Add better error messaging to post mutations
Adds getErrorMessage() helper that checks network availability and
parses WpApiException messages to provide more specific error feedback
to users instead of generic error messages.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Refactor post mutation methods to reduce duplication
Consolidates duplicate boilerplate across trash, delete, publish, and
move-to-draft operations by extracting shared logic into helper functions.
Changes:
- Add executePostMutation() helper for network check, error handling
- Add postStatusUpdate() helper for PostUpdateParams construction
- Unify friendlyErrorMessage() to handle both generic and API errors
- Remove explicit PostService type (use type inference)
Reduces code by ~85 lines with no behavioral changes.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Removed unused import
* Re-throw CancellationException in post mutation catch blocks
Prevents coroutine cancellation from being swallowed by the generic
Exception catch in executePostMutation and moveToDraftAndEdit.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Consolidate duplicate friendlyErrorMessage overloads
The single-param version was a strict subset of the two-param version
with defaultResId=null. All call sites resolve correctly to the
remaining overload.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add KDoc to undocumented private helpers in PostRsListViewModel
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix test compilation errors after wordpress-rs library update
Add missing requestUrl and requestMethod parameters to WpRequestResult
error constructors (UnknownError and WpError) in test files. These
parameters became required after the wordpress-rs library update in
commit 234bd8b.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Load cached items before refresh and guard loadMore during sync
Show cached/stale data immediately when initializing a tab by calling
loadItemsForTab before refreshTab, matching the recommended pattern
from the collection developer guide.
Also skip loadNextPage when a refresh is already in progress to
prevent concurrent sync operations.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix FluxC test compilation errors after wordpress-rs library update
Add missing requestUrl and requestMethod parameters to WpRequestResult.UnknownError
constructors in FluxC test files (MediaRsApiRestClientTest and TaxonomyRsApiRestClientTest).
These parameters became required after the wordpress-rs library update.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Fix line length violations in MediaRsApiRestClientTest
Break long WpRequestResult.UnknownError constructor calls across multiple
lines to comply with 120-character line length limit.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Prevent raw API error messages from being shown to users
The friendlyErrorMessage helper was returning raw WpApiException
messages directly to users, which could include technical content.
Remove this early return so errors always use localized string
resources.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 3295d05 commit a390930
8 files changed
Lines changed: 187 additions & 199 deletions
File tree
- WordPress/src
- main/java/org/wordpress/android/ui/postsrs
- data
- test/java/org/wordpress/android
- support
- aibot/repository
- he/repository
- ui/prefs/taxonomies
- gradle
- libs/fluxc/src/test/java/org/wordpress/android/fluxc/network/rest/wpapi
- media
- taxonomy
Lines changed: 114 additions & 118 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
237 | 239 | | |
238 | 240 | | |
239 | 241 | | |
240 | | - | |
241 | | - | |
| 242 | + | |
| 243 | + | |
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
249 | | - | |
250 | | - | |
| 251 | + | |
| 252 | + | |
251 | 253 | | |
252 | | - | |
| 254 | + | |
253 | 255 | | |
254 | 256 | | |
255 | 257 | | |
| |||
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
263 | | - | |
264 | | - | |
265 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
266 | 272 | | |
267 | | - | |
268 | | - | |
269 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
270 | 280 | | |
271 | | - | |
272 | | - | |
273 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
274 | 291 | | |
275 | | - | |
276 | | - | |
277 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
278 | 302 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
293 | 315 | | |
294 | 316 | | |
295 | | - | |
296 | | - | |
297 | | - | |
| 317 | + | |
298 | 318 | | |
299 | 319 | | |
300 | | - | |
301 | | - | |
302 | | - | |
| 320 | + | |
303 | 321 | | |
304 | 322 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
343 | 336 | | |
344 | 337 | | |
345 | 338 | | |
| |||
364 | 357 | | |
365 | 358 | | |
366 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
367 | 365 | | |
368 | 366 | | |
369 | 367 | | |
| |||
382 | 380 | | |
383 | 381 | | |
384 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
385 | 393 | | |
386 | 394 | | |
387 | | - | |
388 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
389 | 398 | | |
390 | | - | |
| 399 | + | |
391 | 400 | | |
392 | 401 | | |
393 | 402 | | |
| |||
398 | 407 | | |
399 | 408 | | |
400 | 409 | | |
| 410 | + | |
| 411 | + | |
401 | 412 | | |
402 | 413 | | |
403 | 414 | | |
404 | 415 | | |
405 | 416 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 417 | + | |
| 418 | + | |
415 | 419 | | |
416 | 420 | | |
417 | | - | |
418 | | - | |
419 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
420 | 424 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
426 | 431 | | |
427 | | - | |
428 | | - | |
429 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
430 | 436 | | |
431 | | - | |
| 437 | + | |
432 | 438 | | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
437 | 443 | | |
438 | | - | |
| 444 | + | |
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
442 | 448 | | |
443 | 449 | | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 450 | + | |
456 | 451 | | |
457 | 452 | | |
458 | 453 | | |
| |||
559 | 554 | | |
560 | 555 | | |
561 | 556 | | |
| 557 | + | |
562 | 558 | | |
563 | 559 | | |
564 | 560 | | |
| |||
668 | 664 | | |
669 | 665 | | |
670 | 666 | | |
671 | | - | |
| 667 | + | |
672 | 668 | | |
673 | 669 | | |
674 | 670 | | |
| |||
0 commit comments