Commit edefdbc
authored
Fix LiveView warning when uploading device certificates, rehydrate state properly (#2280)
`Phoenix.LiveView. consume_uploaded_entry/3` expects the function passed
to return `{:ok, _return}` or `{:postpone, _return}`. We were returning
a socket, causing a warning in the logs:
```
iex(21)> warning: consuming uploads requires a return signature matching:
{:ok, value} | {:postpone, value}
got:
#Phoenix.LiveView.Socket<...>
(phoenix_live_view 1.1.3) lib/phoenix_live_view/upload_channel.ex:33: Phoenix.LiveView.UploadChannel.consume/3
(elixir 1.18.3) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
(phoenix_live_view 1.1.3) lib/phoenix_live_view/upload.ex:264: Phoenix.LiveView.Upload.consume_uploaded_entry/3
(nerves_hub 2.0.0+afbd8e1f) lib/nerves_hub_web/components/device_page/settings_tab.ex:424: NervesHubWeb.Components.DevicePage.SettingsTab.handle_progress/3
(phoenix_live_view 1.1.3) lib/phoenix_live_view/channel.ex:181: anonymous fn/4 in Phoenix.LiveView.Channel.handle_info/2
(phoenix_live_view 1.1.3) lib/phoenix_live_view/channel.ex:1525: Phoenix.LiveView.Channel.write_socket/4
(phoenix_live_view 1.1.3) lib/phoenix_live_view/channel.ex:174: Phoenix.LiveView.Channel.handle_info/2
(stdlib 6.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
(stdlib 6.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
```
I also fixed an issue when uploading a device certificate. We were
previously using `update_in/2`, but on an unloaded Ecto association.
This was copied over from the old UI, but this code now sits in a
component, and we don't preload device certificates in the parent
LiveView. Fixing this uncovered another bug if you deleted the device's
last cert and then uploaded a new one. `Repo.preload/3` won't preload on
a loaded empty association, so `force: true` is needed.1 parent ef82a9a commit edefdbc
File tree
2 files changed
+13
-6
lines changed- lib
- nerves_hub_web/components/device_page
2 files changed
+13
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
359 | 361 | | |
360 | 362 | | |
361 | 363 | | |
| |||
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
435 | | - | |
| 434 | + | |
| 435 | + | |
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
439 | 440 | | |
440 | 441 | | |
441 | | - | |
| 442 | + | |
442 | 443 | | |
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
447 | 448 | | |
448 | 449 | | |
449 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
450 | 453 | | |
451 | 454 | | |
452 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
| |||
0 commit comments