Skip to content

Commit

Permalink
fix(server): displaying list of chats
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Feb 19, 2024
1 parent 6903da4 commit 946f5f0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ public final class StringUtils {
private StringUtils() {
}

/**
* Splits CSV string to list removing duplicates.
*/
public static List<String> toList(String s) {
return Arrays.asList(s.split("[,\\s]"));
}

public static Set<String> toIdSet(String s) {
Set<String> set = new HashSet<>();
String[] tokens = s.split("[,\\s]");
Expand All @@ -40,21 +33,6 @@ public static Set<String> toIdSet(String[] tokens) {
return set;
}

public static <T extends Enum<T>> Set<T> toEnumSet(String s, Class<T> typeClass) {
Set<T> set = new HashSet<>();
String[] tokens = s.split("[,\\s]");
for (String token : tokens) {
if (!token.isBlank()) {
try {
set.add(Enum.valueOf(typeClass, token.trim().toLowerCase()));
} catch (IllegalArgumentException ignored) {
// ignore invalid values
}
}
}
return set;
}

/**
* If the string is longer than maxLength it is split at the nearest blank space.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Uni<List<Chat>> chats(
Token token = securityIdentity.getCredential(Token.class);

return Chat.listByUser(token, user, order, page, perPage)
.flatMap(chats -> Multi.createFrom().iterable(chats).filter(chat -> chat.title == null).call(ChatResource::createChatTitle).collect().asList());
.call(chats -> Multi.createFrom().iterable(chats).filter(chat -> chat.title == null).map(ChatResource::createChatTitle).collect().asList());
}

private static Uni<List<ChatMessage>> createChatTitle(Chat chat) {
Expand Down

0 comments on commit 946f5f0

Please sign in to comment.