Unverified Commit 516f941d authored by Pancor's avatar Pancor Committed by GitHub

add support for muliserver

parent 1a0398f7
...@@ -49,8 +49,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView, ...@@ -49,8 +49,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
private val roomsRepository: RoomRepository, private val roomsRepository: RoomRepository,
private val localRepository: LocalRepository, private val localRepository: LocalRepository,
factory: ConnectionManagerFactory, factory: ConnectionManagerFactory,
private val mapper: ViewModelMapper, private val mapper: ViewModelMapper) {
private val localRepository: LocalRepository) {
private val currentServer = serverInteractor.get()!! private val currentServer = serverInteractor.get()!!
private val manager = factory.create(currentServer) private val manager = factory.create(currentServer)
private val client = manager.client private val client = manager.client
...@@ -85,8 +84,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView, ...@@ -85,8 +84,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
ex.message?.let { ex.message?.let {
view.showMessage(it) view.showMessage(it)
}.ifNull { }.ifNull {
view.showGenericErrorMessage() view.showGenericErrorMessage()
} }
} finally { } finally {
view.hideLoading() view.hideLoading()
} }
...@@ -112,8 +111,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView, ...@@ -112,8 +111,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
ex.message?.let { ex.message?.let {
view.showMessage(it) view.showMessage(it)
}.ifNull { }.ifNull {
view.showGenericErrorMessage() view.showGenericErrorMessage()
} }
} finally { } finally {
view.enableSendMessageButton() view.enableSendMessageButton()
} }
...@@ -148,8 +147,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView, ...@@ -148,8 +147,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
ex.message?.let { ex.message?.let {
view.showMessage(it) view.showMessage(it)
}.ifNull { }.ifNull {
view.showGenericErrorMessage() view.showGenericErrorMessage()
} }
} finally { } finally {
view.hideLoading() view.hideLoading()
} }
...@@ -164,7 +163,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView, ...@@ -164,7 +163,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
view.showMessage(ex.message!!) // TODO Remove. view.showMessage(ex.message!!) // TODO Remove.
Timber.e(ex) // FIXME: Right now we are only catching the exception with Timber. Timber.e(ex) // FIXME: Right now we are only catching the exception with Timber.
} }
} }
} }
private fun subscribeState() { private fun subscribeState() {
...@@ -563,7 +562,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView, ...@@ -563,7 +562,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
* @param unfinishedMessage The unfinished message to save. * @param unfinishedMessage The unfinished message to save.
*/ */
fun saveUnfinishedMessage(chatRoomId: String, unfinishedMessage: String) { fun saveUnfinishedMessage(chatRoomId: String, unfinishedMessage: String) {
val key = LocalRepository.UNFINISHED_MSG_KEY + chatRoomId val key = "${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
if (unfinishedMessage.isNotBlank()) { if (unfinishedMessage.isNotBlank()) {
localRepository.save(key, unfinishedMessage) localRepository.save(key, unfinishedMessage)
} else { } else {
...@@ -580,7 +579,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView, ...@@ -580,7 +579,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
* @return Returns the unfinished message. * @return Returns the unfinished message.
*/ */
fun getUnfinishedMessage(chatRoomId: String): String { fun getUnfinishedMessage(chatRoomId: String): String {
val key = LocalRepository.UNFINISHED_MSG_KEY + chatRoomId val key = "${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
return localRepository.get(key) ?: "" return localRepository.get(key) ?: ""
} }
} }
\ No newline at end of file
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