Exemplo n.º 1
0
        public void Handle(TLUpdateEditMessage update)
        {
            var message = update.Message as TLMessage;

            if (message == null)
            {
                return;
            }

            Execute.BeginOnUIThread(() =>
            {
                int peerId;
                if (message.ToId is TLPeerUser)
                {
                    peerId = message.IsOut ? message.ToId.Id : message.FromId.Value;
                }
                else
                {
                    peerId = message.ToId.Id;
                }

                for (int i = 0; i < Count; i++)
                {
                    if (this[i].Peer.Id == peerId && this[i].TopMessage == message.Id)
                    {
                        this[i].RaisePropertyChanged(() => this[i].Self);
                    }
                }
            });
        }
Exemplo n.º 2
0
        public void Handle(TLUpdateEditMessage update)
        {
            var message = update.Message as TLMessage;

            if (message == null)
            {
                return;
            }

            var flag = false;

            var userBase = With as TLUserBase;
            var chatBase = With as TLChatBase;

            if (userBase != null && message.ToId is TLPeerUser && !message.IsOut && userBase.Id == message.FromId.Value)
            {
                flag = true;
            }
            else if (userBase != null && message.ToId is TLPeerUser && message.IsOut && userBase.Id == message.ToId.Id)
            {
                flag = true;
            }
            else if (chatBase != null && message.ToId is TLPeerChat && chatBase.Id == message.ToId.Id)
            {
                flag = true;
            }

            if (flag)
            {
                BeginOnUIThread(() =>
                {
                    var already = Items.FirstOrDefault(x => x.Id == update.Message.Id) as TLMessage;
                    if (already == null)
                    {
                        return;
                    }

                    //if (already != message)
                    {
                        already.Edit(message);
                    }

                    message = already;

                    message.RaisePropertyChanged(() => message.HasEditDate);
                    message.RaisePropertyChanged(() => message.Message);
                    message.RaisePropertyChanged(() => message.Media);
                    message.RaisePropertyChanged(() => message.ReplyMarkup);
                    message.RaisePropertyChanged(() => message.Self);
                    message.RaisePropertyChanged(() => message.SelfBase);
                });
            }
        }
        public void Handle(TLUpdateEditMessage update)
        {
            var message = update.Message as TLMessageCommon;

            if (message == null)
            {
                return;
            }

            var editMessage = false;

            var user = With as TLUserBase;
            var chat = With as TLChatBase;

            if (user != null &&
                message.ToId is TLPeerUser &&
                !message.Out.Value &&
                user.Id.Value == message.FromId.Value)
            {
                editMessage = true;
            }
            else if (user != null &&
                     message.ToId is TLPeerUser &&
                     message.Out.Value &&
                     user.Id.Value == message.ToId.Id.Value)
            {
                editMessage = true;
            }
            else if (chat != null &&
                     message.ToId is TLPeerChat &&
                     chat.Id.Value == message.ToId.Id.Value)
            {
                editMessage = true;
            }

            if (editMessage)
            {
                Execute.BeginOnUIThread(() =>
                {
                    var item = Items.FirstOrDefault(x => x.Index == update.Message.Index) as TLMessageCommon;
                    if (item == null)
                    {
                        return;
                    }

                    if (item != message)
                    {
                        item.Edit(message);
                    }

                    message       = item;
                    var item48    = item as TLMessage48;
                    var message48 = message as TLMessage48;
                    if (message48 != null && item48 != null)
                    {
                        message48.Entities = item48.Entities;
                    }
                    var message31 = message as TLMessage48;
                    if (message31 != null)
                    {
                        var mediaGeoLive = message31.Media as TLMessageMediaGeoLive;
                        if (mediaGeoLive != null)
                        {
                            mediaGeoLive.EditDate = message31.EditDate;
                            mediaGeoLive.Date     = message31.Date;
                            mediaGeoLive.NotifyOfPropertyChange(() => mediaGeoLive.Geo);
                            mediaGeoLive.NotifyOfPropertyChange(() => mediaGeoLive.EditDate);
                            mediaGeoLive.NotifyOfPropertyChange(() => mediaGeoLive.Active);

                            message31.NotifyOfPropertyChange(() => message31.Message);
                            message31.NotifyOfPropertyChange(() => message31.ReplyMarkup);

                            if (LocationPicker != null)
                            {
                                LocationPicker.UpdateLiveLocation(message31);
                            }
                            if (LiveLocationBadge != null)
                            {
                                LiveLocationBadge.UpdateLiveLocation(message31);
                            }

                            return;
                        }

                        message31.NotifyOfPropertyChange(() => message31.Message);
                        message31.NotifyOfPropertyChange(() => message31.Media);
                        message31.NotifyOfPropertyChange(() => message31.ReplyMarkup);

                        var mediaGame = message31.Media as TLMessageMediaGame;
                        if (mediaGame != null)
                        {
                            mediaGame.NotifyOfPropertyChange(() => mediaGame.Message);
                            mediaGame.NotifyOfPropertyChange(() => mediaGame.MessageVisibility);
                            mediaGame.NotifyOfPropertyChange(() => mediaGame.DescriptionVisibility);
                        }
                    }

                    var messageService = item as TLMessageService;
                    if (messageService != null)
                    {
                        var actionGameScore = messageService.Action as TLMessageActionGameScore;
                        if (actionGameScore != null)
                        {
                            messageService.NotifyOfPropertyChange(() => messageService.Self);
                        }
                    }
                });
            }
        }