Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/desktop/.env.development
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Node environment
COLORIZE=true
QSS_ALLOWED=true
QPS_ALLOWED=true
QSS_ENDPOINT=ws://127.0.0.1:3003
LOG_TO_FILE=true
ENVFILE=.env.development
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ SHOULD_RUN_BACKEND_WORKER=true
COLORIZE=false
QSS_ALLOWED=true
QSS_ENDPOINT=ws://127.0.0.1:3003
QPS_ALLOWED=true
6 changes: 0 additions & 6 deletions packages/mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,6 @@ android {
}
}
}
buildTypes.each {
it.buildConfigField("Boolean", "SHOULD_RUN_BACKEND_WORKER", "true")
it.buildConfigField("Boolean", "QSS_ALLOWED", "false")
it.buildConfigField("String", "QSS_ENDPOINT", "\"\"")
it.buildConfigField("Boolean", "DEBUG", "false")
}
buildTypes {
debug {
signingConfig = signingConfigs.debug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,18 @@ class BackendWorker(private val context: Context, workerParams: WorkerParameters
command.add(scriptPath)
command.addAll(args)

val envVars = mutableListOf<String>()
envVars.add("QSS_ALLOWED=${BuildConfig.QSS_ALLOWED}")
envVars.add("QSS_ENDPOINT=${BuildConfig.QSS_ENDPOINT}")
val standardFields = setOf(
"DEBUG", "APPLICATION_ID", "BUILD_TYPE", "FLAVOR",
"VERSION_CODE", "VERSION_NAME", "LIBRARY_PACKAGE_NAME",
"IS_NEW_ARCHITECTURE_ENABLED", "IS_HERMES_ENABLED"
)
val envVars = BuildConfig::class.java.fields
.filter { it.name !in standardFields }
.mapNotNull { field ->
field.get(null)?.let { value -> "${field.name}=$value" }
}
.also { vars -> vars.forEach { Log.d("BackendWorker", "Passing env var: $it") } }
.toMutableList()

nodeProject.waitForInit()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ class MainActivity : ReactActivity() {
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)

override fun onCreate(savedInstanceState: Bundle?) {
// pass null to super.onCreate https://github.com/software-mansion/react-native-screens?tab=readme-ov-file#android
// pass null to super.onCreate
// https://github.com/software-mansion/react-native-screens?tab=readme-ov-file#android
super.onCreate(null)

val intent = intent
checkAgainstIntentUpdate(intent)

if (BuildConfig.SHOULD_RUN_BACKEND_WORKER) {
if (BuildConfig.SHOULD_RUN_BACKEND_WORKER == "true") {
val context = applicationContext
BackendWorkManager(context).enqueueRequests()
}
Expand All @@ -63,16 +64,14 @@ class MainActivity : ReactActivity() {

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private fun checkNotificationsPermission() {
if (ContextCompat.checkSelfPermission(
this,
Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) !=
PackageManager.PERMISSION_GRANTED
) {
// Requesting the permission
ActivityCompat.requestPermissions(
this,
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
NOTIFICATION_PERMISSION_REQUEST_CODE
this,
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
NOTIFICATION_PERMISSION_REQUEST_CODE
)
}
}
Expand Down Expand Up @@ -103,12 +102,13 @@ class MainActivity : ReactActivity() {

@Throws(java.lang.Exception::class)
private fun respondOnNotification(bundle: Bundle) {
val channel = bundle.getString("channel")
?: throw java.lang.Exception("respondOnNotification() failed because of missing channel")
val channel =
bundle.getString("channel")
?: throw java.lang.Exception(
"respondOnNotification() failed because of missing channel"
)

getCurrentReactContext { context: ReactContext ->
emitSwitchChannelEvent(context, channel)
}
getCurrentReactContext { context: ReactContext -> emitSwitchChannelEvent(context, channel) }
}

@SuppressLint("VisibleForTests")
Expand All @@ -117,19 +117,20 @@ class MainActivity : ReactActivity() {
if (null != reactContext) {
callback(reactContext)
} else {
reactInstanceManager.addReactInstanceEventListener(object : ReactInstanceEventListener {
override fun onReactContextInitialized(context: ReactContext) {
callback(context)
reactInstanceManager.removeReactInstanceEventListener(this)
}
})
reactInstanceManager.addReactInstanceEventListener(
object : ReactInstanceEventListener {
override fun onReactContextInitialized(context: ReactContext) {
callback(context)
reactInstanceManager.removeReactInstanceEventListener(this)
}
}
)
}
}

private fun emitSwitchChannelEvent(reactContext: ReactContext, channel: String) {
val deviceEventEmitter: RCTDeviceEventEmitter = reactContext.getJSModule(
RCTDeviceEventEmitter::class.java
)
val deviceEventEmitter: RCTDeviceEventEmitter =
reactContext.getJSModule(RCTDeviceEventEmitter::class.java)

deviceEventEmitter.emit("notification", channel)
}
Expand Down
4 changes: 4 additions & 0 deletions packages/mobile/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ allprojects {
}

apply plugin: "com.facebook.react.rootproject"

ext {
REACT_NATIVE_NODE_MODULES_DIR = file("$rootDir/../node_modules/react-native")
}
4 changes: 2 additions & 2 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "7.0.0",
"scripts": {
"build": "tsc -p tsconfig.build.json --noEmit",
"storybook-android": "ENVFILE=.env.storybook react-native run-android --mode=storybookDebug --appIdSuffix=storybook.debug",
"storybook-android": "react-native run-android --mode=storybookDebug --appIdSuffix=storybook.debug",
"storybook-ios": "ENVFILE=.env.storybook react-native run-ios",
"android": "ENVFILE=.env.development react-native run-android --mode=standardDebug --appIdSuffix=debug",
"android": "react-native run-android --mode=standardDebug --appIdSuffix=debug",
"ios": "ENVFILE=.env.development react-native run-ios",
"start": "react-native start",
"test": "TZ=UTC jest --testPathIgnorePatterns=\"./e2e\" --transformIgnorePatterns \"./node_modules/(?!@d11/react-native-fast-image)/\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,35 +130,39 @@ export const CaptchaDrawer: FC = () => {
)

return (
<ModalBottomDrawer visible={visible} onClose={closeScreen} heightRatio={1}>
<View style={styles.container}>
<View style={styles.content}>
<Text style={styles.title}>Prove you are human</Text>
<Text style={styles.description}>Complete the challenge to continue.</Text>
{status === 'loading' && (
<View style={styles.indicatorRow}>
<ActivityIndicator color={defaultTheme.palette.background.lushSky} />
<Text style={styles.secondaryText}>Loading challenge…</Text>
</View>
)}
{errorMessage && (
<View style={styles.errorBanner}>
<Text style={styles.errorText}>{errorMessage}</Text>
<TouchableOpacity style={styles.retryButton} onPress={handleRetry}>
<Text style={styles.retryLabel}>Try again</Text>
</TouchableOpacity>
</View>
)}
<TouchableOpacity
onPress={() => closeScreen('Captcha screen cancelled via button')}
style={styles.cancelButton}
>
<Text style={styles.cancelLabel}>Cancel</Text>
</TouchableOpacity>
<>
<ModalBottomDrawer visible={visible} onClose={closeScreen} heightRatio={1}>
<View style={styles.container}>
<View style={styles.content}>
<Text style={styles.title}>Prove you are human</Text>
<Text style={styles.description}>Complete the challenge to continue.</Text>
{status === 'loading' && (
<View style={styles.indicatorRow}>
<ActivityIndicator color={defaultTheme.palette.background.lushSky} />
<Text style={styles.secondaryText}>Loading challenge…</Text>
</View>
)}
{errorMessage && (
<View style={styles.errorBanner}>
<Text style={styles.errorText}>{errorMessage}</Text>
<TouchableOpacity style={styles.retryButton} onPress={handleRetry}>
<Text style={styles.retryLabel}>Try again</Text>
</TouchableOpacity>
</View>
)}
<TouchableOpacity
onPress={() => closeScreen('Captcha screen cancelled via button')}
style={styles.cancelButton}
>
<Text style={styles.cancelLabel}>Cancel</Text>
</TouchableOpacity>
</View>
</View>
</ModalBottomDrawer>
{siteKey !== '' && (
<ConfirmHcaptcha ref={captchaRef} siteKey={siteKey} onMessage={handleMessage} size={'invisible'} />
</View>
</ModalBottomDrawer>
)}
</>
)
}

Expand Down
Loading