Skip to content

Commit fe525bd

Browse files
committed
Update boxes.py
Updating boxes.py to pass lint check Fixes #1151 Update boxes.py made users_list global by adding global keyword Update boxes.py user names now show id even when not adjacent Update boxes.py globally defined user_names_counter so it needs to be calculated only once Update boxes.py cleaning up the code a bit Update boxes.py black reformatting made function in model.py to get username count created a class variable in model class so that username count dict is calculated only once and using it to get number of users with same name and display id beside their name black reformatting black lint isort isort import order reformatting using .get() instead of the key and removing commented out code squashing commits reformatting using .get() instead of the key and removing commented out code
1 parent 263dcaa commit fe525bd

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

zulipterminal/model.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,9 +1151,7 @@ def user_name_count(self, user_name: str) -> int:
11511151
"""
11521152
Returns the count of the users with the same name as the given name.
11531153
"""
1154-
if not self.user_name_dict_count[user_name]:
1155-
return -1
1156-
return self.user_name_dict_count[user_name]
1154+
return self.user_name_dict_count.get(user_name, -1)
11571155

11581156
def _subscribe_to_streams(self, subscriptions: List[Subscription]) -> None:
11591157
def make_reduced_stream_data(stream: Subscription) -> StreamData:

zulipterminal/ui_tools/boxes.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ def __init__(self, view: Any) -> None:
7676
super().__init__(self.main_view(True))
7777
self.model = view.model
7878
self.view = view
79-
# global users_list # Making it global so it can be accessed in the MessageBox class
80-
# users_list = self.view.users
81-
# global user_names_counter # Making it global so it needs to be calculated only once
82-
# user_names_counter = Counter(
83-
# user["full_name"] for user in users_list
84-
# ) # Counting number of users having same name
79+
8580
# Used to indicate user's compose status, "closed" by default
8681
self.compose_box_status: Literal[
8782
"open_with_private", "open_with_stream", "closed"

0 commit comments

Comments
 (0)