Skip to content
Merged
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
14 changes: 10 additions & 4 deletions src/RemoteSupport/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def __init__(self):
self.question = ""
self.askedUids = set()
self.askedNames = []
self.approved = False
self.declinedUids = set() # Not approved before anybody was, asked again on a new terminal.
self.declinedRequests = set()
self.declines = 0
Expand Down Expand Up @@ -278,6 +279,7 @@ def cleanup(self, reason=None, error=False):
self.url = None
self.approvalPending = False # A late answer is ignored as the session is gone.
self.askedUids = set()
self.approved = False
self.declinedUids = set()
self.declinedRequests = set()
self.declines = 0
Expand Down Expand Up @@ -317,16 +319,19 @@ def checkParticipants(self): # Everybody who joins has to be approved, meanwhil
fd.write("".join(f"{uid}\n" for uid in sorted(approvedUids)))
self.logEvent(f"Access for {', '.join(name for uid, name, final in connected)} kept from before the takeover")
approvedUids = currentApprovals()
if bool(approvedUids) != self.approved: # Dropped once nobody approved is connected.
self.approved = bool(approvedUids)
self.setState(self.state)
waiting = [(uid, name, final) for uid, name, final in participants() if uid not in approvedUids]
if waiting and not exists(LOCK_FILE):
fileWriteLine(LOCK_FILE, "1", source=MODULE_NAME)
elif not waiting and exists(LOCK_FILE):
remove(LOCK_FILE)
waitingUids = {uid for uid, name, final in waiting}
if self.approvalPending:
if waitingUids == self.askedUids:
if waitingUids == self.askedUids and sorted(name for uid, name, final in waiting) == sorted(self.askedNames):
return
withdrawQuestion(self.approvalCallback) # Somebody joined or left meanwhile.
withdrawQuestion(self.approvalCallback) # Somebody joined, left or was renamed meanwhile.
self.approvalPending = False
self.setState(self.state)
if not waiting or not all(final for uid, name, final in waiting): # The browser sets the name a few seconds after joining.
Expand Down Expand Up @@ -1039,8 +1044,8 @@ def scrolledBack(self):

def scroll(self, up):
if up:
self.paused = True
self.screen.prev_page()
self.paused = bool(self.scrolledBack()) # Without history there is nothing to scroll back to.
elif self.scrolledBack():
self.screen.next_page()

Expand Down Expand Up @@ -1222,8 +1227,9 @@ def unfreeze(self):
def keyUp(self):
large = self.largeTerminal()
if self.focusLarge and large:
self.frozen = large
self.terminals[large].scroll(up=True)
if self.terminals[large].scrolledBack():
self.frozen = large
self.render()
elif not self.focusLarge:
self.moveSelection(-1)
Expand Down
Loading