chatEvent method
Constructs a ChatEvent from the ChatEventsVersionedMixin$Events.
Implementation
ChatEvent chatEvent(ChatEventsVersionedMixin$Events e) {
Log.trace('chatEvent($e)', '$runtimeType');
if (e.$$typename == 'EventChatCleared') {
var node = e as ChatEventsVersionedMixin$Events$EventChatCleared;
return EventChatCleared(e.chatId, node.at);
} else if (e.$$typename == 'EventChatUnreadItemsCountUpdated') {
var node =
e as ChatEventsVersionedMixin$Events$EventChatUnreadItemsCountUpdated;
return EventChatUnreadItemsCountUpdated(e.chatId, node.count);
} else if (e.$$typename == 'EventChatItemPosted') {
var node = e as ChatEventsVersionedMixin$Events$EventChatItemPosted;
return EventChatItemPosted(e.chatId, node.item.toDto());
} else if (e.$$typename == 'EventChatLastItemUpdated') {
var node = e as ChatEventsVersionedMixin$Events$EventChatLastItemUpdated;
return EventChatLastItemUpdated(e.chatId, node.lastItem?.toDto());
} else if (e.$$typename == 'EventChatItemHidden') {
var node = e as ChatEventsVersionedMixin$Events$EventChatItemHidden;
return EventChatItemHidden(e.chatId, node.itemId);
} else if (e.$$typename == 'EventChatMuted') {
var node = e as ChatEventsVersionedMixin$Events$EventChatMuted;
return EventChatMuted(e.chatId, node.duration.toModel());
} else if (e.$$typename == 'EventChatTypingStarted') {
var node = e as ChatEventsVersionedMixin$Events$EventChatTypingStarted;
_userRepo.put(node.user.toDto());
return EventChatTypingStarted(e.chatId, node.user.toModel());
} else if (e.$$typename == 'EventChatUnmuted') {
return EventChatUnmuted(e.chatId);
} else if (e.$$typename == 'EventChatTypingStopped') {
var node = e as ChatEventsVersionedMixin$Events$EventChatTypingStopped;
_userRepo.put(node.user.toDto());
return EventChatTypingStopped(e.chatId, node.user.toModel());
} else if (e.$$typename == 'EventChatHidden') {
var node = e as ChatEventsVersionedMixin$Events$EventChatHidden;
return EventChatHidden(e.chatId, node.at);
} else if (e.$$typename == 'EventChatItemDeleted') {
var node = e as ChatEventsVersionedMixin$Events$EventChatItemDeleted;
return EventChatItemDeleted(e.chatId, node.itemId);
} else if (e.$$typename == 'EventChatItemEdited') {
var node = e as ChatEventsVersionedMixin$Events$EventChatItemEdited;
return EventChatItemEdited(
e.chatId,
node.itemId,
node.text == null ? null : EditedMessageText(node.text!.changed),
node.attachments?.changed.map((e) => e.toModel()).toList(),
node.repliesTo?.changed.map((e) => e.toDto()).toList(),
);
} else if (e.$$typename == 'EventChatCallStarted') {
var node = e as ChatEventsVersionedMixin$Events$EventChatCallStarted;
return EventChatCallStarted(e.chatId, node.call.toModel());
} else if (e.$$typename == 'EventChatDirectLinkUsageCountUpdated') {
var node =
e as ChatEventsVersionedMixin$Events$EventChatDirectLinkUsageCountUpdated;
return EventChatDirectLinkUsageCountUpdated(e.chatId, node.usageCount);
} else if (e.$$typename == 'EventChatCallFinished') {
var node = e as ChatEventsVersionedMixin$Events$EventChatCallFinished;
return EventChatCallFinished(e.chatId, node.call.toModel(), node.reason);
} else if (e.$$typename == 'EventChatCallMemberLeft') {
var node = e as ChatEventsVersionedMixin$Events$EventChatCallMemberLeft;
_userRepo.put(node.user.toDto());
return EventChatCallMemberLeft(e.chatId, node.user.toModel(), node.at);
} else if (e.$$typename == 'EventChatCallMemberJoined') {
var node = e as ChatEventsVersionedMixin$Events$EventChatCallMemberJoined;
_userRepo.put(node.user.toDto());
return EventChatCallMemberJoined(
e.chatId,
node.call.toModel(),
node.user.toModel(),
node.at,
);
} else if (e.$$typename == 'EventChatCallMemberRedialed') {
var node =
e as ChatEventsVersionedMixin$Events$EventChatCallMemberRedialed;
_userRepo.put(node.user.toDto());
return EventChatCallMemberRedialed(
e.chatId,
node.at,
node.callId,
node.call.toModel(),
node.user.toModel(),
node.byUser.toModel(),
);
} else if (e.$$typename == 'EventChatDelivered') {
var node = e as ChatEventsVersionedMixin$Events$EventChatDelivered;
return EventChatDelivered(e.chatId, node.until);
} else if (e.$$typename == 'EventChatRead') {
var node = e as ChatEventsVersionedMixin$Events$EventChatRead;
_userRepo.put(node.byUser.toDto());
return EventChatRead(e.chatId, node.byUser.toModel(), node.at);
} else if (e.$$typename == 'EventChatCallDeclined') {
var node = e as ChatEventsVersionedMixin$Events$EventChatCallDeclined;
_userRepo.put(node.user.toDto());
return EventChatCallDeclined(
e.chatId,
node.callId,
node.call.toModel(),
node.user.toModel(),
node.at,
);
} else if (e.$$typename == 'EventChatTotalItemsCountUpdated') {
var node =
e as ChatEventsVersionedMixin$Events$EventChatTotalItemsCountUpdated;
return EventChatTotalItemsCountUpdated(e.chatId, node.count);
} else if (e.$$typename == 'EventChatDirectLinkDeleted') {
return EventChatDirectLinkDeleted(e.chatId);
} else if (e.$$typename == 'EventChatDirectLinkUpdated') {
var node =
e as ChatEventsVersionedMixin$Events$EventChatDirectLinkUpdated;
return EventChatDirectLinkUpdated(
e.chatId,
ChatDirectLink(
slug: node.directLink.slug,
usageCount: node.directLink.usageCount,
createdAt: node.directLink.createdAt,
),
);
} else if (e.$$typename == 'EventChatCallMoved') {
var node = e as ChatEventsVersionedMixin$Events$EventChatCallMoved;
_userRepo.put(node.user.toDto());
return EventChatCallMoved(
e.chatId,
node.callId,
node.call.toModel(),
node.newChatId,
node.newChat.toModel(),
node.newCallId,
node.newCall.toModel(),
node.user.toModel(),
node.at,
);
} else if (e.$$typename == 'EventChatFavorited') {
var node = e as ChatEventsVersionedMixin$Events$EventChatFavorited;
return EventChatFavorited(e.chatId, node.at, node.position);
} else if (e.$$typename == 'EventChatUnfavorited') {
var node = e as ChatEventsVersionedMixin$Events$EventChatUnfavorited;
return EventChatUnfavorited(e.chatId, node.at);
} else if (e.$$typename == 'EventChatCallConversationStarted') {
var node =
e as ChatEventsVersionedMixin$Events$EventChatCallConversationStarted;
return EventChatCallConversationStarted(
e.chatId,
node.callId,
node.at,
node.call.toModel(),
);
} else if (e.$$typename == 'EventChatCallAnswerTimeoutPassed') {
var node =
e as ChatEventsVersionedMixin$Events$EventChatCallAnswerTimeoutPassed;
return EventChatCallAnswerTimeoutPassed(e.chatId, node.callId);
} else {
throw UnimplementedError('Unknown ChatEvent: ${e.$$typename}');
}
}