Option to "Dont show again" for alert that appears on Android < 7 regarding web editors

This commit is contained in:
Johnny Almonte
2019-10-19 11:20:41 -04:00
parent e03e67b190
commit 13760bc31d
2 changed files with 52 additions and 20 deletions

View File

@@ -1,35 +1,54 @@
import Storage from './sfjs/storageManager'
const LastExportDateKey = "LastExportDateKey";
const LastExportDateKey = 'LastExportDateKey'
const DontShowAgainUnsupportedEditorsKey = 'DoNotShowAgainUnsupportedEditorsKey'
export default class UserPrefsManager {
static instance = null;
static get() {
if(this.instance == null) {
this.instance = new UserPrefsManager();
static instance = null
static get () {
if (this.instance == null) {
this.instance = new UserPrefsManager()
}
return this.instance;
return this.instance
}
async setLastExportDate(date) {
await Storage.get().setItem(LastExportDateKey, JSON.stringify(date));
this.lastExportDate = date;
async setLastExportDate (date) {
await Storage.get().setItem(LastExportDateKey, JSON.stringify(date))
this.lastExportDate = date
}
async clearLastExportDate() {
this.lastExportDate = null;
return Storage.get().clearKeys([LastExportDateKey]);
async clearLastExportDate () {
this.lastExportDate = null
return Storage.get().clearKeys([LastExportDateKey])
}
async getLastExportDate() {
if(!this.lastExportDate) {
var date = await Storage.get().getItem(LastExportDateKey);
if(date) {
this.lastExportDate = new Date(JSON.parse(date));
async getLastExportDate () {
if (!this.lastExportDate) {
var date = await Storage.get().getItem(LastExportDateKey)
if (date) {
this.lastExportDate = new Date(JSON.parse(date))
}
}
return this.lastExportDate;
return this.lastExportDate
}
async setDontShowAgainEditorsNotSupported () {
await Storage.get().setItem(
DontShowAgainUnsupportedEditorsKey,
JSON.stringify(true)
)
this.dontShowAgainUnsupportedEditors = true
}
async getDontShowAgainEditorsNotSupported () {
if (!this.dontShowAgainUnsupportedEditors) {
var dontShowAgain = await Storage.get().getItem(
DontShowAgainUnsupportedEditorsKey
)
this.dontShowAgainUnsupportedEditors = dontShowAgain !== null
}
return this.dontShowAgainUnsupportedEditors
}
}

View File

@@ -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,19 @@ 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'}
]
)
})
}
}