public void DeleteMember(TLUserBase user) { var channel = CurrentItem as TLChannel; if (channel == null) { return; } if (user == null) { return; } var rights = new TLChannelAdminRights { Flags = new TLInt(0) }; IsWorking = true; MTProtoService.EditAdminAsync(channel, user.ToInputUser(), rights, result => BeginOnUIThread(() => { IsWorking = false; Items.Remove(user); }), error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("channels.editAdmin error " + error); })); }
public void ForwardInAnimationComplete() { UpdateItems(); if (StateService.Participant != null) { var participant = StateService.Participant; StateService.Participant = null; var channel = CurrentItem as TLChannel; if (channel == null) { return; } IsWorking = true; MTProtoService.EditAdminAsync(channel, participant.ToInputUser(), new TLChannelRoleEditor(), result => Execute.BeginOnUIThread(() => { IsWorking = false; Items.Insert(0, participant); Status = Items.Count > 0 ? string.Empty : AppResources.NoUsersHere; }), error => Execute.BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("channels.inviteToChannel error " + error); })); } }
public void DeleteMember(TLUserBase user) { var channel = CurrentItem as TLChannel; if (channel == null) { return; } if (user == null) { return; } IsWorking = true; MTProtoService.EditAdminAsync(channel, user.ToInputUser(), new TLChannelRoleEmpty(), result => Execute.BeginOnUIThread(() => { IsWorking = false; Items.Remove(user); }), error => Execute.BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("channels.inviteToChannel error " + error); })); }
public void ForwardInAnimationComplete() { UpdateItems(); if (StateService.Participant != null) { var participant = StateService.Participant; StateService.Participant = null; var channel = CurrentItem as TLChannel; if (channel == null) { return; } var rights = GetDefaultAdminRights(channel.IsMegaGroup, new TLChannelRoleEditor()); IsWorking = true; MTProtoService.EditAdminAsync(channel, participant.ToInputUser(), rights, result => BeginOnUIThread(() => { IsWorking = false; var updates = result as TLUpdates; if (updates != null) { var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewChannelMessage) as TLUpdateNewChannelMessage; if (updateNewMessage != null) { EventAggregator.Publish(updateNewMessage.Message); } } Items.Insert(0, participant); var channelParticipants = channel.ChannelParticipants; if (channelParticipants != null) { var user = channelParticipants.Users.FirstOrDefault(x => x.Index == participant.Index); if (user == null) { channelParticipants.Users.Add(participant); channelParticipants.Participants.Add(new TLChannelParticipantAdmin { Flags = new TLInt(0), CanEdit = true, UserId = participant.Id, InviterId = new TLInt(StateService.CurrentUserId), PromotedById = new TLInt(StateService.CurrentUserId), Date = TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now), AdminRights = rights }); channelParticipants.Count = new TLInt(channelParticipants.Count.Value + 1); } } Status = Items.Count > 0 ? string.Empty : AppResources.NoUsersHere; }), error => BeginOnUIThread(() => { IsWorking = false; if (error.CodeEquals(ErrorCode.BAD_REQUEST)) { if (error.TypeEquals(ErrorType.ADMINS_TOO_MUCH)) { MessageBox.Show(AppResources.AdminsTooMuch, AppResources.Error, MessageBoxButton.OK); } } Execute.ShowDebugMessage("channels.editAdmin error " + error); })); } }