mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
Fixing up the muting as you can't add more than the max int....
This commit is contained in:
parent
e6c224bec4
commit
c68dc4f12f
@ -26,14 +26,7 @@ fun showMuteDialog(
|
|||||||
context.getSubbedString(entry.stringRes, TIME_LARGE_KEY to largeTimeUnitString)
|
context.getSubbedString(entry.stringRes, TIME_LARGE_KEY to largeTimeUnitString)
|
||||||
}
|
}
|
||||||
}.toTypedArray()) {
|
}.toTypedArray()) {
|
||||||
// Note: We add the current timestamp to the mute duration to get the un-mute timestamp
|
onMuteDuration(Option.entries[it].getTime())
|
||||||
// that gets stored in the database via ConversationMenuHelper.mute().
|
|
||||||
// Also: This is a kludge, but we ADD one second to the mute duration because otherwise by
|
|
||||||
// the time the view for how long the conversation is muted for gets set then it's actually
|
|
||||||
// less than the entire duration - so 1 hour becomes 59 minutes, 1 day becomes 23 hours etc.
|
|
||||||
// As we really want to see the actual set time (1 hour / 1 day etc.) then we'll bump it by
|
|
||||||
// 1 second which is neither here nor there in the grand scheme of things.
|
|
||||||
onMuteDuration(Option.entries[it].getTime() + System.currentTimeMillis() + 1.seconds.inWholeMilliseconds)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,5 +37,12 @@ private enum class Option(@StringRes val stringRes: Int, val getTime: () -> Long
|
|||||||
SEVEN_DAYS(R.string.notificationsMuteFor, duration = TimeUnit.DAYS.toMillis(7)),
|
SEVEN_DAYS(R.string.notificationsMuteFor, duration = TimeUnit.DAYS.toMillis(7)),
|
||||||
FOREVER(R.string.notificationsMute, getTime = { Long.MAX_VALUE } );
|
FOREVER(R.string.notificationsMute, getTime = { Long.MAX_VALUE } );
|
||||||
|
|
||||||
constructor(@StringRes stringRes: Int, duration: Long): this(stringRes, { duration } )
|
// Note: We add the current timestamp to the mute duration to get the un-mute timestamp
|
||||||
|
// that gets stored in the database via ConversationMenuHelper.mute().
|
||||||
|
// Also: This is a kludge, but we ADD one second to the mute duration because otherwise by
|
||||||
|
// the time the view for how long the conversation is muted for gets set then it's actually
|
||||||
|
// less than the entire duration - so 1 hour becomes 59 minutes, 1 day becomes 23 hours etc.
|
||||||
|
// As we really want to see the actual set time (1 hour / 1 day etc.) then we'll bump it by
|
||||||
|
// 1 second which is neither here nor there in the grand scheme of things.
|
||||||
|
constructor(@StringRes stringRes: Int, duration: Long): this(stringRes, { duration + System.currentTimeMillis() + 1.seconds.inWholeMilliseconds } )
|
||||||
}
|
}
|
@ -125,9 +125,7 @@ class ConversationActionBarView @JvmOverloads constructor(
|
|||||||
settings += ConversationSetting(
|
settings += ConversationSetting(
|
||||||
recipient.mutedUntil.takeUnless { it == Long.MAX_VALUE }
|
recipient.mutedUntil.takeUnless { it == Long.MAX_VALUE }
|
||||||
?.let {
|
?.let {
|
||||||
val mutedDuration = (it - System.currentTimeMillis()).milliseconds
|
context.getString(R.string.notificationsHeaderMute)
|
||||||
val durationString = LocalisedTimeUtil.getDurationWithSingleLargestTimeUnit(context, mutedDuration)
|
|
||||||
context.getSubbedString(R.string.notificationsMuteFor, TIME_LARGE_KEY to durationString)
|
|
||||||
}
|
}
|
||||||
?: context.getString(R.string.notificationsMuted),
|
?: context.getString(R.string.notificationsMuted),
|
||||||
ConversationSettingType.NOTIFICATION,
|
ConversationSettingType.NOTIFICATION,
|
||||||
|
@ -547,6 +547,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
} else {
|
} else {
|
||||||
showMuteDialog(this) { until ->
|
showMuteDialog(this) { until ->
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
|
Log.d("", "**** until: $until")
|
||||||
recipientDatabase.setMuted(thread.recipient, until)
|
recipientDatabase.setMuted(thread.recipient, until)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
binding.recyclerView.adapter!!.notifyDataSetChanged()
|
binding.recyclerView.adapter!!.notifyDataSetChanged()
|
||||||
|
Loading…
Reference in New Issue
Block a user