Skip to content

Commit

Permalink
ProfilePage: Tabs and Telegram Stuff. Fix (#998)
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Muravja <[email protected]>
  • Loading branch information
Aleksandr Muravja committed Jan 22, 2023
1 parent 9dc9c1c commit 8e95c75
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/pm/axe/ui/pages/user/profile/tabs/ProfileTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ public void tabInit(final User user) {

//telegram section
FlexLayout telegramLayout = new FlexLayout();
telegramLayout.setAlignItems(Alignment.BASELINE);

Optional<Account> telegramAccount = getTelegramAccount();
if (telegramAccount.isPresent()) {
Optional<String> telegramUsername = getTelegramUsername();
if (telegramAccount.isPresent() && telegramUsername.isPresent()) { //FIXME fix logic
TextField telegramField = new TextField("Telegram");
telegramField.setPrefixComponent(VaadinIcon.AT.create());
telegramField.setValue(telegramAccount.get().getAccountName());
telegramField.setValue(telegramUsername.get());
Button unlink = new Button("Unlink");
telegramLayout.add(telegramField, unlink);
} else {
Expand Down Expand Up @@ -139,4 +142,13 @@ private Optional<Token> getTelegramToken() {
}
return Optional.ofNullable(tgToken);
}

private Optional<String> getTelegramUsername() {
Optional<Account> telegramAccount = getTelegramAccount();
if (telegramAccount.isPresent()) {
return accountService.decryptAccountName(telegramAccount.get());
} else {
return Optional.empty();
}
}
}

0 comments on commit 8e95c75

Please sign in to comment.