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

[P1] Country support for conversation sharing #178

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 9 additions & 1 deletion OLMoE.swift/Constants/FeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
// Created by Thomas Jones on 11/15/24.
//

import DeviceCheck

enum FeatureFlags {
public enum FeatureFlags {

static let allowDeviceBypass = false

static let serverSideSharing: Bool = {
let appAttestService = DCAppAttestService()
return Locale.isCountrySupported() && appAttestService.isSupported
}()

static let allowMockedModel = false

static let useLLMCaching = true


}
24 changes: 24 additions & 0 deletions OLMoE.swift/Extensions/Locale+CountrySupport.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Locale+CountrySupport.swift
// OLMoE.swift
//
// Created by Stanley Jovel on 3/5/25.
//

import Foundation

extension Locale {
static let supportedCountries = ["US"]

/// Check if the user's country supports server-side sharing
static func isCountrySupported() -> Bool {
let userCountry: String?
if #available(iOS 16, *) {
userCountry = Locale.current.region?.identifier
} else {
userCountry = Locale.current.regionCode
}

return userCountry.map { supportedCountries.contains($0) } ?? false
}
}
18 changes: 12 additions & 6 deletions OLMoE.swift/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,18 @@ struct BotView: View {
} else {
ToolbarButton(action: {
isTextEditorFocused = false
// disclaimerHandlers.setActiveDisclaimer(Disclaimers.ShareDisclaimer())
// disclaimerHandlers.setCancelAction({ disclaimerHandlers.setShowDisclaimerPage(false) })
// disclaimerHandlers.setAllowOutsideTapDismiss(true)
// disclaimerHandlers.setConfirmAction({ shareConversation() })
// disclaimerHandlers.setShowDisclaimerPage(true)
showTextShareSheet = true

if FeatureFlags.serverSideSharing {
// For supported countries, use the disclaimer and shareConversation flow
disclaimerHandlers.setActiveDisclaimer(Disclaimers.ShareDisclaimer())
disclaimerHandlers.setCancelAction({ disclaimerHandlers.setShowDisclaimerPage(false) })
disclaimerHandlers.setAllowOutsideTapDismiss(true)
disclaimerHandlers.setConfirmAction({ shareConversation() })
disclaimerHandlers.setShowDisclaimerPage(true)
} else {
// For unsupported countries, use the text share sheet
showTextShareSheet = true
}
}, imageName: "square.and.arrow.up")
.disabled(isSharing || bot.history.isEmpty || isGenerating)
.opacity(isSharing || bot.history.isEmpty || isGenerating ? 0.5 : 1)
Expand Down