-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #944 click user game announcement link if game has ended #946
base: develop
Are you sure you want to change the base?
fix #944 click user game announcement link if game has ended #946
Conversation
src/chat/channel.py
Outdated
@@ -199,7 +199,12 @@ def pingWindow(self): | |||
def openUrl(self, url): | |||
logger.debug("Clicked on URL: " + url.toString()) | |||
if url.scheme() == "faflive": | |||
replay(url) | |||
if replay(url) == "Replays": # game ended -> Search Replaya |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't accept this kind of hack. If we want to pull the player id from the url, let's not hack it directly out of the url string, this is fragile as hell. I guess QUrl is the only thing we have here, but making a dedicated class for parsing and constructing these out of player / game data would be much more robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I added something to the QUrl (it was the game-uid) in the past you ripped my head of, so I worked here with what I got.
I would have no problem with spicing up the QUrl with 1-2 more attr.
(Keep in mind, this is a fix of a pretty old bug (not a refactor), which wasn't that noticeable with the rare friend host announcement - but will be once the friend announcement will come in.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly, my issue was with the exact same thing - raw parsing of the url string. I'd really like to see a separate class for both building and parsing these game URLs.
src/chat/channel.py
Outdated
# hack to get player name from url | ||
player_id = int(url.path().split("/")[2].split(".")[0]) | ||
if player_id in self._chatterset._playerset._players: | ||
player = self._chatterset._playerset._players[player_id].login |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holy shit, these two lines. Class members starting with an underscore are private, this should be respected. If we need a playerset in the class, pass it in the constructor. Playerset itself has dict-like semantics, there are plenty examples for it in existing code.
If we make a dedicated class for handling these URLs, then using playerset directly won't even be necessary.
src/fa/replay.py
Outdated
@@ -87,7 +87,15 @@ def replay(source, detach=False): | |||
if url.scheme() == "faflive": | |||
mod = QtCore.QUrlQuery(url).queryItemValue("mod") | |||
mapname = QtCore.QUrlQuery(url).queryItemValue("map") | |||
replay_id = url.path().split("/")[0] | |||
replay_id = url.path().split("/")[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the url as above.
src/fa/replay.py
Outdated
"Would you like to look for it in Replays?", | ||
QtWidgets.QMessageBox.Yes, | ||
QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.Yes: | ||
return "Replays" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return type doesn't match up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't we flexible there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an excuse. This return type means something to the caller, adding something out of the blue is unacceptable.
src/fa/replay.py
Outdated
replay_id = url.path().split("/")[0] | ||
replay_id = url.path().split("/")[1] | ||
if int(replay_id) not in client.instance.gameset: | ||
if QtWidgets.QMessageBox.question(client.instance, "Live Game ended", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is blocking, but there's another example of it in this function already, so I guess it's good.
e7f7fca
to
06265cc
Compare
06265cc
to
07c337e
Compare
07c337e
to
2b57343
Compare
2b57343
to
f372ce7
Compare
f372ce7
to
5447f62
Compare
5447f62
to
b01d5f5
Compare
b01d5f5
to
3994188
Compare
3994188
to
568a2fd
Compare
568a2fd
to
c3f305e
Compare
95582af
to
a2f6f4a
Compare
click on player live game announcement when game had ended, let to fa starting with error message. Now it will give a message about game ended, with an option to search users replays in Vault click on host/join game announcent when the game has already started, now will gives a message with an option to watch the live game
a2f6f4a
to
fd177f3
Compare
In Chat a click on player live game announcement when game had ended, let to fa starting with error message.
Now it will give a message about game ended, with an option to search the users replays in Vault.
And click on host game announcements will now be checked for game started (message with option to watch the live game) and game ended (message).