* Add copy post/url/mention/code to tooltip menu * Check for managedConfig.copyAndPasteProtection * Reorder copy options
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import {BackHandler, NativeModules, DeviceEventEmitter} from 'react-native';
|
|
import LocalAuth from 'react-native-local-auth';
|
|
import JailMonkey from 'jail-monkey';
|
|
|
|
const {MattermostManaged} = NativeModules;
|
|
|
|
let localConfig;
|
|
|
|
export default {
|
|
addEventListener: (name, callback) => {
|
|
DeviceEventEmitter.addListener(name, (config) => {
|
|
localConfig = config;
|
|
if (callback && typeof callback === 'function') {
|
|
callback(config);
|
|
}
|
|
});
|
|
},
|
|
clearListeners: () => true,
|
|
authenticate: LocalAuth.authenticate,
|
|
blurAppScreen: MattermostManaged.blurAppScreen,
|
|
getConfig: MattermostManaged.getConfig,
|
|
getLocalConfig: async () => {
|
|
if (!localConfig) {
|
|
try {
|
|
localConfig = await MattermostManaged.getConfig();
|
|
} catch (error) {
|
|
// do nothing...
|
|
}
|
|
}
|
|
|
|
return localConfig || {};
|
|
},
|
|
isDeviceSecure: async () => {
|
|
try {
|
|
return await LocalAuth.isDeviceSecure();
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
},
|
|
isTrustedDevice: () => {
|
|
if (__DEV__) { //eslint-disable-line no-undef
|
|
return true;
|
|
}
|
|
|
|
return JailMonkey.trustFall();
|
|
},
|
|
quitApp: BackHandler.exitApp
|
|
};
|