mirror of https://github.com/zulip/zulip.git
minor: Clean up args for apply_event.
We now require keywords, so that there is no pitfall for mixing up boolean parameters. Positional parameters are basically evil when you have a bunch of bools. I also make user_profile the first argument. Finally, the code is more diff-friendly.
This commit is contained in:
parent
e42baf9e13
commit
3fa595ef85
|
@ -359,7 +359,10 @@ race conditions.
|
|||
state['realm_allow_message_editing'] = user_profile.realm.allow_message_editing
|
||||
# ...
|
||||
|
||||
def apply_event(state, events, user_profile, include_subscribers):
|
||||
def apply_event
|
||||
user_profile: UserProfile,
|
||||
# ...
|
||||
) -> None:
|
||||
for event in events:
|
||||
# ...
|
||||
elif event['type'] == 'realm':
|
||||
|
|
|
@ -438,15 +438,24 @@ def apply_events(
|
|||
# `apply_event`. For now, be careful in your choice of
|
||||
# `fetch_event_types`.
|
||||
continue
|
||||
apply_event(state, event, user_profile,
|
||||
client_gravatar, slim_presence, include_subscribers)
|
||||
apply_event(
|
||||
user_profile,
|
||||
state=state,
|
||||
event=event,
|
||||
client_gravatar=client_gravatar,
|
||||
slim_presence=slim_presence,
|
||||
include_subscribers=include_subscribers,
|
||||
)
|
||||
|
||||
def apply_event(state: Dict[str, Any],
|
||||
event: Dict[str, Any],
|
||||
def apply_event(
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
state: Dict[str, Any],
|
||||
event: Dict[str, Any],
|
||||
client_gravatar: bool,
|
||||
slim_presence: bool,
|
||||
include_subscribers: bool) -> None:
|
||||
include_subscribers: bool,
|
||||
) -> None:
|
||||
if event['type'] == "message":
|
||||
state['max_message_id'] = max(state['max_message_id'], event['message']['id'])
|
||||
if 'raw_unread_msgs' in state:
|
||||
|
|
Loading…
Reference in New Issue