Ejemplo n.º 1
0
        public void DeleteChannel()
        {
            var channel = CurrentItem as TLChannel;

            if (channel == null || !channel.Creator)
            {
                return;
            }

            var confirmationString = channel.IsMegaGroup
                ? AppResources.DeleteGroupConfirmation
                : AppResources.DeleteChannelConfirmation;

            var confirmation = MessageBox.Show(confirmationString, AppResources.Confirm, MessageBoxButton.OKCancel);

            if (confirmation != MessageBoxResult.OK)
            {
                return;
            }

            IsWorking = true;
            MTProtoService.DeleteChannelAsync(channel,
                                              result => BeginOnUIThread(() =>
            {
                IsWorking = false;

                ContinueDeleteChannel(channel);
            }),
                                              error => BeginOnUIThread(() =>
            {
                Execute.ShowDebugMessage("channels.deleteChannel error " + error);

                IsWorking = false;

                if (error.CodeEquals(ErrorCode.BAD_REQUEST) &&
                    error.TypeEquals(ErrorType.CHANNEL_PRIVATE))
                {
                    ContinueDeleteChannel(channel);
                }
            }));
        }