Don't ask joinAs for voice chats each time.
This commit is contained in:
		
							parent
							
								
									5d16359a5a
								
							
						
					
					
						commit
						c65c554d88
					
				
					 3 changed files with 21 additions and 9 deletions
				
			
		| 
						 | 
					@ -172,7 +172,7 @@ void ChooseJoinAsProcess::start(
 | 
				
			||||||
		Fn<void(object_ptr<Ui::BoxContent>)> showBox,
 | 
							Fn<void(object_ptr<Ui::BoxContent>)> showBox,
 | 
				
			||||||
		Fn<void(QString)> showToast,
 | 
							Fn<void(QString)> showToast,
 | 
				
			||||||
		Fn<void(JoinInfo)> done,
 | 
							Fn<void(JoinInfo)> done,
 | 
				
			||||||
		PeerData *currentJoinAs) {
 | 
							PeerData *changingJoinAsFrom) {
 | 
				
			||||||
	Expects(done != nullptr);
 | 
						Expects(done != nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const auto session = &peer->session();
 | 
						const auto session = &peer->session();
 | 
				
			||||||
| 
						 | 
					@ -243,14 +243,14 @@ void ChooseJoinAsProcess::start(
 | 
				
			||||||
			finish(info);
 | 
								finish(info);
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							const auto selectedId = peer->groupCallDefaultJoinAs();
 | 
				
			||||||
		info.joinAs = [&]() -> not_null<PeerData*> {
 | 
							info.joinAs = [&]() -> not_null<PeerData*> {
 | 
				
			||||||
			const auto selectedId = peer->groupCallDefaultJoinAs();
 | 
								const auto loaded = selectedId
 | 
				
			||||||
			if (!selectedId) {
 | 
									? session->data().peerLoaded(selectedId)
 | 
				
			||||||
				return self;
 | 
									: nullptr;
 | 
				
			||||||
			}
 | 
								return (changingJoinAsFrom
 | 
				
			||||||
			const auto loaded = session->data().peerLoaded(selectedId);
 | 
									&& ranges::contains(list, not_null{ changingJoinAsFrom }))
 | 
				
			||||||
			return (currentJoinAs && ranges::contains(list, not_null{ currentJoinAs }))
 | 
									? not_null(changingJoinAsFrom)
 | 
				
			||||||
				? not_null(currentJoinAs)
 | 
					 | 
				
			||||||
				: (loaded && ranges::contains(list, not_null{ loaded }))
 | 
									: (loaded && ranges::contains(list, not_null{ loaded }))
 | 
				
			||||||
				? not_null(loaded)
 | 
									? not_null(loaded)
 | 
				
			||||||
				: ranges::contains(list, self)
 | 
									: ranges::contains(list, self)
 | 
				
			||||||
| 
						 | 
					@ -259,6 +259,13 @@ void ChooseJoinAsProcess::start(
 | 
				
			||||||
		}();
 | 
							}();
 | 
				
			||||||
		info.possibleJoinAs = std::move(list);
 | 
							info.possibleJoinAs = std::move(list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!changingJoinAsFrom
 | 
				
			||||||
 | 
								&& selectedId
 | 
				
			||||||
 | 
								&& info.joinAs->id == selectedId) {
 | 
				
			||||||
 | 
								// We already joined this voice chat, just rejoin with the same.
 | 
				
			||||||
 | 
								finish(info);
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		auto box = Box(
 | 
							auto box = Box(
 | 
				
			||||||
			ChooseJoinAsBox,
 | 
								ChooseJoinAsBox,
 | 
				
			||||||
			context,
 | 
								context,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,7 @@ public:
 | 
				
			||||||
		Fn<void(object_ptr<Ui::BoxContent>)> showBox,
 | 
							Fn<void(object_ptr<Ui::BoxContent>)> showBox,
 | 
				
			||||||
		Fn<void(QString)> showToast,
 | 
							Fn<void(QString)> showToast,
 | 
				
			||||||
		Fn<void(JoinInfo)> done,
 | 
							Fn<void(JoinInfo)> done,
 | 
				
			||||||
		PeerData *currentJoinAs = nullptr);
 | 
							PeerData *changingJoinAsFrom = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	struct ChannelsListRequest {
 | 
						struct ChannelsListRequest {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -426,6 +426,11 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
 | 
				
			||||||
	LOG(("Call Info: Requesting join payload."));
 | 
						LOG(("Call Info: Requesting join payload."));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_joinAs = as;
 | 
						_joinAs = as;
 | 
				
			||||||
 | 
						if (const auto chat = _peer->asChat()) {
 | 
				
			||||||
 | 
							chat->setGroupCallDefaultJoinAs(_joinAs->id);
 | 
				
			||||||
 | 
						} else if (const auto channel = _peer->asChannel()) {
 | 
				
			||||||
 | 
							channel->setGroupCallDefaultJoinAs(_joinAs->id);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const auto weak = base::make_weak(this);
 | 
						const auto weak = base::make_weak(this);
 | 
				
			||||||
	_instance->emitJoinPayload([=](tgcalls::GroupJoinPayload payload) {
 | 
						_instance->emitJoinPayload([=](tgcalls::GroupJoinPayload payload) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue