11package com.mendix.mendixnative.react
22
33import com.facebook.react.bridge.ReactApplicationContext
4- import com.facebook.react.bridge.WritableMap
5- import com.facebook.react.bridge.WritableNativeMap
64import com.mendix.mendixnative.MendixApplication
75import com.mendix.mendixnative.config.AppUrl
86import com.mendix.mendixnative.react.ota.getNativeDependencies
97import com.mendix.mendixnative.react.ota.getOtaManifestFilepath
108
119class MxConfiguration (val reactContext : ReactApplicationContext ) {
1210
13- fun getConstants (): WritableMap ? {
11+ fun getConstants (): Map < String , Any > {
1412 val application = (reactContext.applicationContext as MendixApplication )
1513 if (runtimeUrl == null ) {
1614 if (warningsFilter != WarningsFilter .none) {
@@ -22,31 +20,26 @@ class MxConfiguration(val reactContext: ReactApplicationContext) {
2220 Throwable (" Without the runtime URL, the app cannot retrieve any data.\n\n Please redeploy the app." )
2321 )
2422
25- return WritableNativeMap ()
23+ return emptyMap ()
2624 }
2725
2826 throw IllegalStateException (" Runtime URL not set in the MxConfiguration" )
2927 }
3028
31- val constants = WritableNativeMap ()
32- constants.putString(" RUNTIME_URL" , AppUrl .forRuntime(runtimeUrl))
33- constants.putString(" APP_NAME" , defaultAppName)
34- constants.putString(" DATABASE_NAME" , defaultDatabaseName)
35- constants.putString(
36- " FILES_DIRECTORY_NAME" ,
37- defaultFilesDirectoryName
38- ) // Not to be removed as it is required for backwards compatibility.
39- constants.putString(" WARNINGS_FILTER_LEVEL" , warningsFilter.toString())
40- constants.putString(" OTA_MANIFEST_PATH" , getOtaManifestFilepath(reactContext))
41- constants.putBoolean(" IS_DEVELOPER_APP" , application.getUseDeveloperSupport())
42- constants.putInt(" NATIVE_BINARY_VERSION" , NATIVE_BINARY_VERSION )
43- constants.putString(" APP_SESSION_ID" , application.getAppSessionId())
44-
45- val dependencies = WritableNativeMap ()
46- getNativeDependencies(reactContext).forEach {
47- dependencies.putString(it.key, it.value)
29+ val constants = mutableMapOf (
30+ " RUNTIME_URL" to AppUrl .forRuntime(runtimeUrl),
31+ " DATABASE_NAME" to defaultDatabaseName,
32+ " FILES_DIRECTORY_NAME" to defaultFilesDirectoryName,
33+ " WARNINGS_FILTER_LEVEL" to warningsFilter.toString(),
34+ " OTA_MANIFEST_PATH" to getOtaManifestFilepath(reactContext),
35+ " IS_DEVELOPER_APP" to application.getUseDeveloperSupport(),
36+ " NATIVE_BINARY_VERSION" to NATIVE_BINARY_VERSION ,
37+ " APP_SESSION_ID" to application.getAppSessionId(),
38+ " NATIVE_DEPENDENCIES" to getNativeDependencies(reactContext)
39+ )
40+ defaultAppName?.let {
41+ constants.put(" APP_NAME" , it)
4842 }
49- constants.putMap(" NATIVE_DEPENDENCIES" , dependencies)
5043
5144 return constants
5245 }
0 commit comments