Skip to content

Commit

Permalink
Reset session state when browser exists
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Dec 15, 2023
1 parent 73b170e commit b6ab652
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 1 addition & 3 deletions addons/io_hubs_addon/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,7 @@ def load_post(dummy):

@persistent
def update_session():
if hubs_session.is_alive():
hubs_session.update_session_state()

hubs_session.update_session_state()
return 2.0


Expand Down
28 changes: 17 additions & 11 deletions addons/io_hubs_addon/hubs_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,23 @@ def __create_instance(self, context):
self._web_driver = webdriver.Chrome(options=options)

def update_session_state(self):
url = self._web_driver.current_url
from urllib.parse import urlparse
from urllib.parse import parse_qs
parsed = urlparse(url)
params = parse_qs(parsed.query, keep_blank_values=True)
self._room_params = {k: v for k, v in params.items() if k != "hub_id"}

params = self._web_driver.execute_script(JS_STATE_UPDATE)
self._user_logged_in = params["signedIn"]
self._user_in_room = params["entered"]
self._room_name = params["roomName"]
if self.is_alive():
url = self._web_driver.current_url
from urllib.parse import urlparse
from urllib.parse import parse_qs
parsed = urlparse(url)
params = parse_qs(parsed.query, keep_blank_values=True)
self._room_params = {k: v for k, v in params.items() if k != "hub_id"}

params = self._web_driver.execute_script(JS_STATE_UPDATE)
self._user_logged_in = params["signedIn"]
self._user_in_room = params["entered"]
self._room_name = params["roomName"]

else:
self._user_logged_in = False
self._user_in_room = False
self._room_name = ""

def bring_to_front(self, context):
# In some systems switch_to doesn't work, the code below is a hack to make it work
Expand Down

0 comments on commit b6ab652

Please sign in to comment.