webui: handle playback_pos response with empty contents #13

Merged
oysteikt merged 1 commits from handle-empty-playback-pos-response into master 2024-08-05 21:16:57 +02:00
Owner

Compatibility with changes made in 93366593c7. Should have no real effect on the original grzegorz API.

Compatibility with changes made in https://git.pvv.ntnu.no/oysteikt/mpvipc-async/commit/93366593c78819123cb122b322cc245e718d955a. Should have no real effect on the original grzegorz API.
oysteikt added 1 commit 2024-08-04 01:52:11 +02:00
oysteikt requested review from pederbs 2024-08-04 01:52:17 +02:00
pederbs reviewed 2024-08-04 03:56:26 +02:00
@ -295,3 +295,3 @@
playback_pos = None
if playback_pos:
if playback_pos and playback_pos["current"] and playback_pos["total"]:
Member
			if playback_pos and isinstance(playback_pos, dict) and "current" in playback_pos and "total" in playback_pos: 
```suggestion if playback_pos and isinstance(playback_pos, dict) and "current" in playback_pos and "total" in playback_pos: ```
Member

ellers får du KeyError

ellers får du KeyError
Member

glemte å godkjenne pending comments...

<sup>glemte å godkjenne pending comments...<sup>
oysteikt marked this conversation as resolved
oysteikt force-pushed handle-empty-playback-pos-response from 5d1538b370 to 771275cf84 2024-08-04 13:19:19 +02:00 Compare
pederbs reviewed 2024-08-04 21:09:38 +02:00
@ -298,0 +298,4 @@
playback_pos,
isinstance(playback_pos, dict),
playback_pos["current"],
playback_pos["total"],
Member

                "current" in playback_pos,
                "total" in playback_pos,

jeg antar at Option betyr keyen er optional, og ikke at verdien er nullable?

``` "current" in playback_pos, "total" in playback_pos, ``` jeg antar at `Option` betyr keyen er optional, og ikke at verdien er nullable?
Member

hvis både nullable og optional er kansje dette det du trenger

                "current" in playback_pos,
                 "total" in playback_pos,
                 playback_pos["current"] is not None,
                 playback_pos["total"] is not None,
hvis både nullable og optional er kansje dette det du trenger ``` "current" in playback_pos, "total" in playback_pos, playback_pos["current"] is not None, playback_pos["total"] is not None, ```
Author
Owner

Option betyr bare nullable. Det er som en haskell Maybe. Serialisert til json med Nones, så eksisterer feltene med verdi null.

`Option` betyr bare nullable. Det er som en haskell `Maybe`. Serialisert til json med `None`s, så eksisterer feltene med verdi `null`.
Member

👍

:+1:
pederbs marked this conversation as resolved
pederbs reviewed 2024-08-04 23:51:08 +02:00
pederbs left a comment
Member

denne koden kommer til å brekke hvis playback_pos = None, fordi playback_pos["current"] blir eagerly evaluated av kallet til all, som vil kaste en typefeil. Det er bedre på bruke en rekke av and i disse tilfellene fordi de blir short-circuited ved første False

denne koden kommer til å brekke hvis `playback_pos = None`, fordi `playback_pos["current"]` blir eagerly evaluated av kallet til `all`, som vil kaste en typefeil. Det er bedre på bruke en rekke av `and` i disse tilfellene fordi de blir short-circuited ved første `False`
oysteikt force-pushed handle-empty-playback-pos-response from 771275cf84 to 132cabf434 2024-08-05 17:53:20 +02:00 Compare
Author
Owner

sjukt. lazy python when

sjukt. lazy python when
oysteikt requested review from pederbs 2024-08-05 17:54:01 +02:00
pederbs approved these changes 2024-08-05 21:00:13 +02:00
oysteikt merged commit cb292a56b1 into master 2024-08-05 21:16:57 +02:00
oysteikt deleted branch handle-empty-playback-pos-response 2024-08-05 21:16:57 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Projects/grzegorz-clients#13
No description provided.