Skip to content

Commit

Permalink
修复了重启客户端后事件监听失效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Aug 7, 2023
1 parent 62f6c16 commit 579ea08
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Config(QConfig):

YEAR = 2023
AUTHOR = "Zaphkiel"
VERSION = "0.2.1"
VERSION = "0.2.2"
FEEDBACK_URL = "https://github.com/Zzaphkiel/Seraphine/issues"
GITHUB_URL = "https://github.com/Zzaphkiel/Seraphine"

Expand Down
5 changes: 4 additions & 1 deletion app/lol/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ async def main():
wllp = await willump.start()
allEventSubscription = await wllp.subscribe('OnJsonApiEvent')

res = await wllp.request("get", "/lol-summoner/v1/current-summoner")
res = await res.json()

# 订阅改头像 / 改名字消息
wllp.subscription_filter_endpoint(
allEventSubscription,
f'/lol-summoner/v1/summoners/{self.parent().currentSummoner.summonerId}',
f'/lol-summoner/v1/summoners/{res["summonerId"]}',
onCurrentSummonerProfileChanged)

# 订阅游戏状态改变消息
Expand Down
7 changes: 5 additions & 2 deletions app/view/career_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CareerInterface(ScrollArea):
def __init__(self, parent=None):
super().__init__(parent)
self.summoner: Summoner = None
self.currentSummonerName: Summoner = None

self.vBoxLayout = QVBoxLayout(self)
self.IconNameHBoxLayout = QHBoxLayout()
Expand Down Expand Up @@ -483,7 +484,9 @@ def __onfilterComboBoxChanged(self, index):
self.gameInfoLayout.addSpacerItem(
QSpacerItem(1, 1, QSizePolicy.Minimum, QSizePolicy.Expanding))

def setCurrentSummonerName(self, name):
self.currentSummonerName = name

def isCurrentSummoner(self):
summoner: Summoner = self.parent().parent().parent().currentSummoner

return summoner == None or summoner.name == self.name.text()
return self.currentSummonerName == None or self.currentSummonerName == self.name.text()
6 changes: 5 additions & 1 deletion app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ def __changeCareerToCurrentSummoner(self):
xpSinceLastLevel = self.currentSummoner.xpSinceLastLevel
xpUntilNextLevel = self.currentSummoner.xpUntilNextLevel

self.careerInterface.currentSummonerName = name

self.rankInfo = self.lolConnector.getRankedStatsByPuuid(
self.currentSummoner.puuid)
gamesInfo = self.lolConnector.getSummonerGamesByPuuid(
Expand Down Expand Up @@ -293,6 +295,8 @@ def _():
self.isClientProcessRunning = False

self.currentSummoner = None
self.careerInterface.setCurrentSummonerName(None)

icon = "app/resource/images/game.png"
name = self.tr("Start LOL")

Expand All @@ -308,7 +312,7 @@ def _():
self.auxiliaryFuncInterface.removeTokensCard.lolConnector = None
self.auxiliaryFuncInterface.createPracticeLobbyCard.lolConnector = None

self.eventListener.exit()
self.eventListener.terminate()

threading.Thread(target=_).start()

Expand Down

0 comments on commit 579ea08

Please sign in to comment.