Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
fix: display message if using advanced editors on iOS < 11 (#512)
Browse files Browse the repository at this point in the history
* fix: display message if using advanced editors on iOS < 11

* Update src/screens/Compose/ComponentView.tsx

Co-authored-by: Mo <mo@standardnotes.org>

* fix: rename from checkIfSupportsAdvancedEditors to warnIfUnsupportedEditors

Co-authored-by: Johnny Almonte <johnny243@users.noreply.github.com>
Co-authored-by: Mo <mo@standardnotes.org>
  • Loading branch information
3 people committed Dec 6, 2021
1 parent 8651f8f commit 7153a76
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions src/screens/Compose/ComponentView.tsx
Expand Up @@ -85,32 +85,58 @@ export const ComponentView = ({
}, [application, liveComponent?.item.uuid, componentUuid]);

useEffect(() => {
const warnUnsupportedEditors = async () => {
const warnIfUnsupportedEditors = async () => {
let platformVersionRequirements;

switch (Platform.OS) {
case 'ios':
if (parseInt(Platform.Version.toString(), 10) < 11) {
// WKWebView has issues on iOS < 11
platformVersionRequirements = 'iOS 11 or greater';
}
break;
case 'android':
if (Platform.Version <= 23) {
/**
* postMessage doesn't work on Android <= 6 (API version 23)
* https://github.com/facebook/react-native/issues/11594
*/
platformVersionRequirements = 'Android 7.0 or greater';
}
break;
}

if (!platformVersionRequirements) {
return;
}

const doNotShowAgainUnsupportedEditors = application
?.getLocalPreferences()
.getValue(PrefKey.DoNotShowAgainUnsupportedEditors, false);

if (!doNotShowAgainUnsupportedEditors) {
const alertText =
`Web editors require ${platformVersionRequirements}. ` +
'Your version does not support web editors. ' +
'Changes you make may not be properly saved. Please switch to the Plain Editor for the best experience.';

const confirmed = await application?.alertService?.confirm(
'Web editors require Android 7.0 or greater. Your version does not support web editors. Changes you make may not be properly saved. Please switch to the Plain Editor for the best experience.',
alertText,
'Editors Not Supported',
"Don't show again",
ButtonType.Info,
'OK'
);

if (confirmed) {
application
?.getLocalPreferences()
.setUserPrefValue(PrefKey.DoNotShowAgainUnsupportedEditors, true);
}
}
};
if (Platform.OS === 'android' && Platform.Version <= 23) {
/**
* postMessage doesn't work on Android <= 6 (API version 23)
* https://github.com/facebook/react-native/issues/11594
*/
warnUnsupportedEditors();
}

warnIfUnsupportedEditors();
}, [application]);

useEffect(() => {
Expand Down

0 comments on commit 7153a76

Please sign in to comment.