purple: feature flag management
Originally the Damus Purple feature was gated behind a setting which served as a feature flag. However, when we release, we need to enable Purple features for all users running on a particular version. This commit improves feature flag management by replacing the setting with a computed property (which still points to the setting, but can be very easily replaced) Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Reviewed-by: William Casarin <jb55@jb55.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
dd240899cf
commit
a6b430284f
@@ -688,7 +688,7 @@ struct ContentView: View {
|
|||||||
|
|
||||||
home.damus_state = self.damus_state!
|
home.damus_state = self.damus_state!
|
||||||
|
|
||||||
if let damus_state, damus_state.settings.enable_experimental_purple_api {
|
if let damus_state, damus_state.purple.enable_purple {
|
||||||
// Assign delegate so that we can send receipts to the Purple API server as soon as we get updates from user's purchases
|
// Assign delegate so that we can send receipts to the Purple API server as soon as we get updates from user's purchases
|
||||||
StoreObserver.standard.delegate = damus_state.purple
|
StoreObserver.standard.delegate = damus_state.purple
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ class DamusPurple: StoreObserverDelegate {
|
|||||||
var environment: DamusPurpleEnvironment {
|
var environment: DamusPurpleEnvironment {
|
||||||
return self.settings.purple_enviroment
|
return self.settings.purple_enviroment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enable_purple: Bool {
|
||||||
|
// TODO: On release, we could just replace this with `true` (or some other feature flag)
|
||||||
|
return self.settings.enable_experimental_purple_api
|
||||||
|
}
|
||||||
|
|
||||||
func profile_purple_badge_info(pubkey: Pubkey) async -> UserBadgeInfo? {
|
func profile_purple_badge_info(pubkey: Pubkey) async -> UserBadgeInfo? {
|
||||||
if let cached_result = self.starred_profiles_cache[pubkey] {
|
if let cached_result = self.starred_profiles_cache[pubkey] {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ struct EventProfileName: View {
|
|||||||
}
|
}
|
||||||
.onAppear(perform: {
|
.onAppear(perform: {
|
||||||
Task {
|
Task {
|
||||||
if damus_state.settings.enable_experimental_purple_api {
|
if damus_state.purple.enable_purple {
|
||||||
self.purple_badge = await damus_state.purple.profile_purple_badge_info(pubkey: pubkey)
|
self.purple_badge = await damus_state.purple.profile_purple_badge_info(pubkey: pubkey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ struct ProfileName: View {
|
|||||||
}
|
}
|
||||||
.onAppear(perform: {
|
.onAppear(perform: {
|
||||||
Task {
|
Task {
|
||||||
if damus_state.settings.enable_experimental_purple_api {
|
if damus_state.purple.enable_purple {
|
||||||
self.purple_badge = await damus_state.purple.profile_purple_badge_info(pubkey: pubkey)
|
self.purple_badge = await damus_state.purple.profile_purple_badge_info(pubkey: pubkey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ struct TranslationSettingsView: View {
|
|||||||
.toggleStyle(.switch)
|
.toggleStyle(.switch)
|
||||||
|
|
||||||
Picker(NSLocalizedString("Service", comment: "Prompt selection of translation service provider."), selection: $settings.translation_service) {
|
Picker(NSLocalizedString("Service", comment: "Prompt selection of translation service provider."), selection: $settings.translation_service) {
|
||||||
ForEach(TranslationService.allCases.filter({ settings.enable_experimental_purple_api ? true : $0 != .purple }), id: \.self) { server in
|
ForEach(TranslationService.allCases.filter({ damus_state.purple.enable_purple ? true : $0 != .purple }), id: \.self) { server in
|
||||||
Text(server.model.displayName)
|
Text(server.model.displayName)
|
||||||
.tag(server.model.tag)
|
.tag(server.model.tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if settings.translation_service == .purple && settings.enable_experimental_purple_api {
|
if settings.translation_service == .purple && damus_state.purple.enable_purple {
|
||||||
NavigationLink(destination: DamusPurpleView(damus_state: damus_state)) {
|
NavigationLink(destination: DamusPurpleView(damus_state: damus_state)) {
|
||||||
Text(NSLocalizedString("Configure Damus Purple", comment: "Button to allow Damus Purple to be configured"))
|
Text(NSLocalizedString("Configure Damus Purple", comment: "Button to allow Damus Purple to be configured"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct SideMenuView: View {
|
|||||||
navLabel(title: NSLocalizedString("Wallet", comment: "Sidebar menu label for Wallet view."), img: "wallet")
|
navLabel(title: NSLocalizedString("Wallet", comment: "Sidebar menu label for Wallet view."), img: "wallet")
|
||||||
}
|
}
|
||||||
|
|
||||||
if damus_state.settings.enable_experimental_purple_api {
|
if damus_state.purple.enable_purple {
|
||||||
NavigationLink(destination: DamusPurpleView(damus_state: damus_state)) {
|
NavigationLink(destination: DamusPurpleView(damus_state: damus_state)) {
|
||||||
HStack(spacing: 13) {
|
HStack(spacing: 13) {
|
||||||
Image("nostr-hashtag")
|
Image("nostr-hashtag")
|
||||||
|
|||||||
Reference in New Issue
Block a user