Default expiration timer value to zero

This commit is contained in:
charles 2022-12-12 13:14:57 +11:00
parent 1ad10a4ac7
commit 4b66e0516d
7 changed files with 12 additions and 12 deletions

View File

@ -87,7 +87,8 @@ class ExpirationSettingsViewModel(
val expiresIn = _selectedExpirationTimer.value?.value?.toIntOrNull() ?: 0
val expiryType = _selectedExpirationType.value
val expiryChangeTimestampMs = System.currentTimeMillis()
storage.addExpirationConfiguration(ExpirationConfiguration(threadId, expiresIn, expiryType, expiryChangeTimestampMs))
storage.setExpirationConfiguration(ExpirationConfiguration(threadId, expiresIn, expiryType, expiryChangeTimestampMs))
}
@dagger.assisted.AssistedFactory

View File

@ -932,10 +932,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
if (item.itemId == android.R.id.home) {
return false
}
else if (item.itemId == R.id.menu_overflow) {
binding?.toolbar?.showOverflowMenu()
return false
}
return viewModel.recipient?.let { recipient ->
ConversationMenuHelper.onOptionItemSelected(this, item, recipient)
} ?: false

View File

@ -58,8 +58,8 @@ object ConversationMenuHelper {
if (thread.isGroupRecipient) {
item.setIcon(R.drawable.ic_outline_settings_24)
} else {
item.setActionView(R.layout.view_profile_overflow)
item.actionView.setOnClickListener { onOptionsItemSelected(item) }
/*TODO: item.setActionView(R.layout.view_profile_overflow)
item.actionView.setOnClickListener { onOptionsItemSelected(item) }*/
}
val menu = item.subMenu
// Expiring messages

View File

@ -971,7 +971,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
return DatabaseComponent.get(context).expirationConfigurationDatabase().getExpirationConfiguration(threadId)
}
override fun addExpirationConfiguration(config: ExpirationConfiguration) {
override fun setExpirationConfiguration(config: ExpirationConfiguration) {
DatabaseComponent.get(context).expirationConfigurationDatabase().setExpirationConfiguration(config)
}

View File

@ -200,7 +200,7 @@ interface StorageProtocol {
fun unblock(toUnblock: List<Recipient>)
fun blockedContacts(): List<Recipient>
fun getExpirationConfiguration(threadId: Long): ExpirationConfiguration?
fun addExpirationConfiguration(config: ExpirationConfiguration)
fun setExpirationConfiguration(config: ExpirationConfiguration)
fun getExpiringMessages(messageIds: LongArray): List<Pair<String, Int>>
fun updateDisappearingState(address: String, disappearingState: Recipient.DisappearingState)
}

View File

@ -40,8 +40,11 @@ abstract class Message {
}
fun setExpirationConfigurationIfNeeded(builder: SignalServiceProtos.Content.Builder) {
val threadId = threadID ?: return
val config = MessagingModuleConfiguration.shared.storage.getExpirationConfiguration(threadId) ?: return
val config = threadID?.let { MessagingModuleConfiguration.shared.storage.getExpirationConfiguration(it) }
?: run {
builder.expirationTimer = 0
return
}
builder.expirationTimer = config.durationSeconds
if (config.isEnabled) {
builder.expirationType = config.expirationType

View File

@ -101,7 +101,7 @@ fun updateExpirationConfigurationIfNeeded(message: Message, proto: SignalService
type,
proto.lastDisappearingMessageChangeTimestamp
)
storage.addExpirationConfiguration(remoteConfig)
storage.setExpirationConfiguration(remoteConfig)
}
// region Control Messages