diff --git a/app/view/career_interface.py b/app/view/career_interface.py index a7cbd61..ab9abe3 100644 --- a/app/view/career_interface.py +++ b/app/view/career_interface.py @@ -46,6 +46,7 @@ def __init__(self, parent=None): self.currentSummonerName = None self.puuid = None self.showTagLine = False + self.recentTeammatesInfo = None self.vBoxLayout = QVBoxLayout(self) self.IconNameHBoxLayout = QHBoxLayout() @@ -80,8 +81,8 @@ def __init__(self, parent=None): self.kdaLabel = QLabel(self.tr("KDA:") + " None / None / None") self.championsCard = ChampionsCard() self.recentTeamButton = PushButton(self.tr("Recent teammates")) - self.teammatesFlyout = TeammatesFlyOut() self.filterComboBox = ComboBox() + self.recentTeammatesFlyout: Flyout = None self.gameInfoAreaLayout = QHBoxLayout() self.gameInfoArea = SmoothScrollArea() @@ -382,6 +383,10 @@ async def updateInterface(self, puuid=None, summoner=None): assert summoner or puuid self.setLoadingPageEnabled(True) + self.recentTeammatesInfo = None + if self.recentTeammatesFlyout: + self.recentTeammatesFlyout.close() + self.recentTeammatesFlyout = None if summoner is None: summoner = await connector.getSummonerByPuuid(puuid) @@ -477,7 +482,6 @@ async def repaintInterface(self, info): self.__updateGameInfo() self.backToMeButton.setEnabled(not self.isCurrentSummoner()) - self.teammatesFlyout.updatePuuid(puuid) if 'champions' in info: self.championsCard.updateChampions(info['champions']) @@ -560,18 +564,20 @@ def isCurrentSummoner(self): return self.currentSummonerName == None or self.currentSummonerName == self.name.text() def __onRecentTeammatesButtonClicked(self): - self.w = Flyout.make( - self.teammatesFlyout, self.recentTeamButton, self, - aniType=FlyoutAnimationType.DROP_DOWN, isDeleteOnClose=False) + view = TeammatesFlyOut() + if self.info: + view.setLoadingPageEnabled(False) + view.updateSummoners(self.info) - async def __updateRecentTeammates(self): - self.teammatesFlyout.setLoadingPageEnabled(True) + self.recentTeammatesFlyout = Flyout.make( + view, self.recentTeamButton, self, FlyoutAnimationType.DROP_DOWN) - info = await getRecentTeammates( - self.games['games'], self.puuid) + async def __updateRecentTeammates(self): + self.info = await getRecentTeammates(self.games['games'], self.puuid) - self.teammatesFlyout.updateSummoners(info) - self.teammatesFlyout.setLoadingPageEnabled(False) + if self.recentTeammatesFlyout: + self.recentTeammatesFlyout.close() + self.__onRecentTeammatesButtonClicked() class TeammatesFlyOut(FlyoutViewBase): @@ -604,9 +610,6 @@ def __initLayout(self): self.stackedWidget.setFixedHeight(352) self.stackedWidget.setFixedWidth(490) - def updatePuuid(self, puuid): - self.puuid = puuid - def clear(self): for i in reversed(range(self.infopageVBoxLayout.count())): item = self.infopageVBoxLayout.itemAt(i) @@ -616,11 +619,6 @@ def clear(self): item.widget().deleteLater() def updateSummoners(self, info): - if self.puuid != info['puuid']: - return - - self.clear() - for summoner in info['summoners']: infoBar = TeammateInfoBar(summoner) self.infopageVBoxLayout.addWidget(infoBar)