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
8 changes: 7 additions & 1 deletion Session/Conversations/Settings/ThreadSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, Ob
threadViewModel.threadShouldBeVisible != true &&
threadViewModel.threadPinnedPriority == LibSession.hiddenPriority
)
let showThreadPubkey: Bool = (
threadViewModel.threadVariant == .contact || (
threadViewModel.threadVariant == .group &&
dependencies[feature: .groupsShowPubkeyInConversationSettings]
)
)
// MARK: - Conversation Info
let conversationInfoSection: SectionModel = SectionModel(
model: .conversationInfo,
Expand Down Expand Up @@ -318,7 +324,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, Ob
)
},

(threadViewModel.threadVariant != .contact ? nil :
(!showThreadPubkey ? nil :
SessionCell.Info(
id: .sessionId,
subtitle: SessionCell.TextInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH
}

public enum TableItem: Hashable, Differentiable, CaseIterable {
case groupsShowPubkeyInConversationSettings
case updatedGroupsDisableAutoApprove
case updatedGroupsRemoveMessagesOnKick
case updatedGroupsAllowHistoricAccessOnInvite
Expand All @@ -78,6 +79,7 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH

public var differenceIdentifier: String {
switch self {
case .groupsShowPubkeyInConversationSettings: return "groupsShowPubkeyInConversationSettings"
case .updatedGroupsDisableAutoApprove: return "updatedGroupsDisableAutoApprove"
case .updatedGroupsRemoveMessagesOnKick: return "updatedGroupsRemoveMessagesOnKick"
case .updatedGroupsAllowHistoricAccessOnInvite: return "updatedGroupsAllowHistoricAccessOnInvite"
Expand All @@ -96,7 +98,8 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH

public static var allCases: [TableItem] {
var result: [TableItem] = []
switch TableItem.updatedGroupsDisableAutoApprove {
switch TableItem.groupsShowPubkeyInConversationSettings {
case .groupsShowPubkeyInConversationSettings: result.append(groupsShowPubkeyInConversationSettings); fallthrough
case .updatedGroupsDisableAutoApprove: result.append(.updatedGroupsDisableAutoApprove); fallthrough
case .updatedGroupsRemoveMessagesOnKick: result.append(.updatedGroupsRemoveMessagesOnKick); fallthrough
case .updatedGroupsAllowHistoricAccessOnInvite:
Expand All @@ -116,6 +119,7 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH
// MARK: - Content

public struct State: Equatable, ObservableKeyProvider {
let groupsShowPubkeyInConversationSettings: Bool
let updatedGroupsDisableAutoApprove: Bool
let updatedGroupsRemoveMessagesOnKick: Bool
let updatedGroupsAllowHistoricAccessOnInvite: Bool
Expand All @@ -135,6 +139,7 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH
}

public let observedKeys: Set<ObservableKey> = [
.feature(.groupsShowPubkeyInConversationSettings),
.feature(.updatedGroupsDisableAutoApprove),
.feature(.updatedGroupsRemoveMessagesOnKick),
.feature(.updatedGroupsAllowHistoricAccessOnInvite),
Expand All @@ -148,6 +153,7 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH

static func initialState(using dependencies: Dependencies) -> State {
return State(
groupsShowPubkeyInConversationSettings: dependencies[feature: .groupsShowPubkeyInConversationSettings],
updatedGroupsDisableAutoApprove: dependencies[feature: .updatedGroupsDisableAutoApprove],
updatedGroupsRemoveMessagesOnKick: dependencies[feature: .updatedGroupsRemoveMessagesOnKick],
updatedGroupsAllowHistoricAccessOnInvite: dependencies[feature: .updatedGroupsAllowHistoricAccessOnInvite],
Expand All @@ -170,6 +176,7 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH
using dependencies: Dependencies
) async -> State {
return State(
groupsShowPubkeyInConversationSettings: dependencies[feature: .groupsShowPubkeyInConversationSettings],
updatedGroupsDisableAutoApprove: dependencies[feature: .updatedGroupsDisableAutoApprove],
updatedGroupsRemoveMessagesOnKick: dependencies[feature: .updatedGroupsRemoveMessagesOnKick],
updatedGroupsAllowHistoricAccessOnInvite: dependencies[feature: .updatedGroupsAllowHistoricAccessOnInvite],
Expand All @@ -190,6 +197,23 @@ class DeveloperSettingsGroupsViewModel: SessionTableViewModel, NavigatableStateH
let general: SectionModel = SectionModel(
model: .general,
elements: [
SessionCell.Info(
id: .groupsShowPubkeyInConversationSettings,
title: "Show Group Pubkey in Conversation Settings",
subtitle: """
Makes the group identity public key appear in the conversation settings screen.
""",
trailingAccessory: .toggle(
state.groupsShowPubkeyInConversationSettings,
oldValue: previousState.groupsShowPubkeyInConversationSettings
),
onTap: { [dependencies = viewModel.dependencies] in
dependencies.set(
feature: .groupsShowPubkeyInConversationSettings,
to: !state.groupsShowPubkeyInConversationSettings
)
}
),
SessionCell.Info(
id: .updatedGroupsDisableAutoApprove,
title: "Disable Auto Approve",
Expand Down
4 changes: 4 additions & 0 deletions SessionUtilitiesKit/General/Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public extension FeatureStorage {
defaultOption: 100
)

static let groupsShowPubkeyInConversationSettings: FeatureConfig<Bool> = Dependencies.create(
identifier: "groupsShowPubkeyInConversationSettings"
)

static let updatedGroupsDisableAutoApprove: FeatureConfig<Bool> = Dependencies.create(
identifier: "updatedGroupsDisableAutoApprove"
)
Expand Down