forked from github/wulkanowy-mirror
Show appropriate message when message does not exist (#1083)
This commit is contained in:
parent
9128e0b55f
commit
e6e9d201ce
@ -65,6 +65,9 @@ class MessagePreviewFragment :
|
|||||||
override val printHTML: String
|
override val printHTML: String
|
||||||
get() = requireContext().assets.open("message-print-page.html").bufferedReader().use { it.readText() }
|
get() = requireContext().assets.open("message-print-page.html").bufferedReader().use { it.readText() }
|
||||||
|
|
||||||
|
override val messageNotExists: String
|
||||||
|
get() = getString(R.string.message_not_exists)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MESSAGE_ID_KEY = "message_id"
|
const val MESSAGE_ID_KEY = "message_id"
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ import io.github.wulkanowy.data.repositories.MessageRepository
|
|||||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
|
||||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.afterLoading
|
import io.github.wulkanowy.utils.afterLoading
|
||||||
import io.github.wulkanowy.utils.flowWithResource
|
import io.github.wulkanowy.utils.flowWithResource
|
||||||
import io.github.wulkanowy.utils.flowWithResourceIn
|
import io.github.wulkanowy.utils.flowWithResourceIn
|
||||||
@ -65,7 +65,7 @@ class MessagePreviewPresenter @Inject constructor(
|
|||||||
Status.LOADING -> Timber.i("Loading message ${message.messageId} preview started")
|
Status.LOADING -> Timber.i("Loading message ${message.messageId} preview started")
|
||||||
Status.SUCCESS -> {
|
Status.SUCCESS -> {
|
||||||
Timber.i("Loading message ${message.messageId} preview result: Success ")
|
Timber.i("Loading message ${message.messageId} preview result: Success ")
|
||||||
checkNotNull(it.data, { "Can't find message in local db! Probably no longer exist in this folder" })
|
if (it.data != null) {
|
||||||
this@MessagePreviewPresenter.message = it.data.message
|
this@MessagePreviewPresenter.message = it.data.message
|
||||||
this@MessagePreviewPresenter.attachments = it.data.attachments
|
this@MessagePreviewPresenter.attachments = it.data.attachments
|
||||||
view?.apply {
|
view?.apply {
|
||||||
@ -77,6 +77,12 @@ class MessagePreviewPresenter @Inject constructor(
|
|||||||
"type" to "message_preview",
|
"type" to "message_preview",
|
||||||
"length" to it.data.message.content.length
|
"length" to it.data.message.content.length
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
view?.run {
|
||||||
|
showMessage(messageNotExists)
|
||||||
|
popView()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Status.ERROR -> {
|
Status.ERROR -> {
|
||||||
Timber.i("Loading message ${message.messageId} preview result: An exception occurred ")
|
Timber.i("Loading message ${message.messageId} preview result: An exception occurred ")
|
||||||
|
@ -14,6 +14,8 @@ interface MessagePreviewView : BaseView {
|
|||||||
|
|
||||||
val printHTML: String
|
val printHTML: String
|
||||||
|
|
||||||
|
val messageNotExists: String
|
||||||
|
|
||||||
fun initView()
|
fun initView()
|
||||||
|
|
||||||
fun setMessageWithAttachment(item: MessageWithAttachment)
|
fun setMessageWithAttachment(item: MessageWithAttachment)
|
||||||
|
@ -215,6 +215,7 @@
|
|||||||
<string name="message_subject">Temat</string>
|
<string name="message_subject">Temat</string>
|
||||||
<string name="message_content">Treść</string>
|
<string name="message_content">Treść</string>
|
||||||
<string name="message_send_successful">Wiadomość wysłana pomyślnie</string>
|
<string name="message_send_successful">Wiadomość wysłana pomyślnie</string>
|
||||||
|
<string name="message_not_exists">Wiadomość nie istnieje</string>
|
||||||
<string name="message_required_recipients">Musisz wybrać co najmniej 1 adresata</string>
|
<string name="message_required_recipients">Musisz wybrać co najmniej 1 adresata</string>
|
||||||
<string name="message_content_min_length">Treść wiadomości musi zawierać co najmniej 3 znaki</string>
|
<string name="message_content_min_length">Treść wiadomości musi zawierać co najmniej 3 znaki</string>
|
||||||
<plurals name="message_number_item">
|
<plurals name="message_number_item">
|
||||||
|
@ -223,6 +223,7 @@
|
|||||||
<string name="message_subject">Subject</string>
|
<string name="message_subject">Subject</string>
|
||||||
<string name="message_content">Content</string>
|
<string name="message_content">Content</string>
|
||||||
<string name="message_send_successful">Message sent successfully</string>
|
<string name="message_send_successful">Message sent successfully</string>
|
||||||
|
<string name="message_not_exists">Message does not exist</string>
|
||||||
<string name="message_required_recipients">You need to choose at least 1 recipient</string>
|
<string name="message_required_recipients">You need to choose at least 1 recipient</string>
|
||||||
<string name="message_content_min_length">The message content must be at least 3 characters</string>
|
<string name="message_content_min_length">The message content must be at least 3 characters</string>
|
||||||
<plurals name="message_number_item">
|
<plurals name="message_number_item">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user