Skip to content

Commit bb1280f

Browse files
rsashankneiljp
authored andcommitted
refactor: api_types/model: Move presence interval defaults to api_types.
From ZFL 164, the server provides presence interval parameters; this commit moves the default values for earlier feature levels to 'api_types'.
1 parent d65cbee commit bb1280f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

zulipterminal/api_types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
MAX_MESSAGE_LENGTH: Final = 10000
3535

3636

37+
###############################################################################
38+
# These values are in the register response from ZFL 164
39+
# Before this feature level, they had the listed default (fixed) values
40+
41+
PRESENCE_OFFLINE_THRESHOLD_SECS: Final = 140
42+
PRESENCE_PING_INTERVAL_SECS: Final = 60
43+
44+
3745
###############################################################################
3846
# Core message types (used in Composition and Message below)
3947

zulipterminal/model.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
MAX_MESSAGE_LENGTH,
3535
MAX_STREAM_NAME_LENGTH,
3636
MAX_TOPIC_NAME_LENGTH,
37+
PRESENCE_OFFLINE_THRESHOLD_SECS,
38+
PRESENCE_PING_INTERVAL_SECS,
3739
TYPING_STARTED_EXPIRY_PERIOD,
3840
TYPING_STARTED_WAIT_PERIOD,
3941
TYPING_STOPPED_WAIT_PERIOD,
@@ -81,9 +83,6 @@
8183
from zulipterminal.ui_tools.utils import create_msg_box_list
8284

8385

84-
OFFLINE_THRESHOLD_SECS = 140
85-
86-
8786
class ServerConnectionFailure(Exception):
8887
pass
8988

@@ -445,7 +444,7 @@ def _start_presence_updates(self) -> None:
445444
view = self.controller.view
446445
view.users_view.update_user_list(user_list=self.users)
447446
view.middle_column.update_message_list_status_markers()
448-
time.sleep(60)
447+
time.sleep(PRESENCE_PING_INTERVAL_SECS)
449448

450449
@asynch
451450
def toggle_message_reaction(
@@ -1202,7 +1201,7 @@ def _update_users_data_from_initial_data(self) -> None:
12021201
*
12031202
* Out of the ClientPresence objects found in `presence`, we
12041203
* consider only those with a timestamp newer than
1205-
* OFFLINE_THRESHOLD_SECS; then of
1204+
* PRESENCE_OFFLINE_THRESHOLD_SECS; then of
12061205
* those, return the one that has the greatest UserStatus, where
12071206
* `active` > `idle` > `offline`.
12081207
*
@@ -1216,7 +1215,7 @@ def _update_users_data_from_initial_data(self) -> None:
12161215
timestamp = client[1]["timestamp"]
12171216
if client_name == "aggregated":
12181217
continue
1219-
elif (time.time() - timestamp) < OFFLINE_THRESHOLD_SECS:
1218+
elif (time.time() - timestamp) < PRESENCE_OFFLINE_THRESHOLD_SECS:
12201219
if status == "active":
12211220
aggregate_status = "active"
12221221
if status == "idle" and aggregate_status != "active":

0 commit comments

Comments
 (0)