Skip to content

Commit

Permalink
utils: Merge the hasTouch calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
bbhtt committed Jan 17, 2025
1 parent 376bcbf commit af817dc
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions backend/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def appstream2dict(appstream_url=None) -> dict[str, dict]:
app["locales"] = {}

isMobileFriendly = False
hasTouch = False

requires = component.find("requires")
if requires is not None:
if display_lengths := requires.findall("display_length"):
Expand All @@ -109,20 +111,13 @@ def appstream2dict(appstream_url=None) -> dict[str, dict]:
):
isMobileFriendly = True

hasTouch = False
supports = component.find("supports")
if supports is not None:
if controls := supports.findall("control"):
for control in controls:
if control.text == "touch":
hasTouch = True

recommends = component.find("recommends")
if recommends is not None:
if controls := recommends.findall("control"):
for control in controls:
if control.text == "touch":
hasTouch = True
for parent in ("supports", "recommends"):
child = component.find(parent)
if child is not None:
controls = child.findall("control")
if any(control.text == "touch" for control in controls):
hasTouch = True
break

app["isMobileFriendly"] = isMobileFriendly and hasTouch

Expand Down

0 comments on commit af817dc

Please sign in to comment.