Commit 32930f2
committed
Guard connectivity observers against LiveData replay side effects
LiveData replays the current value to each new observer, so a side effect that
should only run on an offline->online transition also fired on open.
- SuggestionActivity: only call viewModel.onConnectionChanged (which refreshes
suggestions) on a genuine offline->online transition. The initial replay was
triggering a redundant fetch on top of the one started in viewModel.init().
- ReaderPostListFragment: initialise lastConnected to true so the first replayed
"connected" value doesn't re-run the search (e.g. on a restored fragment with
an active search); only a real transition resubmits.1 parent c617721 commit 32930f2
3 files changed
Lines changed: 14 additions & 2 deletions
File tree
- WordPress/src/main/java/org/wordpress/android/ui
- reader
- suggestion
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
183 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
184 | 191 | | |
185 | 192 | | |
186 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments