Пример #1
0
        public void Done()
        {
            if (IsWorking)
            {
                return;
            }

            var chat = CurrentItem as TLChat;

            if (chat != null)
            {
                IsWorking = true;
                MTProtoService.EditChatTitleAsync(chat.Id, new TLString(Title),
                                                  statedMessage =>
                {
                    IsWorking = false;

                    var updates = statedMessage as TLUpdates;
                    if (updates != null)
                    {
                        var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewMessage) as TLUpdateNewMessage;
                        if (updateNewMessage != null)
                        {
                            EventAggregator.Publish(updateNewMessage.Message);
                            BeginOnUIThread(() => NavigationService.GoBack());
                        }
                    }
                },
                                                  error =>
                {
                    Execute.ShowDebugMessage("messages.editChatTitle error " + error);

                    IsWorking = false;
                    BeginOnUIThread(() => NavigationService.GoBack());
                });
                return;
            }

            var channel = CurrentItem as TLChannel;

            if (channel != null)
            {
                EditChannelAboutAsync(channel, new TLString(About),
                                      () => EditChannelTitleAsync(channel, new TLString(Title),
                                                                  () => NavigationService.GoBack()));

                return;
            }

            var broadcastChat = CurrentItem as TLBroadcastChat;

            if (broadcastChat != null)
            {
                broadcastChat.Title = new TLString(Title);
                CacheService.SyncBroadcast(broadcastChat, result => BeginOnUIThread(() => NavigationService.GoBack()));
                return;
            }
        }