various code cleanups

This commit is contained in:
Conny Duck 2024-04-12 15:50:16 +02:00
parent b04f2ee7c6
commit 5ac34f679a
No known key found for this signature in database
4 changed files with 10 additions and 19 deletions

View File

@ -90,7 +90,7 @@ class NotificationsPagingAdapter(
}
}
is NotificationViewData.Placeholder -> VIEW_TYPE_PLACEHOLDER
null -> throw IllegalStateException("")
null -> throw IllegalStateException("no item at position $position")
}
}

View File

@ -42,10 +42,6 @@ class NotificationsRemoteMediator(
var excludes: Set<Notification.Type>
) : RemoteMediator<Int, NotificationDataEntity>() {
init {
println(excludes)
}
private var initialRefresh = false
private val notificationsDao = db.notificationsDao()

View File

@ -136,7 +136,7 @@ class NotificationsViewModel @Inject constructor(
account.notificationsFilter = serialize(newFilters)
accountManager.saveAccount(account)
remoteMediator.excludes = newFilters
// clear the cache
// clear the cache to trigger a reload
db.notificationsDao().cleanupNotifications(account.id, 0)
_filters.value = newFilters
}

View File

@ -148,14 +148,14 @@ internal class StatusNotificationViewHolder(
binding.statusUsername.text = usernameText
}
private fun setCreatedAt(createdAt: Date?, useAbsoluteTime: Boolean) {
private fun setCreatedAt(createdAt: Date, useAbsoluteTime: Boolean) {
if (useAbsoluteTime) {
binding.statusMetaInfo.text = absoluteTimeFormatter.format(createdAt, true)
} else {
val readout: String // visible timestamp
val readoutAloud: CharSequence // for screenreaders so they don't mispronounce timestamps like "17m" as 17 meters
if (createdAt != null) {
val then = createdAt.time
val then = createdAt.time
val now = System.currentTimeMillis()
readout = getRelativeTimeSpanString(binding.statusMetaInfo.context, then, now)
readoutAloud = DateUtils.getRelativeTimeSpanString(
@ -164,11 +164,7 @@ internal class StatusNotificationViewHolder(
DateUtils.SECOND_IN_MILLIS,
DateUtils.FORMAT_ABBREV_RELATIVE
)
} else {
// unknown minutes~
readout = "?m"
readoutAloud = "? minutes"
}
binding.statusMetaInfo.text = readout
binding.statusMetaInfo.contentDescription = readoutAloud
}
@ -343,11 +339,10 @@ internal class StatusNotificationViewHolder(
binding.buttonToggleNotificationContent.visibility = View.GONE
binding.notificationContent.filters = NO_INPUT_FILTER
}
val emojifiedText =
content.emojify(
emojis,
binding.notificationContent,
animateEmojis
val emojifiedText = content.emojify(
emojis = emojis,
view = binding.notificationContent,
animate = animateEmojis
)
setClickableText(
binding.notificationContent,