Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(groups): add peers if already playing audio when netcam created
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonybilinski committed Mar 8, 2019
1 parent 7c13b8b commit e489168
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/widget/form/groupchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ void GroupChatForm::peerAudioPlaying(ToxPk peerPk)
delete peerAudioTimers[peerPk];
peerAudioTimers[peerPk] = nullptr;
});
}
if (netcam) {
static_cast<GroupNetCamView*>(netcam)->removePeer(peerPk);
const auto nameIt = group->getPeerList().find(peerPk);
static_cast<GroupNetCamView*>(netcam)->addPeer(peerPk, nameIt.value());
if (netcam) {
static_cast<GroupNetCamView*>(netcam)->removePeer(peerPk);
const auto nameIt = group->getPeerList().find(peerPk);
static_cast<GroupNetCamView*>(netcam)->addPeer(peerPk, nameIt.value());
}
}

peerLabels[peerPk]->setStyleSheet(Style::getStylesheet(PEER_LABEL_STYLE_SHEET_PATH));
Expand Down Expand Up @@ -466,8 +466,17 @@ void GroupChatForm::onCallClicked()

GenericNetCamView* GroupChatForm::createNetcam()
{
// leave view empty, it will pe populated once we receive audio from peers
return new GroupNetCamView(group->getId(), this);
auto view = new GroupNetCamView(group->getId(), this);

const auto& names = group->getPeerList();
const auto ownPk = Core::getInstance()->getSelfPublicKey();
for (const auto& peerPk : names.keys()) {
auto timerIt = peerAudioTimers.find(peerPk);
if (peerPk != ownPk && timerIt != peerAudioTimers.end()) {
static_cast<GroupNetCamView*>(view)->addPeer(peerPk, names.find(peerPk).value());
}
}
return view;
}

void GroupChatForm::keyPressEvent(QKeyEvent* ev)
Expand Down

0 comments on commit e489168

Please sign in to comment.