Display current account in the account chat header

This commit is contained in:
Eugene Zadyra
2018-06-09 00:28:28 +02:00
parent f049928da1
commit 1bff845c99
4 changed files with 11 additions and 4 deletions

View File

@@ -39,8 +39,9 @@ class Account(val userId: UserId, bot: Bot, dataService: DataService, val locali
whenSafe(AskAction) {
case Event(Next, _) =>
val credentials = dataService.getUserCredentials(userId.userId)
val currentAccount = credentials.find(c => c.accountId == userId.accountId).getOrElse(sys.error("Can't determine current account"))
val buttons = Seq(Button(lang.addAccount, -1L), Button(lang.deleteAccount, -2L)) ++ credentials.map(c => Button(s"🔐️ ${c.username}", c.accountId))
bot.sendMessage(userId.source, lang.pleaseChooseAccount, inlineKeyboard = createInlineKeyboard(buttons, columns = 1))
bot.sendMessage(userId.source, lang.pleaseChooseAccount(currentAccount.username), inlineKeyboard = createInlineKeyboard(buttons, columns = 1))
goto(AwaitAction)
}

View File

@@ -361,5 +361,8 @@ object En extends Lang {
override def accountSwitched(username: String): String =
s"✅ Account has been switched to <b>$username</b>"
override def pleaseChooseAccount: String = "<b>➡</b> Please choose an <b>action</b> or select <b>account</b>"
override def pleaseChooseAccount(currentAccountName: String): String =
s"""Current account is <b>$currentAccountName</b>
|
|<b>➡</b> Please choose an <b>action</b> or select <b>account</b>""".stripMargin
}

View File

@@ -238,7 +238,7 @@ trait Lang {
def addAccount: String
def pleaseChooseAccount: String
def pleaseChooseAccount(currentAccountName: String): String
def accountSwitched(username: String): String
}

View File

@@ -360,5 +360,8 @@ object Ua extends Lang {
override def accountSwitched(username: String): String =
s"✅ Аккаунт було переключено на <b>$username</b>"
override def pleaseChooseAccount: String = "<b>➡</b> Будь ласка, оберіть <b>дію</b> або виберіть <b>акаунт</b>"
override def pleaseChooseAccount(currentAccountName: String): String =
s"""Поточний акаунт <b>$currentAccountName</b>
|
|<b>➡</b> Будь ласка, оберіть <b>дію</b> або виберіть <b>акаунт</b>""".stripMargin
}