mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 03:09:00 +00:00
Use different notification for party chat message
Using getUserData() did not work (value comes too late) so added local var for party that's populated from same observable as notifications
This commit is contained in:
parent
0f86f44b33
commit
2cf3e29f4d
3 changed files with 16 additions and 1 deletions
|
|
@ -865,6 +865,7 @@
|
|||
<string name="dismiss_all">Dismiss All</string>
|
||||
<string name="new_bailey_update">New Bailey Update!</string>
|
||||
<string name="new_msg_guild"><![CDATA[<b>%1$s</b> has new posts]]></string>
|
||||
<string name="new_msg_party"><![CDATA[Your Party, <b>%1$s</b>, has new posts]]></string>
|
||||
<string name="unallocated_stats_points"><![CDATA[You have <b>%1$s unallocated Stat Points</b>]]></string>
|
||||
<string name="create">Create</string>
|
||||
<string name="only_leader_create_challenge">Only leader can create Challenges</string>
|
||||
|
|
|
|||
|
|
@ -114,10 +114,11 @@ class NotificationsActivity : BaseActivity(), androidx.swiperefreshlayout.widget
|
|||
|
||||
private fun createNewChatMessageNotification(notification: GlobalNotification): View? {
|
||||
val data = notification.getData() as? NewChatMessageData
|
||||
val stringId = if (viewModel.isPartyMessage(data)) R.string.new_msg_party else R.string.new_msg_guild;
|
||||
|
||||
return createNotificationItem(
|
||||
notification,
|
||||
fromHtml(getString(R.string.new_msg_guild, data?.group?.name))
|
||||
fromHtml(getString(stringId, data?.group?.name))
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package com.habitrpg.android.habitica.ui.viewmodels
|
|||
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.models.notifications.GlobalNotification
|
||||
import com.habitrpg.android.habitica.models.notifications.NewChatMessageData
|
||||
import com.habitrpg.android.habitica.models.notifications.NotificationType
|
||||
import com.habitrpg.android.habitica.models.social.UserParty
|
||||
import com.playseeds.android.sdk.inappmessaging.Log
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
|
|
@ -10,12 +12,15 @@ import io.realm.RealmList
|
|||
|
||||
|
||||
open class NotificationsViewModel : BaseViewModel() {
|
||||
var party: UserParty? = null
|
||||
|
||||
override fun inject(component: AppComponent) {
|
||||
component.inject(this)
|
||||
}
|
||||
|
||||
fun getNotifications(): Flowable<List<GlobalNotification>> {
|
||||
return userRepository.getUser()
|
||||
.doOnEach { party = it.value?.party }
|
||||
.map { filterSupportedTypes(it.notifications) }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
|
@ -33,6 +38,14 @@ open class NotificationsViewModel : BaseViewModel() {
|
|||
return notifications.filter { NotificationType.contains(it.type) }
|
||||
}
|
||||
|
||||
fun isPartyMessage(data: NewChatMessageData?): Boolean {
|
||||
if (party == null || data?.group?.id == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
return party?.id == data.group?.id
|
||||
}
|
||||
|
||||
fun dismissNotification(notification: GlobalNotification) {
|
||||
Log.d("NotificationsViewModel.dismissNotification " + notification.type + " " + notification.id)
|
||||
//TODO("not implemented")
|
||||
|
|
|
|||
Loading…
Reference in a new issue