Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.session.libsession.messaging.open_groups.OpenGroupApi
import org.session.libsession.network.SnodeClock
import org.session.libsession.utilities.Address
import org.session.libsession.utilities.ConfigFactoryProtocol
import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsession.utilities.withGroupConfigs
import org.session.libsession.utilities.withUserConfigs
import org.session.libsignal.exceptions.NonRetryableException
Expand All @@ -42,7 +41,6 @@ class MessageParser @Inject constructor(
private val configFactory: ConfigFactoryProtocol,
private val storage: StorageProtocol,
private val snodeClock: SnodeClock,
private val prefs: TextSecurePreferences,
private val proBackendConfig: Provider<ProBackendConfig>,
) {

Expand Down Expand Up @@ -142,13 +140,10 @@ class MessageParser @Inject constructor(
message.receivedTimestamp = snodeClock.currentTimeMillis()
message.isSenderSelf = isSenderSelf

// Only process pro features post pro launch
if (prefs.forcePostPro()) {
if (pro?.status == ProProof.STATUS_VALID) {
(message as? VisibleMessage)?.proFeatures = buildSet {
addAll(pro.proMessageFeatures.asSequence())
addAll(pro.proProfileFeatures.asSequence())
}
if (pro?.status == ProProof.STATUS_VALID) {
(message as? VisibleMessage)?.proFeatures = buildSet {
addAll(pro.proMessageFeatures.asSequence())
addAll(pro.proProfileFeatures.asSequence())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import org.session.libsession.utilities.TextSecurePreferences.Companion.SEND_WIT
import org.session.libsession.utilities.TextSecurePreferences.Companion.SET_FORCE_CURRENT_USER_PRO
import org.session.libsession.utilities.TextSecurePreferences.Companion.SET_FORCE_INCOMING_MESSAGE_PRO
import org.session.libsession.utilities.TextSecurePreferences.Companion.SET_FORCE_OTHER_USERS_PRO
import org.session.libsession.utilities.TextSecurePreferences.Companion.SET_FORCE_POST_PRO
import org.session.libsession.utilities.TextSecurePreferences.Companion.SHOWN_CALL_NOTIFICATION
import org.session.libsession.utilities.TextSecurePreferences.Companion.SHOWN_CALL_WARNING
import org.session.libsession.utilities.TextSecurePreferences.Companion.SHOW_DONATION_CTA_FROM_POSITIVE_REVIEW
Expand Down Expand Up @@ -149,14 +148,11 @@ interface TextSecurePreferences {
fun setForceOtherUsersAsPro(isPro: Boolean)
fun forceIncomingMessagesAsPro(): Boolean
fun setForceIncomingMessagesAsPro(isPro: Boolean)
fun forcePostPro(): Boolean
fun setForcePostPro(postPro: Boolean)
fun hasSeenProExpiring(): Boolean
fun setHasSeenProExpiring()
fun hasSeenProExpired(): Boolean
fun setHasSeenProExpired()
fun clearProExpiryView()
fun watchPostProStatus(): StateFlow<Boolean>
fun hasSeenSlowModeCallWarning(): Boolean
fun setHasSeenSlowModeCallWarning(value: Boolean)
fun setShownCallWarning(): Boolean
Expand Down Expand Up @@ -304,7 +300,6 @@ interface TextSecurePreferences {
const val SET_FORCE_CURRENT_USER_PRO = "pref_force_current_user_pro"
const val SET_FORCE_OTHER_USERS_PRO = "pref_force_other_users_pro"
const val SET_FORCE_INCOMING_MESSAGE_PRO = "pref_force_incoming_message_pro"
const val SET_FORCE_POST_PRO = "pref_force_post_pro"
const val HAS_SEEN_PRO_EXPIRING = "has_seen_pro_expiring"
const val HAS_SEEN_PRO_EXPIRED = "has_seen_pro_expired"
const val SHOWN_SLOW_MODE_CALL_WARNING = "has_seen_slow_mode_call_warning"
Expand Down Expand Up @@ -571,7 +566,6 @@ class AppTextSecurePreferences @Inject constructor(
@param:ApplicationContext private val context: Context,
private val json: Json,
): TextSecurePreferences {
private val postProLaunchState = MutableStateFlow(getBooleanPreference(SET_FORCE_POST_PRO, if (BuildConfig.BUILD_TYPE != "release") true else false))
private val hiddenPasswordState = MutableStateFlow(getBooleanPreference(HIDE_PASSWORD, false))

override var migratedToGroupV2Config: Boolean
Expand Down Expand Up @@ -1010,16 +1004,6 @@ class AppTextSecurePreferences @Inject constructor(
setBooleanPreference(SET_FORCE_INCOMING_MESSAGE_PRO, isPro)
}

override fun forcePostPro(): Boolean {
return postProLaunchState.value
}

override fun setForcePostPro(postPro: Boolean) {
setBooleanPreference(SET_FORCE_POST_PRO, postPro)
postProLaunchState.update { postPro }
_events.tryEmit(SET_FORCE_POST_PRO)
}

override fun hasSeenProExpiring(): Boolean {
return getBooleanPreference(HAS_SEEN_PRO_EXPIRING, false)
}
Expand All @@ -1041,10 +1025,6 @@ class AppTextSecurePreferences @Inject constructor(
setBooleanPreference(HAS_SEEN_PRO_EXPIRING, false)
}

override fun watchPostProStatus(): StateFlow<Boolean> {
return postProLaunchState
}

override fun getFingerprintKeyGenerated(): Boolean {
return getBooleanPreference(TextSecurePreferences.FINGERPRINT_KEY_GENERATED, false)
}
Expand Down Expand Up @@ -1148,7 +1128,6 @@ class AppTextSecurePreferences @Inject constructor(
* Clear all prefs and reset our observables
*/
override fun clearAll() {
postProLaunchState.update { false }
hiddenPasswordState.update { false }

getDefaultSharedPreferences(context).edit(commit = true) { clear() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class InputbarViewModel(
count = charsLeft,
countFormatted = NumberUtil.getFormattedNumber(charsLeft.toLong()),
danger = charsLeft < 0,
showProBadge = proStatusManager.isPostPro() && !currentUser.isPro // only show the badge for non pro users POST pro launch
showProBadge = !currentUser.isPro // only show the badge for non pro users
)
} else {
null
Expand All @@ -56,9 +56,7 @@ abstract class InputbarViewModel(
val charsLeft = _inputBarState.value.charLimitState?.count ?: 0
return if(charsLeft < 0){
// the user is trying to send a message that is too long - we should display a dialog
// we currently have different logic for PRE and POST Pro launch
// which we can remove once Pro is out - currently we can switch this fro the debug menu
if(!proStatusManager.isPostPro() || currentUser.isPro){
if(currentUser.isPro){
showMessageTooLongSendDialog()
} else {
showSessionProCTA()
Expand All @@ -71,9 +69,7 @@ abstract class InputbarViewModel(
}

fun onCharLimitTapped(){
// we currently have different logic for PRE and POST Pro launch
// which we can remove once Pro is out - currently we can switch this fro the debug menu
if(!proStatusManager.isPostPro() || currentUser.isPro){
if(currentUser.isPro){
handleCharLimitTappedForProUser()
} else {
handleCharLimitTappedForRegularUser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,7 @@ class RecipientRepository @Inject constructor(
): Pair<Recipient, Flow<*>?> {
val now = snodeClock.get().currentTime()

val proDataContext = if (proStatusManager.get().postProLaunchStatus.value) {
ProDataContext()
} else {
null
}
val proDataContext = ProDataContext()

// Fetch data from config first, this may contain partial information for some kind of recipient
val configData = getDataFromConfig(
Expand Down Expand Up @@ -482,8 +478,6 @@ class RecipientRepository @Inject constructor(
}
}

changeSources?.add(proStatusManager.get().postProLaunchStatus.drop(1))

return updatedValue to changeSources?.let { merge(*it.toTypedArray()) }
}

Expand Down Expand Up @@ -554,11 +548,7 @@ class RecipientRepository @Inject constructor(
settingsFetcher: (address: Address) -> RecipientSettings
): Recipient {
// 1. Create a local context specifically for this member
val memberProDataContext = if (proStatusManager.get().postProLaunchStatus.value) {
ProDataContext()
} else {
null
}
val memberProDataContext = ProDataContext()

// 2. Fetch the basic recipient data
val rawRecipient = when (val configData = getDataFromConfig(member.address, memberProDataContext)) {
Expand Down Expand Up @@ -603,11 +593,7 @@ class RecipientRepository @Inject constructor(
settingsFetcher: (address: Address) -> RecipientSettings,
): Recipient {
// 1. Create Local Context
val memberProDataContext = if (proStatusManager.get().postProLaunchStatus.value) {
ProDataContext()
} else {
null
}
val memberProDataContext = ProDataContext()

// 2. Fetch Data
val rawRecipient = when (val configData = getDataFromConfig(address, memberProDataContext)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,6 @@ fun DebugMenu(

}

Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
DebugSwitchRow(
text = "Set app as post Pro launch",
checked = uiState.forcePostPro,
onCheckedChange = {
sendCommand(DebugMenuViewModel.Commands.ForcePostPro(it))
}
)

Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
DebugSwitchRow(
text = "Set other users as Pro",
Expand Down Expand Up @@ -963,7 +954,6 @@ fun PreviewDebugMenu() {
forceCurrentUserAsPro = true,
forceIncomingMessagesAsPro = true,
forceOtherUsersAsPro = false,
forcePostPro = false,
forceShortTTl = false,
messageProFeature = setOf(ProMessageFeature.HIGHER_CHARACTER_LIMIT),
dbInspectorState = DebugMenuViewModel.DatabaseInspectorState.STARTED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class DebugMenuViewModel @AssistedInject constructor(
forceCurrentUserAsPro = textSecurePreferences.forceCurrentUserAsPro(),
forceOtherUsersAsPro = textSecurePreferences.forceOtherUsersAsPro(),
forceIncomingMessagesAsPro = textSecurePreferences.forceIncomingMessagesAsPro(),
forcePostPro = textSecurePreferences.forcePostPro(),
forceShortTTl = textSecurePreferences.forcedShortTTL(),
debugAvatarReupload = textSecurePreferences.debugAvatarReupload,
messageProFeature = textSecurePreferences.getDebugMessageFeatures(),
Expand Down Expand Up @@ -348,13 +347,6 @@ class DebugMenuViewModel @AssistedInject constructor(
}
}

is Commands.ForcePostPro -> {
textSecurePreferences.setForcePostPro(command.set)
_uiState.update {
it.copy(forcePostPro = command.set)
}
}

is Commands.ForceShortTTl -> {
textSecurePreferences.setForcedShortTTL(command.set)
_uiState.update {
Expand Down Expand Up @@ -631,7 +623,6 @@ class DebugMenuViewModel @AssistedInject constructor(
val forceOtherUsersAsPro: Boolean,
val forceIncomingMessagesAsPro: Boolean,
val messageProFeature: Set<ProFeature>,
val forcePostPro: Boolean,
val forceShortTTl: Boolean,
val forceDeprecationState: LegacyGroupDeprecationManager.DeprecationState?,
val debugAvatarReupload: Boolean,
Expand Down Expand Up @@ -701,7 +692,6 @@ class DebugMenuViewModel @AssistedInject constructor(
data class ForceIncomingMessagesAsPro(val set: Boolean) : Commands()
data class ForceNoBilling(val set: Boolean) : Commands()
data class WithinQuickRefund(val set: Boolean) : Commands()
data class ForcePostPro(val set: Boolean) : Commands()
data class ForceShortTTl(val set: Boolean) : Commands()
data class SetMessageProFeature(val feature: ProFeature, val set: Boolean) : Commands()
data class ShowDeprecationChangeDialog(val state: LegacyGroupDeprecationManager.DeprecationState?) : Commands()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ fun Settings(
Buttons(
recoveryHidden = uiState.recoveryHidden,
pathStatus = uiState.pathStatus,
postPro = uiState.isPostPro,
proDataState = uiState.proDataState,
sendCommand = sendCommand
)
Expand Down Expand Up @@ -398,7 +397,6 @@ fun Settings(
AvatarDialog(
state = uiState.avatarDialogState,
isPro = uiState.proDataState.type is ProStatus.Active,
isPostPro = uiState.isPostPro,
sendCommand = sendCommand,
startAvatarSelection = startAvatarSelection
)
Expand Down Expand Up @@ -537,7 +535,6 @@ fun Settings(
fun Buttons(
recoveryHidden: Boolean,
pathStatus: PathStatus,
postPro: Boolean,
proDataState: ProDataState,
sendCommand: (SettingsViewModel.Commands) -> Unit,
) {
Expand Down Expand Up @@ -580,10 +577,9 @@ fun Buttons(

Cell {
Column {
if(postPro){
ItemButton(
text = annotatedStringResource(
when (proDataState.type) {
ItemButton(
text = annotatedStringResource(
when (proDataState.type) {
is ProStatus.Active -> Phrase.from(
LocalContext.current,
R.string.sessionProBeta
Expand Down Expand Up @@ -618,7 +614,6 @@ fun Buttons(
}

Divider()
}

// Invite a friend
ItemButton(
Expand Down Expand Up @@ -921,7 +916,6 @@ fun AvatarOption(
fun AvatarDialog(
state: SettingsViewModel.AvatarDialogState,
isPro: Boolean,
isPostPro: Boolean,
sendCommand: (SettingsViewModel.Commands) -> Unit,
startAvatarSelection: () -> Unit,
){
Expand All @@ -934,22 +928,20 @@ fun AvatarDialog(
// custom content that has the displayed images

// animated Pro title
if(isPostPro){
ProBadgeText(
modifier = Modifier
.padding(
top = LocalDimensions.current.xxxsSpacing,
bottom = LocalDimensions.current.xsSpacing,
)
.clickable {
sendCommand(ShowAnimatedProCTA)
},
text = stringResource(if(isPro) R.string.proAnimatedDisplayPictureModalDescription
else R.string.proAnimatedDisplayPicturesNonProModalDescription),
textStyle = LocalType.current.base.copy(color = LocalColors.current.textSecondary),
badgeAtStart = isPro
)
}
ProBadgeText(
modifier = Modifier
.padding(
top = LocalDimensions.current.xxxsSpacing,
bottom = LocalDimensions.current.xsSpacing,
)
.clickable {
sendCommand(ShowAnimatedProCTA)
},
text = stringResource(if(isPro) R.string.proAnimatedDisplayPictureModalDescription
else R.string.proAnimatedDisplayPicturesNonProModalDescription),
textStyle = LocalType.current.base.copy(color = LocalColors.current.textSecondary),
badgeAtStart = isPro
)

// main container that control the overall size and adds the rounded bg
Box(
Expand Down Expand Up @@ -1069,7 +1061,6 @@ private fun SettingsScreenPreview() {
)
)
),
isPostPro = true,
proDataState = ProDataState(
type = previewAutoRenewingApple,
refreshState = State.Success(Unit),
Expand Down Expand Up @@ -1099,7 +1090,6 @@ fun PreviewAvatarDialog(
AvatarDialog(
state = SettingsViewModel.AvatarDialogState.NoAvatar,
isPro = false,
isPostPro = false,
sendCommand = {},
startAvatarSelection = {}
)
Expand Down
Loading
Loading