public static bool ShowDraft(TLDialog53 dialog)
        {
            if (dialog == null)
            {
                return(false);
            }

            var draft = dialog.Draft as TLDraftMessage;

            if (draft != null)
            {
                if (dialog.Peer is TLPeerChannel)
                {
                    var channel = dialog.With as TLChannel;
                    if (channel != null && channel.IsBroadcast && !channel.Creator && !channel.IsEditor)
                    {
                        return(false);
                    }
                }

                var topMessage = dialog.TopMessage as TLMessageCommon;
                if (topMessage != null && !topMessage.Out.Value && topMessage.Unread.Value)
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
        public static void CreateSecretChatCommon(TLUserBase user, TLDHConfig dhConfig, IMTProtoService mtProtoService, ICacheService cacheService, INavigationService navigationService, IStateService stateService, ITelegramEventAggregator eventAggregator)
        {
            if (user == null)
            {
                return;
            }

            var random   = new Random();
            var randomId = random.Next();

            mtProtoService.RequestEncryptionAsync(user.ToInputUser(), new TLInt(randomId), dhConfig.GA,
                                                  encryptedChat =>
            {
                var chatWaiting = encryptedChat as TLEncryptedChatWaiting;

                if (chatWaiting != null)
                {
                    var action   = new TLMessageActionChatCreate();
                    action.Title = TLString.Empty;
                    action.Users = new TLVector <TLInt> {
                        Items = new List <TLInt> {
                            user.Id
                        }
                    };

                    var dialog             = new TLDialog53();
                    dialog.Flags           = new TLInt(0);
                    dialog.ReadOutboxMaxId = new TLInt(0);
                    dialog.ReadInboxMaxId  = new TLInt(0);
                    dialog.With            = user;
                    dialog.Peer            = new TLPeerUser {
                        Id = user.Id
                    };

                    var topMessage    = new TLMessageService17();
                    topMessage.Date   = chatWaiting.Date;
                    topMessage.FromId = chatWaiting.AdminId;
                    topMessage.ToId   = new TLPeerUser {
                        Id = user.Id
                    };
                    topMessage.Out    = new TLBool(true);
                    topMessage.Action = action;
                    topMessage.SetUnread(new TLBool(false));

                    chatWaiting.A = dhConfig.A;
                    chatWaiting.P = dhConfig.P;
                    chatWaiting.G = dhConfig.G;
                }

                stateService.RemoveBackEntry = true;
                stateService.With            = chatWaiting;
                stateService.Participant     = user;

                Execute.BeginOnUIThread(() =>
                {
                    stateService.AnimateTitle = true;
                    navigationService.UriFor <SecretDialogDetailsViewModel>().Navigate();
                });


                //syncing chat and message
                cacheService.SyncEncryptedChat(chatWaiting, eventAggregator.Publish);

                var message = new TLDecryptedMessageService17
                {
                    RandomId = TLLong.Random(),
                    //RandomBytes = TLString.Random(Telegram.Api.Constants.MinRandomBytesLength),
                    ChatId = chatWaiting.Id,
                    Action = new TLDecryptedMessageActionEmpty(),
                    FromId = new TLInt(stateService.CurrentUserId),
                    Date   = chatWaiting.Date,
                    Out    = new TLBool(false),
                    Unread = new TLBool(false),
                    Status = MessageStatus.Read
                };

                cacheService.SyncDecryptedMessage(message, chatWaiting, result => { });
            },
                                                  error =>
            {
                Execute.ShowDebugMessage("messages.requestEncryption error " + error);
            });
        }