Skip to content

Commit d7e576e

Browse files
mkp6781neiljp
authored andcommitted
refactor: api_types/model: TypedDict for realm emoji data.
Defined class RealmEmojiData to represent realm emoji data more precisely with each key having value of a specific type.
1 parent 81070e6 commit d7e576e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

zulipterminal/api_types.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,18 @@ class UpdateDisplaySettings(TypedDict):
148148
setting: bool
149149

150150

151+
class RealmEmojiData(TypedDict):
152+
id: str
153+
name: str
154+
source_url: str
155+
deactivated: bool
156+
# Previous versions had an author object with an id field.
157+
author_id: int # NOTE: new in Zulip 3.0 / ZFL 7.
158+
159+
151160
class UpdateRealmEmojiEvent(TypedDict):
152161
type: Literal['realm_emoji']
153-
realm_emoji: Dict[str, Any]
162+
realm_emoji: Dict[str, RealmEmojiData]
154163

155164

156165
Event = Union[

zulipterminal/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
EditPropagateMode,
3030
Event,
3131
PrivateComposition,
32+
RealmEmojiData,
3233
StreamComposition,
3334
Subscription,
3435
)
@@ -481,7 +482,7 @@ def update_stream_message(self, topic: str, message_id: int,
481482
return response['result'] == 'success'
482483

483484
def generate_all_emoji_data(self,
484-
custom_emoji: Dict[str, Any]
485+
custom_emoji: Dict[str, RealmEmojiData]
485486
) -> NamedEmojiData:
486487
unicode_emoji_data = unicode_emojis.EMOJI_DATA
487488
for name, data in unicode_emoji_data.items():

0 commit comments

Comments
 (0)