Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPavilionG7 committed Nov 29, 2022
1 parent 195f8b1 commit 0893978
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
Expand Up @@ -212,10 +212,15 @@ private void setChannelTopic(String content) {

private void updateChannelTopic() {
String oldTopicContent = topicContent;
ChannelTopic topic = chatChannel.getTopic();
setChannelTopic(topic.getContent());
if (StringUtils.isNotBlank(topic.getAuthor())) {
onChatMessage(new ChatMessage(channelName, Instant.now(), topic.getAuthor(), i18n.get("chat.topicUpdated", oldTopicContent, topic.getContent())));
String newTopicContent = chatChannel.getTopic().getContent();
if (StringUtils.equals(oldTopicContent, newTopicContent)) {
return;
}

setChannelTopic(newTopicContent);
String username = chatChannel.getTopic().getAuthor();
if (StringUtils.isNotBlank(username) && chatChannel.getUser(username) != null) {
onChatMessage(new ChatMessage(channelName, Instant.now(), username, i18n.get("chat.topicUpdated", oldTopicContent, newTopicContent)));
}

if (topicPane.isDisable()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/faforever/client/chat/ChatChannel.java
Expand Up @@ -8,6 +8,7 @@
import javafx.collections.ObservableMap;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -72,6 +73,7 @@ public int getUserCount() {
return users.size();
}

@Nullable
public ChatChannelUser getUser(String username) {
return users.get(username);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/faforever/client/fx/PlatformService.java
Expand Up @@ -104,10 +104,11 @@ public void reveal(Path path) {
}
}


/**
* Show a Window, restore it to it's state before minimizing (normal/restored or maximized) and move it to foreground
* will only work on windows systems
* Note: An application cannot force a window to the foreground while the user is working with another window.
* Instead, Windows flashes the taskbar button of the window to notify the user.
*/
public void focusWindow(String windowTitle) {
focusWindow(windowTitle, null);
Expand All @@ -118,6 +119,7 @@ public void focusWindow(String windowTitle, @Nullable Long processId) {
if (!isWindows) {
return;
}
log.debug("Focus '{}' window", windowTitle);
focusWindow(getWindow(windowTitle, processId));
}

Expand Down
Expand Up @@ -357,7 +357,7 @@ public CompletableFuture<Void> onLoginButtonClicked() {

return oAuthValuesReceiver.receiveValues(redirectUriCandidates, state, verifier)
.thenCompose(values -> {
platformService.focusWindow(clientProperties.getMainWindowTitle());
platformService.focusWindow(i18n.get("login.title"));
String actualState = values.getState();
if (!state.equals(actualState)) {
handleInvalidSate(actualState, state);
Expand Down

0 comments on commit 0893978

Please sign in to comment.