diff --git a/src/lib/userPrefsManager.js b/src/lib/userPrefsManager.js index 59bcde43..03f10202 100644 --- a/src/lib/userPrefsManager.js +++ b/src/lib/userPrefsManager.js @@ -1,10 +1,10 @@ import Storage from './sfjs/storageManager' -const LastExportDateKey = "LastExportDateKey"; +const LastExportDateKey = 'LastExportDateKey' +const DontShowAgainUnsupportedEditorsKey = 'DoNotShowAgainUnsupportedEditorsKey' export default class UserPrefsManager { - - static instance = null; + static instance = null static get() { if(this.instance == null) { this.instance = new UserPrefsManager(); @@ -24,7 +24,7 @@ export default class UserPrefsManager { async getLastExportDate() { if(!this.lastExportDate) { - var date = await Storage.get().getItem(LastExportDateKey); + let date = await Storage.get().getItem(LastExportDateKey); if(date) { this.lastExportDate = new Date(JSON.parse(date)); } @@ -32,4 +32,18 @@ export default class UserPrefsManager { return this.lastExportDate; } + + async setDontShowAgainEditorsNotSupported() { + await Storage.get().setItem(DontShowAgainUnsupportedEditorsKey, JSON.stringify(true)); + this.dontShowAgainUnsupportedEditors = true; + } + + async getDontShowAgainEditorsNotSupported() { + if(this.dontShowAgainUnsupportedEditors === null || this.dontShowAgainUnsupportedEditors === undefined) { + let dontShowAgain = await Storage.get().getItem(DontShowAgainUnsupportedEditorsKey); + this.dontShowAgainUnsupportedEditors = dontShowAgain !== null; + } + + return this.dontShowAgainUnsupportedEditors; + } } diff --git a/src/screens/ComponentView.js b/src/screens/ComponentView.js index 59534f43..6bde840c 100644 --- a/src/screens/ComponentView.js +++ b/src/screens/ComponentView.js @@ -4,6 +4,7 @@ import { WebView } from 'react-native-webview'; import ComponentManager from '@Lib/componentManager' import ModelManager from '@Lib/sfjs/modelManager' +import UserPrefsManager from '@Lib/userPrefsManager' import StyleKit from "@Style/StyleKit" import ApplicationState from "@Lib/ApplicationState" @@ -45,7 +46,20 @@ export default class ComponentView extends Component { componentDidMount() { 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 - Alert.alert('Editors Not Supported', `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.`, [{text: 'OK'}]) + UserPrefsManager.get().getDontShowAgainEditorsNotSupported().then((dontShowAgain) => { + if(dontShowAgain) { + return; + } + + Alert.alert( + 'Editors Not Supported', + '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.', + [ + {text: "Don't show again", onPress: () => UserPrefsManager.get().setDontShowAgainEditorsNotSupported()}, + {text: 'OK'} + ] + ) + }) } }