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
|
||||
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 {
|
||||
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.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.afterLoading
|
||||
import io.github.wulkanowy.utils.flowWithResource
|
||||
import io.github.wulkanowy.utils.flowWithResourceIn
|
||||
@ -65,18 +65,24 @@ class MessagePreviewPresenter @Inject constructor(
|
||||
Status.LOADING -> Timber.i("Loading message ${message.messageId} preview started")
|
||||
Status.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" })
|
||||
this@MessagePreviewPresenter.message = it.data.message
|
||||
this@MessagePreviewPresenter.attachments = it.data.attachments
|
||||
view?.apply {
|
||||
setMessageWithAttachment(it.data)
|
||||
initOptions()
|
||||
if (it.data != null) {
|
||||
this@MessagePreviewPresenter.message = it.data.message
|
||||
this@MessagePreviewPresenter.attachments = it.data.attachments
|
||||
view?.apply {
|
||||
setMessageWithAttachment(it.data)
|
||||
initOptions()
|
||||
}
|
||||
analytics.logEvent(
|
||||
"load_item",
|
||||
"type" to "message_preview",
|
||||
"length" to it.data.message.content.length
|
||||
)
|
||||
} else {
|
||||
view?.run {
|
||||
showMessage(messageNotExists)
|
||||
popView()
|
||||
}
|
||||
}
|
||||
analytics.logEvent(
|
||||
"load_item",
|
||||
"type" to "message_preview",
|
||||
"length" to it.data.message.content.length
|
||||
)
|
||||
}
|
||||
Status.ERROR -> {
|
||||
Timber.i("Loading message ${message.messageId} preview result: An exception occurred ")
|
||||
|
@ -14,6 +14,8 @@ interface MessagePreviewView : BaseView {
|
||||
|
||||
val printHTML: String
|
||||
|
||||
val messageNotExists: String
|
||||
|
||||
fun initView()
|
||||
|
||||
fun setMessageWithAttachment(item: MessageWithAttachment)
|
||||
|
@ -215,6 +215,7 @@
|
||||
<string name="message_subject">Temat</string>
|
||||
<string name="message_content">Treść</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_content_min_length">Treść wiadomości musi zawierać co najmniej 3 znaki</string>
|
||||
<plurals name="message_number_item">
|
||||
|
@ -223,6 +223,7 @@
|
||||
<string name="message_subject">Subject</string>
|
||||
<string name="message_content">Content</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_content_min_length">The message content must be at least 3 characters</string>
|
||||
<plurals name="message_number_item">
|
||||
|
Loading…
x
Reference in New Issue
Block a user