Hook up Damus Purple translation service
This commit integrates the Damus Purple translation service: - Automatically handles translation settings change after purchase - Asks for permission to override translation settings if the user already has translation setup - Translation settings can be changed with Damus Purple, if desired - Translation requests working with the Damus API server Testing -------- PASS Device: iPhone 15 simulator iOS: 17.2 Damus: This commit Damus Purple API server: `9397201d7d55ddcec4c18fcd337f759b61dce697` running on Ubuntu 22.04 LTS VM (npm run dev) iOS setting: English set as the only preferred language. Steps: 1. Enable Damus Purple feature flag on developer settings, set purple localhost mode, and restart app 2. Set translation setting to something other than none (e.g. DeepL) 3. Simulate Damus Purple purchase 4. Check that when dismissing welcome view, a confirmation prompt will ask the user whether they want to switch translator to Damus Purple. PASS 5. Click "Yes". 6. Go to translation settings. Check that translation settings are set to "Purple". PASS 7. Go to a non-English profile. Check that translations appear with "Mock translation" (Which is the translation text provided by the mock translation server). PASS 8. Reinstall app 9. Repeat the test, but this time starting with no translation settings. Make sure that translation settings will automatically switch to Damus Purple. PASS Feature flag testing -------------------- PASS Preconditions: Same as above Steps: 1. Turn off translation 2. Turn off Damus Purple feature flag 3. Go to translation settings. Make sure that Damus Purple is not an option. PASS Closes: https://github.com/damus-io/damus/issues/1836 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
39b6dfb47e
commit
9a547077c1
@@ -306,7 +306,6 @@ func should_translate(event: NostrEvent, our_keypair: Keypair, settings: UserSet
|
||||
}
|
||||
|
||||
func should_preload_translation(event: NostrEvent, our_keypair: Keypair, current_status: TranslateStatus, settings: UserSettingsStore, note_lang: String?) -> Bool {
|
||||
|
||||
switch current_status {
|
||||
case .havent_tried:
|
||||
return should_translate(event: event, our_keypair: our_keypair, settings: settings, note_lang: note_lang) && settings.auto_translate
|
||||
@@ -445,7 +444,7 @@ func preload_event(plan: PreloadPlan, state: DamusState) async {
|
||||
// We have to recheck should_translate here now that we have note_language
|
||||
if plan.load_translations && should_translate(event: plan.event, our_keypair: our_keypair, settings: settings, note_lang: note_language) && settings.auto_translate
|
||||
{
|
||||
translations = await translate_note(profiles: profiles, keypair: our_keypair, event: plan.event, settings: settings, note_lang: note_language)
|
||||
translations = await translate_note(profiles: profiles, keypair: our_keypair, event: plan.event, settings: settings, note_lang: note_language, purple: state.purple)
|
||||
}
|
||||
|
||||
let ts = translations
|
||||
|
||||
Reference in New Issue
Block a user