private void OnTick(object sender, object e) { if (_call != null && _call.ScheduledStartDate != 0) { JoinButton.Content = _call.GetStartsIn(); } else { _scheduledTimer.Stop(); } }
public bool UpdateGroupCall(Chat chat, GroupCall call) { var visible = true; var channel = call?.IsRtmpStream is true || (chat.Type is ChatTypeSupergroup super && super.IsChannel); //if (chat.VideoChat.GroupCallId != call?.Id || !chat.VideoChat.HasParticipants || call == null || call.IsJoined) //{ // ShowHide(false); // visible = false; //} //else if (call != null && chat.VideoChat.GroupCallId == call.Id && ((chat.VideoChat.HasParticipants && !(call.IsJoined || call.NeedRejoin)) || call.ScheduledStartDate > 0)) { ShowHide(true); TitleLabel.Text = call.ScheduledStartDate > 0 && call.Title.Length > 0 ? call.Title : channel ? Strings.Resources.VoipChannelVoiceChat : Strings.Resources.VoipGroupVoiceChat; ServiceLabel.Text = call.ParticipantCount > 0 ? Locale.Declension("Participants", call.ParticipantCount) : Strings.Resources.MembersTalkingNobody; if (call.ScheduledStartDate != 0) { var date = Converters.Converter.DateTime(call.ScheduledStartDate); var duration = date - DateTime.Now; if (duration.TotalDays < 1) { _scheduledTimer.Start(); } else { _scheduledTimer.Stop(); } TitleLabel.Text = call.Title.Length > 0 ? call.Title : channel ? Strings.Resources.VoipChannelScheduledVoiceChat : Strings.Resources.VoipGroupScheduledVoiceChat; JoinButton.Background = BootStrapper.Current.Resources["VideoChatPurpleBrush"] as Brush; JoinButton.Content = call.GetStartsIn(); } else { _scheduledTimer.Stop(); TitleLabel.Text = channel ? Strings.Resources.VoipChannelVoiceChat : Strings.Resources.VoipGroupVoiceChat; JoinButton.Background = BootStrapper.Current.Resources["StartButtonBackground"] as Brush; JoinButton.Content = Strings.Resources.VoipChatJoin; } if (call.HasHiddenListeners) { RecentUsers.Items.Clear(); } else { if (RecentUsers.Items.Count > 0 && _call?.Id == call.Id) { RecentUsers.Items.ReplaceDiff(call.RecentSpeakers.Select(x => x.ParticipantId)); } else { RecentUsers.Items.Clear(); RecentUsers.Items.AddRange(call.RecentSpeakers.Select(x => x.ParticipantId)); } } } else { ShowHide(false); visible = false; } _call = call; return(visible); }
public bool UpdateGroupCall(Chat chat, GroupCall call) { var visible = true; //if (chat.VoiceChat.GroupCallId != call?.Id || !chat.VoiceChat.HasParticipants || call == null || call.IsJoined) //{ // ShowHide(false); // visible = false; //} //else if (call != null && chat.VoiceChat.GroupCallId == call.Id && ((chat.VoiceChat.HasParticipants && !(call.IsJoined || call.NeedRejoin)) || call.ScheduledStartDate > 0)) { ShowHide(true); TitleLabel.Text = call.ScheduledStartDate > 0 && call.Title.Length > 0 ? call.Title : Strings.Resources.VoipGroupVoiceChat; ServiceLabel.Text = call.ParticipantCount > 0 ? Locale.Declension("Participants", call.ParticipantCount) : Strings.Resources.MembersTalkingNobody; if (call.ScheduledStartDate != 0) { var date = Converters.Converter.DateTime(call.ScheduledStartDate); var duration = date - DateTime.Now; if (duration.TotalDays < 1) { _scheduledTimer.Start(); } else { _scheduledTimer.Stop(); } TitleLabel.Text = call.Title.Length > 0 ? call.Title : Strings.Resources.VoipGroupScheduledVoiceChat; JoinButton.Background = BootStrapper.Current.Resources["VoiceChatPurpleBrush"] as Brush; JoinButton.Content = call.GetStartsIn(); } else { _scheduledTimer.Stop(); TitleLabel.Text = Strings.Resources.VoipGroupVoiceChat; JoinButton.Background = BootStrapper.Current.Resources["StartButtonBackground"] as Brush; JoinButton.Content = Strings.Resources.VoipChatJoin; } var destination = RecentUsers.Items; var origin = call.RecentSpeakers; if (_call?.Id == call.Id) { for (int i = 0; i < origin.Count; i++) { var item = origin[i]; var index = -1; for (int j = 0; j < destination.Count; j++) { if (destination[j].IsEqual(item.ParticipantId)) { index = j; break; } } if (index > -1 && index != i) { destination.Move(index, Math.Min(i, destination.Count)); } else if (index == -1) { destination.Insert(Math.Min(i, destination.Count), item.ParticipantId); } } for (int i = 0; i < destination.Count; i++) { var item = destination[i]; var index = -1; for (int j = 0; j < origin.Count; j++) { if (origin[j].ParticipantId.IsEqual(item)) { index = j; break; } } if (index == -1) { destination.Remove(item); i--; } } } else { RecentUsers.Items.ReplaceWith(origin.Select(x => x.ParticipantId)); } } else { ShowHide(false); visible = false; } _call = call; return(visible); }