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 expiresIn = _selectedExpirationTimer.value?.value?.toIntOrNull() ?: 0
val expiryType = _selectedExpirationType.value val expiryType = _selectedExpirationType.value
val expiryChangeTimestampMs = System.currentTimeMillis() val expiryChangeTimestampMs = System.currentTimeMillis()
storage.addExpirationConfiguration(ExpirationConfiguration(threadId, expiresIn, expiryType, expiryChangeTimestampMs)) storage.setExpirationConfiguration(ExpirationConfiguration(threadId, expiresIn, expiryType, expiryChangeTimestampMs))
} }
@dagger.assisted.AssistedFactory @dagger.assisted.AssistedFactory

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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