Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove ai and sync features from macOS #1416

Merged
merged 9 commits into from
May 22, 2024
14 changes: 9 additions & 5 deletions Mail/Views/Menu Drawer/Items/MenuDrawerItemsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct MenuDrawerItemsAdvancedListView: View {
@EnvironmentObject private var mainViewState: MainViewState

@LazyInjectService private var matomo: MatomoUtils
@LazyInjectService private var platformDetector: PlatformDetectable

@Environment(\.openURL) private var openURL

Expand All @@ -40,18 +41,21 @@ struct MenuDrawerItemsAdvancedListView: View {
var body: some View {
MenuDrawerItemsListView(title: MailResourcesStrings.Localizable.menuDrawerAdvancedActions,
matomoName: "advancedActions") {
MenuDrawerItemCell(icon: MailResourcesAsset.doubleArrowsSynchronize,
label: MailResourcesStrings.Localizable.syncCalendarsAndContactsTitle,
matomoName: "syncProfile") {
matomo.track(eventWithCategory: .syncAutoConfig, name: "openFromMenuDrawer")
mainViewState.isShowingSyncProfile = true
if !platformDetector.isMac {
MenuDrawerItemCell(icon: MailResourcesAsset.doubleArrowsSynchronize,
label: MailResourcesStrings.Localizable.syncCalendarsAndContactsTitle,
matomoName: "syncProfile") {
matomo.track(eventWithCategory: .syncAutoConfig, name: "openFromMenuDrawer")
mainViewState.isShowingSyncProfile = true
}
}

MenuDrawerItemCell(icon: MailResourcesAsset.drawerDownload,
label: MailResourcesStrings.Localizable.buttonImportEmails,
matomoName: "importEmails") {
openURL(URLConstants.importMails.url)
}

if mailboxCanRestoreEmails {
MenuDrawerItemCell(
icon: MailResourcesAsset.restoreArrow,
Expand Down
14 changes: 6 additions & 8 deletions Mail/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,15 @@ struct SettingsView: View {

// MARK: Sync Calendar/Contacts

Button {
matomo.track(eventWithCategory: .syncAutoConfig, name: "openFromSettings")
if platformDetector.isMac {
isShowingSyncProfile = true
} else {
if !platformDetector.isMac {
Button {
matomo.track(eventWithCategory: .syncAutoConfig, name: "openFromSettings")
mainViewState.isShowingSyncProfile = true
} label: {
SettingsSubMenuLabel(title: MailResourcesStrings.Localizable.syncCalendarsAndContactsTitle)
}
} label: {
SettingsSubMenuLabel(title: MailResourcesStrings.Localizable.syncCalendarsAndContactsTitle)
.buttonStyle(.plain)
}
.buttonStyle(.plain)

// MARK: AI Writer

Expand Down
3 changes: 2 additions & 1 deletion Mail/Views/SplitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct SplitView: View {
@LazyInjectService private var snackbarPresenter: SnackBarPresentable
@LazyInjectService private var platformDetector: PlatformDetectable
@LazyInjectService private var appLaunchCounter: AppLaunchCounter
@LazyInjectService private var featureFlagsManageable: FeatureFlagsManageable

let mailboxManager: MailboxManager

Expand Down Expand Up @@ -165,7 +166,7 @@ struct SplitView: View {
try await mailboxManager.refreshAllSignatures()
}
guard !platformDetector.isDebug else { return }
mainViewState.isShowingSyncDiscovery = shouldShowSync()
mainViewState.isShowingSyncDiscovery = platformDetector.isMac ? false : shouldShowSync()
}
}
.onOpenURL { url in
Expand Down
13 changes: 13 additions & 0 deletions MailCore/Utils/FeatureFlagsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum FeatureFlag: String, Codable {

public final class FeatureFlagsManager: FeatureFlagsManageable {
@LazyInjectService private var accountManager: AccountManager
@LazyInjectService private var platformDetector: PlatformDetectable

private var enabledFeatures: SendableDictionary<AppFeatureFlags.Key, AppFeatureFlags.Value>

Expand All @@ -54,11 +55,23 @@ public final class FeatureFlagsManager: FeatureFlagsManageable {
}

public func isEnabled(_ feature: FeatureFlag) -> Bool {
guard isEnabledLocally(feature) else { return false }

guard let mailboxUUID = accountManager.currentMailboxManager?.mailbox.uuid,
let userFeatures = enabledFeatures.value(for: mailboxUUID) else { return false }

return userFeatures.contains(feature)
}

private func isEnabledLocally(_ feature: FeatureFlag) -> Bool {
switch feature {
case .aiMailComposer:
return !platformDetector.isMac
default:
return true
}
}

public func feature(_ feature: FeatureFlag, on: () -> Void, off: (() -> Void)?) {
if isEnabled(feature) {
on()
Expand Down
Loading