private void HandleTypingCommon(TLUpdateTypingBase updateTyping) { TLSendMessageActionBase action = new TLSendMessageTypingAction(); var updateUserTyping17 = updateTyping as IUserTypingAction; if (updateUserTyping17 != null) { action = updateUserTyping17.Action; } if (action is TLSendMessageCancelAction) { InputTypingManager.RemoveTypingUser(updateTyping.UserId.Value); } else { InputTypingManager.AddTypingUser(updateTyping.UserId.Value, action); } }
private void HandleTypingCommon(TLUpdateTypingBase updateTyping, Dictionary <int, TypingTuple> typingCache) { Execute.BeginOnUIThread(() => { var frame = Application.Current.RootVisual as TelegramTransitionFrame; if (frame != null) { var shellView = frame.Content as ShellView; if (shellView == null) { return; } } var updateChatUserTyping = updateTyping as TLUpdateChatUserTyping; var id = updateChatUserTyping != null ? updateChatUserTyping.ChatId : updateTyping.UserId; TypingTuple tuple; if (!typingCache.TryGetValue(id.Value, out tuple)) { for (var i = 0; i < Items.Count; i++) { if (updateChatUserTyping == null && Items[i].Peer is TLPeerUser && Items[i].Peer.Id.Value == id.Value || (updateChatUserTyping != null && Items[i].Peer is TLPeerChat && Items[i].Peer.Id.Value == id.Value)) { var dialog = Items[i] as TLDialog; if (dialog != null) { tuple = new TypingTuple(dialog, new InputTypingManager( users => Execute.BeginOnUIThread(() => { dialog.TypingString = GetTypingString(dialog.Peer, users); dialog.NotifyOfPropertyChange(() => dialog.Self.TypingString); }), () => Execute.BeginOnUIThread(() => { dialog.TypingString = null; dialog.NotifyOfPropertyChange(() => dialog.Self.TypingString); }))); typingCache[id.Value] = tuple; } break; } } } if (tuple != null) { TLSendMessageActionBase action = null; var typingAction = updateTyping as IUserTypingAction; if (typingAction != null) { action = typingAction.Action; } tuple.Item2.AddTypingUser(updateTyping.UserId.Value, action); } }); }