Unverified Commit 736abef9 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge branch 'develop' into patch-3

parents 826d21e6 391a9361
......@@ -123,6 +123,7 @@ class ChatRoomPresenter @Inject constructor(
private var lastState = manager.state
private var typingStatusList = arrayListOf<String>()
private val roomChangesChannel = Channel<Room>(Channel.CONFLATED)
private lateinit var draftKey: String
fun setupChatRoom(
roomId: String,
......@@ -130,14 +131,17 @@ class ChatRoomPresenter @Inject constructor(
roomType: String,
chatRoomMessage: String? = null
) {
draftKey = "${currentServer}_${LocalRepository.DRAFT_KEY}$roomId"
chatRoomId = roomId
chatRoomType = roomType
launch(CommonPool + strategy.jobs) {
try {
chatRoomId = roomId
chatRoomType = roomType
chatRoles = if (roomTypeOf(roomType) !is RoomType.DirectMessage) {
client.chatRoomRoles(roomType = roomTypeOf(roomType), roomName = roomName)
} else emptyList()
} catch (ex: RocketChatException) {
} else {
emptyList()
}
} catch (ex: Exception) {
Timber.e(ex)
chatRoles = emptyList()
} finally {
......@@ -183,7 +187,6 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
}
......@@ -369,6 +372,7 @@ class ChatRoomPresenter @Inject constructor(
client.updateMessage(chatRoomId, messageId, text)
}
clearUnfinishedMessage()
view.enableSendMessageButton()
} catch (ex: Exception) {
Timber.d(ex, "Error sending message...")
......@@ -914,7 +918,7 @@ class ChatRoomPresenter @Inject constructor(
navigator.toChatDetails(chatRoomId, chatRoomType, isSubscribed, isMenuDisabled)
}
fun loadChatRooms() {
fun loadChatRoomsSuggestions() {
launchUI(strategy) {
try {
val chatRooms = getChatRoomsAsync()
......@@ -1286,31 +1290,26 @@ class ChatRoomPresenter @Inject constructor(
}
/**
* Save unfinished message, when user left chat room without sending a message. It also clears
* saved message from local repository when unfinishedMessage is blank.
* Save unfinished message, when user left chat room without sending a message.
*
* @param chatRoomId Chat room Id.
* @param unfinishedMessage The unfinished message to save.
*/
fun saveUnfinishedMessage(chatRoomId: String, unfinishedMessage: String) {
val key = "${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
fun saveUnfinishedMessage(unfinishedMessage: String) {
if (unfinishedMessage.isNotBlank()) {
localRepository.save(key, unfinishedMessage)
} else {
localRepository.clear(key)
localRepository.save(draftKey, unfinishedMessage)
}
}
fun clearUnfinishedMessage() {
localRepository.clear(draftKey)
}
/**
* Get unfinished message from local repository, when user left chat room without
* sending a message and now the user is back.
*
* @param chatRoomId Chat room Id.
*
* @return Returns the unfinished message.
* @return Returns the unfinished message, null otherwise.
*/
fun getUnfinishedMessage(chatRoomId: String): String {
val key = "${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
return localRepository.get(key) ?: ""
fun getUnfinishedMessage(): String? {
return localRepository.get(draftKey)
}
}
......@@ -27,7 +27,7 @@ interface LocalRepository {
const val SETTINGS_KEY = "settings_"
const val PERMISSIONS_KEY = "permissions_"
const val USER_KEY = "user_"
const val UNFINISHED_MSG_KEY = "unfinished_msg_"
const val DRAFT_KEY = "draft"
const val CURRENT_USERNAME_KEY = "username_"
const val LAST_CHATROOMS_REFRESH = "_chatrooms_refresh"
}
......
......@@ -146,7 +146,7 @@
<string name="msg_send">Sende</string>
<string name="msg_sent_attachment">Sende Anhang</string>
<string name="msg_welcome_to_rocket_chat">Willkommen bei Rocket.Chat</string>
<string name="msg_team_communication">Open Source-Kommunikation</string>
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email">Einloggen mit <b>e-mail</b></string>
<string name="msg_create_account">Ein Konto erstellen</string>
<string name="msg_continue_with_facebook">Weitermachen mit <b>Facebook</b></string>
......
......@@ -146,7 +146,7 @@
<string name="msg_delete_description">Seguro que quieres borrar este mensaje</string>
<string name="msg_no_search_found">No se han encontrado resultados</string>
<string name="msg_welcome_to_rocket_chat">Welcome to Rocket.Chat</string> <!-- TODO Add translation -->
<string name="msg_team_communication">Open Source Communication</string> <!-- TODO Add translation -->
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email">Login with <b>e-mail</b></string> <!-- TODO Add translation -->
<string name="msg_create_account">Create an account</string> <!-- TODO Add translation -->
<string name="msg_continue_with_facebook">Continue with <b>Facebook</b></string> <!-- TODO Add translation -->
......
......@@ -150,7 +150,7 @@
<string name="msg_delete_message">Supprimer Message</string>
<string name="msg_delete_description">Êtes-vous sûr de vouloir supprimer ce message</string>
<string name="msg_welcome_to_rocket_chat">Welcome to Rocket.Chat</string> <!-- TODO Add translation -->
<string name="msg_team_communication">Open Source Communication</string> <!-- TODO Add translation -->
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email">Login with <b>e-mail</b></string> <!-- TODO Add translation -->
<string name="msg_create_account">Create an account</string> <!-- TODO Add translation -->
<string name="msg_continue_with_facebook">Continue with <b>Facebook</b></string> <!-- TODO Add translation -->
......
......@@ -152,7 +152,7 @@
<string name="msg_delete_message">संदेश को हटाएं</string>
<string name="msg_delete_description">क्या आप निश्चित रूप से यह संदेश हटाना चाहते हैं</string>
<string name="msg_welcome_to_rocket_chat">Rocket.Chat में आपका स्वागत है</string>
<string name="msg_team_communication">ओपन सोर्स कम्युनिकेशन</string>
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email">ई-मेल के साथ लॉगिन करें</string>
<string name="msg_create_account">खाता बनाएं</string>
<string name="msg_continue_with_facebook"><b>Facebook</b> के साथ जारी रखें</string>
......
......@@ -146,7 +146,7 @@
<string name="msg_send">Inviare</string>
<string name="msg_sent_attachment">Inviato allegato</string>
<string name="msg_welcome_to_rocket_chat">Benvenuto in Rocket.Chat </string>
<string name="msg_team_communication">Team Communication</string>
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email">Accedi con <b>e-mail</b></string>
<string name="msg_create_account">Crea un utente</string>
<string name="msg_continue_with_facebook">Continua con <b>Facebook</b></string>
......
......@@ -151,7 +151,7 @@
<string name="msg_send">送信</string>
<string name="msg_sent_attachment">添付ファイルを送信しました</string>
<string name="msg_welcome_to_rocket_chat">Rocket.Chatへようこそ</string>
<string name="msg_team_communication">チームコミュニケーション</string>
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email"><b>e-mail</b>でログイン</string>
<string name="msg_create_account">アカウントを作成</string>
<string name="msg_continue_with_facebook"><b>Facebook</b>でログイン</string>
......
......@@ -151,7 +151,7 @@
<string name="msg_delete_message">Remove mensagem</string>
<string name="msg_delete_description">Tem certeza que quer apagar esta mensagem?</string>
<string name="msg_welcome_to_rocket_chat">Bem-vindo ao Rocket.Chat</string>
<string name="msg_team_communication">Comunicação Open Source</string>
<string name="msg_team_communication">Comunicação para equipes</string>
<string name="msg_login_with_email">Fazer login com <b>e-mail</b></string>
<string name="msg_create_account">Criar conta</string>
<string name="msg_continue_with_facebook">Continuar com <b>Facebook</b></string>
......
......@@ -149,7 +149,7 @@
<string name="msg_channel_name">Название канала</string>
<string name="msg_search">Поиск</string>
<string name="msg_welcome_to_rocket_chat">Rocket.Chat</string>
<string name="msg_team_communication">Чат с открытым исходным кодом</string>
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email">Войти с помощью <b>e-mail</b></string>
<string name="msg_create_account">Создать аккаунт</string>
<string name="msg_continue_with_facebook">Войти с помощью <b>Facebook</b></string>
......
......@@ -150,7 +150,7 @@
<string name="msg_send">Gönder</string>
<string name="msg_sent_attachment">Bir dosya eki gönderildi</string>
<string name="msg_welcome_to_rocket_chat">Welcome to Rocket.Chat</string> <!-- TODO Add translation -->
<string name="msg_team_communication">Team Communication</string> <!-- TODO Add translation -->
<string name="msg_team_communication">Team Communication</string> <!-- TODO Translate -->
<string name="msg_login_with_email">Login with <b>e-mail</b></string> <!-- TODO Add translation -->
<string name="msg_create_account">Create an account</string> <!-- TODO Add translation -->
<string name="msg_continue_with_facebook">Continue with <b>Facebook</b></string> <!-- TODO Add translation -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment