-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remember last opened chat tab (#3205)
* remember last opened chat tab * replace from stream to foreach * remove unused annotations * redo ChatControllerTest * clear chat navigation when chat is disconnected * use `isCloseable` condition for remember chat tab
- Loading branch information
1 parent
339162e
commit 7c903c8
Showing
6 changed files
with
224 additions
and
124 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
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
package com.faforever.client.chat; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.LinkedHashSet; | ||
|
||
@Component | ||
@Lazy | ||
public class ChatNavigation { | ||
|
||
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)); | ||
} | ||
|
||
@Nullable | ||
public String getLastOpenedTabId() { | ||
return currentTabs.stream().filter(ChatTab::isSelected).findFirst().map(ChatTab::getId).orElse(null); | ||
} | ||
|
||
public void setLastOpenedTabId(String tabId) { | ||
currentTabs.forEach(tab -> tab.setSelected(tab.getId().equals(tabId))); | ||
} | ||
|
||
public void clear() { | ||
currentTabs.clear(); | ||
} | ||
} |
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; | ||
} |
Oops, something went wrong.