Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions conreq/_core/home/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,26 @@ async def set_viewport():
elif state._viewport_secondary is state._viewport_intent:
state._viewport_selector = ViewportSelector.secondary

# Replace the selected viewport
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function homepage.set_viewport refactored with the following changes:

This removes the following comments ( why? ):

# Replace the oldest viewport
# Replace the selected viewport
# Automatically determine what viewport to use

elif state._viewport_intent.selector == ViewportSelector.primary:
state._viewport_selector = state._viewport_intent.selector
state._viewport_primary = state._viewport_intent
elif state._viewport_intent.selector == ViewportSelector.secondary:
state._viewport_selector = state._viewport_intent.selector
state._viewport_secondary = state._viewport_intent

# Automatically determine what viewport to use
elif state._viewport_intent.selector == ViewportSelector.auto:
# Use an unused viewport if it exists
if not state._viewport_primary:
state._viewport_selector = ViewportSelector.primary
state._viewport_primary = state._viewport_intent
elif not state._viewport_secondary:
state._viewport_selector = ViewportSelector.secondary
state._viewport_secondary = state._viewport_intent
# Replace the oldest viewport
elif (
state._viewport_primary.timestamp > state._viewport_secondary.timestamp
if (
not state._viewport_primary
or state._viewport_secondary
and state._viewport_primary.timestamp
> state._viewport_secondary.timestamp
):
state._viewport_selector = ViewportSelector.primary
state._viewport_primary = state._viewport_intent
else:
state._viewport_selector = ViewportSelector.secondary
state._viewport_secondary = state._viewport_intent

# Reset the intent
state._viewport_intent = None

Expand Down