mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 13:48:20 +01:00
[Messages] Fix opening messages.
This commit is contained in:
parent
03c9932b8c
commit
91a6366548
@ -123,14 +123,26 @@ class MessageFragment : Fragment(), CoroutineScope {
|
|||||||
val msg =
|
val msg =
|
||||||
if (messageString != null)
|
if (messageString != null)
|
||||||
app.gson.fromJson(messageString, MessageFull::class.java)?.also {
|
app.gson.fromJson(messageString, MessageFull::class.java)?.also {
|
||||||
//it.body = null
|
if (arguments?.getLong("sentDate") ?: 0L > 0L)
|
||||||
it.addedDate = arguments?.getLong("sentDate") ?: System.currentTimeMillis()
|
it.addedDate = arguments?.getLong("sentDate") ?: 0L
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
app.db.messageDao().getByIdNow(App.profileId, messageId)
|
app.db.messageDao().getByIdNow(App.profileId, messageId)
|
||||||
|
|
||||||
|
// load recipients in sent messages
|
||||||
|
val teachers by lazy { app.db.teacherDao().getAllNow(App.profileId) }
|
||||||
|
msg?.recipients?.forEach { recipient ->
|
||||||
|
if (recipient.fullName == null) {
|
||||||
|
recipient.fullName = teachers.firstOrNull { it.id == recipient.id }?.fullName ?: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg?.type == TYPE_SENT && msg.senderName == null) {
|
||||||
|
msg.senderName = app.profile.accountName ?: app.profile.studentNameLong
|
||||||
|
}
|
||||||
|
|
||||||
msg?.also {
|
msg?.also {
|
||||||
it.recipients = app.db.messageRecipientDao().getAllByMessageId(it.profileId, it.id)
|
//it.recipients = app.db.messageRecipientDao().getAllByMessageId(it.profileId, it.id)
|
||||||
if (it.body != null && !it.seen) {
|
if (it.body != null && !it.seen) {
|
||||||
app.db.metadataDao().setSeen(it.profileId, it, true)
|
app.db.metadataDao().setSeen(it.profileId, it, true)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,9 @@ class MessagesListFragment : LazyFragment(), CoroutineScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val adapter = MessagesAdapter(activity, teachers) {
|
val adapter = MessagesAdapter(activity, teachers) {
|
||||||
|
activity.loadTarget(MainActivity.TARGET_MESSAGES_DETAILS, Bundle(
|
||||||
|
"messageId" to it.id
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
app.db.messageDao().getAllByType(App.profileId, messageType).observe(this@MessagesListFragment, Observer { items ->
|
app.db.messageDao().getAllByType(App.profileId, messageType).observe(this@MessagesListFragment, Observer { items ->
|
||||||
|
@ -505,7 +505,7 @@ class MessagesComposeFragment : Fragment(), CoroutineScope {
|
|||||||
|
|
||||||
activity.snackbar(app.getString(R.string.messages_sent_success), app.getString(R.string.ok))
|
activity.snackbar(app.getString(R.string.messages_sent_success), app.getString(R.string.ok))
|
||||||
activity.loadTarget(MainActivity.TARGET_MESSAGES_DETAILS, Bundle(
|
activity.loadTarget(MainActivity.TARGET_MESSAGES_DETAILS, Bundle(
|
||||||
"messageId" to (event.message.id ?: -1),
|
"messageId" to event.message.id,
|
||||||
"message" to app.gson.toJson(event.message),
|
"message" to app.gson.toJson(event.message),
|
||||||
"sentDate" to event.sentDate
|
"sentDate" to event.sentDate
|
||||||
))
|
))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user