-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d26aaa4
commit 390bed4
Showing
5 changed files
with
94 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/faforever/client/chat/ChatNavigation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.faforever.client.chat; | ||
|
||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.LinkedHashSet; | ||
|
||
@Component | ||
@Lazy | ||
@Slf4j | ||
public class ChatNavigation { // TODO: Not a very good name of class | ||
|
||
@Getter | ||
private final LinkedHashSet<ChatTab> currentTabs = new LinkedHashSet<>(); | ||
|
||
public boolean addTabIfMissing(String tabId) { | ||
return currentTabs.add(new ChatTab(tabId)); | ||
} | ||
|
||
public void removeTab(String tabId) { | ||
currentTabs.removeIf(chatTab -> chatTab.getId().equals(tabId)); | ||
} | ||
|
||
public String getLastOpenedTabId() { | ||
return currentTabs.stream().filter(ChatTab::isSelected).findFirst().map(ChatTab::getId).orElse(null); | ||
} | ||
|
||
public void setLastOpenedTabId(String tabId) { | ||
if (ChatController.ADD_CHANNEL_TAB_ID.equals(tabId)) { | ||
return; | ||
} | ||
|
||
currentTabs.stream() | ||
.peek(chatTab -> chatTab.setSelected(false)) | ||
.filter(chatTab -> chatTab.getId().equals(tabId)) | ||
.findFirst() | ||
.ifPresent(chatTab -> chatTab.setSelected(true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.faforever.client.chat; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
@EqualsAndHashCode(onlyExplicitlyIncluded = true) | ||
public class ChatTab { | ||
|
||
@EqualsAndHashCode.Include | ||
private final String id; | ||
@Setter | ||
private boolean selected; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters