threads are enabled by default end forced to enabled for existing users (#7775)

This commit is contained in:
Nikita Fedrunov 2022-12-13 14:02:45 +01:00 committed by GitHub
parent 4657729e36
commit 3dadebe505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 2 deletions

1
changelog.d/5503.misc Normal file
View File

@ -0,0 +1 @@
[Threads] - Threads Labs Flag is enabled by default and forced to be enabled for existing users, but sill can be disabled manually

View File

@ -66,7 +66,7 @@ data class MatrixConfiguration(
/**
* Thread messages default enable/disabled value.
*/
val threadMessagesEnabledDefault: Boolean = false,
val threadMessagesEnabledDefault: Boolean = true,
/**
* List of network interceptors, they will be added when building an OkHttp client.
*/

View File

@ -39,7 +39,7 @@
<!-- Level 1: Labs -->
<bool name="settings_labs_deferred_dm_visible">true</bool>
<bool name="settings_labs_deferred_dm_default">true</bool>
<bool name="settings_labs_thread_messages_default">false</bool>
<bool name="settings_labs_thread_messages_default">true</bool>
<bool name="settings_labs_new_app_layout_default">true</bool>
<bool name="settings_labs_new_session_manager_default">false</bool>
<bool name="settings_labs_new_session_manager_visible">true</bool>

View File

@ -254,6 +254,12 @@ class HomeActivityViewModel @AssistedInject constructor(
// }
when {
!vectorPreferences.areThreadMessagesEnabled() && !vectorPreferences.wasThreadFlagChangedManually() -> {
vectorPreferences.setThreadMessagesEnabled()
lightweightSettingsStorage.setThreadMessagesEnabled(vectorPreferences.areThreadMessagesEnabled())
// Clear Cache
_viewEvents.post(HomeActivityViewEvents.MigrateThreads(checkSession = false))
}
// Notify users
vectorPreferences.shouldNotifyUserAboutThreads() && vectorPreferences.areThreadMessagesEnabled() -> {
Timber.i("----> Notify users about threads")

View File

@ -239,6 +239,7 @@ class VectorPreferences @Inject constructor(
// This key will be used to identify clients with the new thread support enabled m.thread
const val SETTINGS_LABS_ENABLE_THREAD_MESSAGES = "SETTINGS_LABS_ENABLE_THREAD_MESSAGES_FINAL"
const val SETTINGS_LABS_THREAD_MESSAGES_CHANGED_BY_USER = "SETTINGS_LABS_THREAD_MESSAGES_CHANGED_BY_USER"
const val SETTINGS_THREAD_MESSAGES_SYNCED = "SETTINGS_THREAD_MESSAGES_SYNCED"
// This key will be used to enable user for displaying live user info or not.
@ -1129,6 +1130,24 @@ class VectorPreferences @Inject constructor(
.apply()
}
/**
* Indicates whether or not user changed threads flag manually. We need this to not force flag to be enabled on app start.
* Should be removed when Threads flag will be removed
*/
fun wasThreadFlagChangedManually(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_LABS_THREAD_MESSAGES_CHANGED_BY_USER, false)
}
/**
* Sets the flag to indicate that user changed threads flag (e.g. disabled them).
*/
fun setThreadFlagChangedManually() {
defaultPrefs
.edit()
.putBoolean(SETTINGS_LABS_THREAD_MESSAGES_CHANGED_BY_USER, true)
.apply()
}
/**
* Indicates whether or not the user will be notified about the new thread support.
* We should notify the user only if he had old thread support enabled.

View File

@ -141,6 +141,7 @@ class VectorSettingsLabsFragment :
*/
private fun onThreadsPreferenceClicked() {
// We should migrate threads only if threads are disabled
vectorPreferences.setThreadFlagChangedManually()
vectorPreferences.setShouldMigrateThreads(!vectorPreferences.areThreadMessagesEnabled())
lightweightSettingsStorage.setThreadMessagesEnabled(vectorPreferences.areThreadMessagesEnabled())
displayLoadingView()