示例#1
0
        private void ExportInvite()
        {
            if (IsWorking)
            {
                return;
            }
            if (Invite != null)
            {
                return;
            }

            IsWorking = true;
            MTProtoService.ExportInviteAsync(_newChannel.ToInputChannel(),
                                             result => Execute.BeginOnUIThread(() =>
            {
                IsWorking          = false;
                Invite             = result;
                var inviteExported = Invite as TLChatInviteExported;
                if (inviteExported != null)
                {
                    if (!TLString.IsNullOrEmpty(inviteExported.Link))
                    {
                        InviteLink = inviteExported.Link.ToString();
                    }
                }
            }),
                                             error => Execute.BeginOnUIThread(() =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("channels.exportInvite error " + error);
            }));
        }
        private void ExportChatInviteAsync()
        {
            var channel = _chat as TLChannel;

            if (channel != null)
            {
                IsWorking = true;
                MTProtoService.ExportInviteAsync(channel.ToInputChannel(),
                                                 chatInviteBase => BeginOnUIThread(() =>
                {
                    IsWorking = false;
                    var chatInviteExported = chatInviteBase as TLChatInviteExported;
                    if (chatInviteExported != null)
                    {
                        Link = chatInviteExported.Link.ToString();
                    }
                    else
                    {
                        Link = string.Empty;
                    }

                    _chat.ExportedInvite = chatInviteExported;
                    CacheService.Commit();
                }),
                                                 error => BeginOnUIThread(() =>
                {
                    IsWorking = false;
                }));

                return;
            }

            IsWorking = true;
            MTProtoService.ExportChatInviteAsync(_chat.Id,
                                                 chatInviteBase => BeginOnUIThread(() =>
            {
                IsWorking = false;
                var chatInviteExported = chatInviteBase as TLChatInviteExported;
                if (chatInviteExported != null)
                {
                    Link = chatInviteExported.Link.ToString();
                }
                else
                {
                    Link = string.Empty;
                }

                _chat.ExportedInvite = chatInviteExported;
                CacheService.Commit();
            }),
                                                 error => BeginOnUIThread(() =>
            {
                IsWorking = false;
            }));
        }