Skip to content

Commit e3f00fa

Browse files
committed
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. Refactored code in `model.py`.
1 parent 52b6717 commit e3f00fa

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

zulipterminal/api_types.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,17 @@ 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+
author_id: int # NOTE: new in Zulip 3.0 / ZFL 7
157+
158+
151159
class UpdateRealmEmojiEvent(TypedDict):
152160
type: Literal['realm_emoji']
153-
realm_emoji: Dict[str, Any]
161+
realm_emoji: Dict[str, RealmEmojiData]
154162

155163

156164
Event = Union[

zulipterminal/model.py

Lines changed: 3 additions & 3 deletions
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
)
@@ -480,9 +481,8 @@ def update_stream_message(self, topic: str, message_id: int,
480481

481482
return response['result'] == 'success'
482483

483-
def generate_all_emoji_data(self,
484-
custom_emoji: Dict[str,
485-
Any]) -> NamedEmojiData:
484+
def generate_all_emoji_data(self, custom_emoji: Dict[str,
485+
RealmEmojiData]) -> NamedEmojiData:
486486
unicode_emoji_data = unicode_emojis.EMOJI_DATA
487487
for name, data in unicode_emoji_data.items():
488488
data['type'] = 'unicode_emoji'

0 commit comments

Comments
 (0)