Compare commits

..

4 Commits

Author SHA1 Message Date
Reinaldo Neto 36bc222707 minor tweak 2023-02-15 18:31:00 -03:00
Reinaldo Neto 21acdd9f2c refactor and tweaks 2023-02-15 18:21:38 -03:00
Reinaldo Neto 4ea8aabe6b parser inside the model 2023-02-02 12:34:04 -03:00
Reinaldo Neto eb9f973e47 [NEW] Quotes on E2EE Messages 2023-02-01 18:24:34 -03:00
186 changed files with 6069 additions and 3759 deletions

View File

@ -1,9 +1,6 @@
defaults: &defaults defaults: &defaults
working_directory: ~/repo working_directory: ~/repo
orbs:
android: circleci/android@2.1.2
macos: &macos macos: &macos
macos: macos:
xcode: "14.2.0" xcode: "14.2.0"
@ -330,14 +327,6 @@ commands:
working_directory: ios working_directory: ios
- save_cache: *save-gems-cache - save_cache: *save-gems-cache
create-e2e-account-file:
description: "Create e2e account file"
steps:
- run:
command: |
echo $E2E_ACCOUNT | base64 --decode > ./e2e_account.ts
working_directory: e2e
version: 2.1 version: 2.1
# EXECUTORS # EXECUTORS
@ -449,94 +438,6 @@ jobs:
- upload-to-google-play-beta: - upload-to-google-play-beta:
official: true official: true
e2e-build-android:
<<: *defaults
executor:
name: android/android-machine
resource-class: xlarge
tag: 2022.12.1
environment:
<<: *android-env
steps:
- checkout
- restore_cache: *restore-npm-cache-linux
- run: *install-npm-modules
- save_cache: *save-npm-cache-linux
- restore_cache: *restore-gradle-cache
- run:
name: Configure Gradle
command: |
echo -e "" > ./gradle.properties
# echo -e "android.enableAapt2=false" >> ./gradle.properties
echo -e "android.useAndroidX=true" >> ./gradle.properties
echo -e "android.enableJetifier=true" >> ./gradle.properties
echo -e "newArchEnabled=false" >> ./gradle.properties
echo -e "FLIPPER_VERSION=0.125.0" >> ./gradle.properties
echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
echo -e "APPLICATION_ID=chat.rocket.reactnative" >> ./gradle.properties
echo -e "BugsnagAPIKey=$BUGSNAG_KEY" >> ./gradle.properties
echo $KEYSTORE_EXPERIMENTAL_BASE64 | base64 --decode > ./app/$KEYSTORE_EXPERIMENTAL
echo -e "KEYSTORE=$KEYSTORE_EXPERIMENTAL" >> ./gradle.properties
echo -e "KEYSTORE_PASSWORD=$KEYSTORE_EXPERIMENTAL_PASSWORD" >> ./gradle.properties
echo -e "KEY_ALIAS=$KEYSTORE_EXPERIMENTAL_ALIAS" >> ./gradle.properties
echo -e "KEY_PASSWORD=$KEYSTORE_EXPERIMENTAL_PASSWORD" >> ./gradle.properties
working_directory: android
- run:
name: Build Android
command: |
echo "RUNNING_E2E_TESTS=true" > ./.env
yarn e2e:android-build
- save_cache: *save-gradle-cache
- store_artifacts:
path: android/app/build/outputs/apk/experimentalPlay/release/app-experimental-play-release.apk
- store_artifacts:
path: android/app/build/outputs/apk/androidTest/experimentalPlay/release/app-experimental-play-release-androidTest.apk
- persist_to_workspace:
root: /home/circleci/repo
paths:
- android/app/build/outputs/apk/
e2e-test-android:
<<: *defaults
executor:
name: android/android-machine
resource-class: xlarge
tag: 2022.12.1
parallelism: 4
steps:
- checkout
- attach_workspace:
at: /home/circleci/repo
- restore_cache: *restore-npm-cache-linux
- run: *install-npm-modules
- save_cache: *save-npm-cache-linux
- run: mkdir ~/junit
- create-e2e-account-file
- android/create-avd:
avd-name: Pixel_API_31_AOSP
install: true
system-image: system-images;android-31;default;x86_64
- run:
name: Setup emulator
command: |
echo "hw.lcd.density = 440" >> ~/.android/avd/Pixel_API_31_AOSP.avd/config.ini
echo "hw.lcd.height = 2280" >> ~/.android/avd/Pixel_API_31_AOSP.avd/config.ini
echo "hw.lcd.width = 1080" >> ~/.android/avd/Pixel_API_31_AOSP.avd/config.ini
- run:
name: Run Detox Tests
command: |
TEST=$(circleci tests glob "e2e/tests/**/*.ts" | circleci tests split --split-by=timings)
yarn e2e:android-test $TEST
- store_artifacts:
path: artifacts
- run:
command: cp junit.xml ~/junit/
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
# iOS builds # iOS builds
ios-build-experimental: ios-build-experimental:
executor: mac-env executor: mac-env
@ -560,89 +461,11 @@ jobs:
- upload-to-testflight: - upload-to-testflight:
official: true official: true
e2e-build-ios:
executor: mac-env
steps:
- checkout
- restore_cache: *restore-gems-cache
- restore_cache: *restore-npm-cache-mac
- run: *install-npm-modules
- run: *update-fastlane-ios
- save_cache: *save-npm-cache-mac
- save_cache: *save-gems-cache
- manage-pods
- run:
name: Configure Detox
command: |
brew tap wix/brew
brew install applesimutils
- run:
name: Build
command: |
/usr/libexec/PlistBuddy -c "Set :bugsnag:apiKey $BUGSNAG_KEY" ./ios/RocketChatRN/Info.plist
/usr/libexec/PlistBuddy -c "Set :bugsnag:apiKey $BUGSNAG_KEY" ./ios/ShareRocketChatRN/Info.plist
yarn detox clean-framework-cache && yarn detox build-framework-cache
echo "RUNNING_E2E_TESTS=true" > ./.env
yarn e2e:ios-build
- persist_to_workspace:
root: /Users/distiller/project
paths:
- ios/build/Build/Products/Release-iphonesimulator/Rocket.Chat Experimental.app
e2e-test-ios:
executor: mac-env
parallelism: 5
steps:
- checkout
- attach_workspace:
at: /Users/distiller/project
- restore_cache: *restore-npm-cache-mac
- run: *install-npm-modules
- save_cache: *save-npm-cache-mac
- run: mkdir ~/junit
- run:
name: Configure Detox
command: |
brew tap wix/brew
brew install applesimutils
yarn detox clean-framework-cache && yarn detox build-framework-cache
- create-e2e-account-file
- run:
name: Run tests
command: |
TEST=$(circleci tests glob "e2e/tests/**/*.ts" | circleci tests split --split-by=timings)
yarn e2e:ios-test $TEST
- store_artifacts:
path: artifacts
- run:
command: cp junit.xml ~/junit/
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
workflows: workflows:
build-and-test: build-and-test:
jobs: jobs:
- lint-testunit - lint-testunit
# E2E tests
- e2e-hold:
type: approval
- e2e-build-ios:
requires:
- e2e-hold
- e2e-test-ios:
requires:
- e2e-build-ios
- e2e-build-android:
requires:
- e2e-hold
- e2e-test-android:
requires:
- e2e-build-android
# iOS Experimental # iOS Experimental
- ios-hold-build-experimental: - ios-hold-build-experimental:
type: approval type: approval

View File

@ -1,91 +0,0 @@
/** @type {Detox.DetoxConfig} */
module.exports = {
testRunner: {
args: {
$0: 'jest',
config: 'e2e/jest.config.js'
},
retries: process.env.CI ? 3 : 0
},
artifacts: {
plugins: {
screenshot: 'failing',
video: 'failing',
uiHierarchy: 'enabled'
}
},
apps: {
'ios.debug': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/Rocket.Chat Experimental.app',
build:
'xcodebuild -workspace ios/RocketChatRN.xcworkspace -scheme RocketChatRN -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
},
'ios.release': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/Rocket.Chat Experimental.app',
build:
'xcodebuild -workspace ios/RocketChatRN.xcworkspace -scheme RocketChatRN -configuration Release -sdk iphonesimulator -derivedDataPath ios/build'
},
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/experimentalPlay/debug/app-experimental-play-debug.apk',
build:
'cd android ; ./gradlew assembleExperimentalPlayDebug assembleExperimentalPlayDebugAndroidTest -DtestBuildType=debug ; cd -',
reversePorts: [8081]
},
'android.release': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/experimentalPlay/release/app-experimental-play-release.apk',
build:
'cd android ; ./gradlew assembleExperimentalPlayRelease assembleExperimentalPlayReleaseAndroidTest -DtestBuildType=release ; cd -'
}
},
devices: {
simulator: {
type: 'ios.simulator',
device: {
type: 'iPhone 14'
}
},
attached: {
type: 'android.attached',
device: {
adbName: '.*'
}
},
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_API_31_AOSP'
},
headless: process.env.CI ? true : false
}
},
configurations: {
'ios.sim.debug': {
device: 'simulator',
app: 'ios.debug'
},
'ios.sim.release': {
device: 'simulator',
app: 'ios.release'
},
'android.att.debug': {
device: 'attached',
app: 'android.debug'
},
'android.att.release': {
device: 'attached',
app: 'android.release'
},
'android.emu.debug': {
device: 'emulator',
app: 'android.debug'
},
'android.emu.release': {
device: 'emulator',
app: 'android.release'
}
}
};

2
.env
View File

@ -1,2 +0,0 @@
# DON'T COMMIT THIS FILE
RUNNING_E2E_TESTS=

View File

@ -240,8 +240,19 @@ module.exports = {
}, },
{ {
files: ['e2e/**'], files: ['e2e/**'],
globals: {
by: true,
detox: true,
device: true,
element: true,
waitFor: true
},
rules: { rules: {
'no-await-in-loop': 0 'import/no-extraneous-dependencies': 0,
'no-await-in-loop': 0,
'no-restricted-syntax': 0,
// TODO: remove this rule when update Detox to 20 and test if the namespace Detox is available
'no-undef': 1
} }
} }
] ]

1
.gitignore vendored
View File

@ -67,6 +67,5 @@ e2e/docker/rc_test_env/docker-compose.yml
e2e/docker/data/db e2e/docker/data/db
e2e/e2e_account.js e2e/e2e_account.js
e2e/e2e_account.ts e2e/e2e_account.ts
junit.xml
*.p8 *.p8

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -147,7 +147,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode VERSIONCODE as Integer versionCode VERSIONCODE as Integer
versionName "4.37.0" versionName "4.35.1"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
if (!isFoss) { if (!isFoss) {
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
@ -250,7 +250,6 @@ android {
release { release {
minifyEnabled enableProguardInReleaseBuilds minifyEnabled enableProguardInReleaseBuilds
setProguardFiles([getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro']) setProguardFiles([getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'])
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
signingConfig signingConfigs.release signingConfig signingConfigs.release
if (!isFoss) { if (!isFoss) {
firebaseCrashlytics { firebaseCrashlytics {
@ -269,11 +268,6 @@ android {
// pickFirst '**/x86_64/libc++_shared.so' // pickFirst '**/x86_64/libc++_shared.so'
// } // }
// FIXME: Remove when we update RN
packagingOptions {
pickFirst '**/*.so'
}
// applicationVariants are e.g. debug, release // applicationVariants are e.g. debug, release
flavorDimensions "app", "type" flavorDimensions "app", "type"
@ -286,6 +280,10 @@ android {
dimension = "app" dimension = "app"
buildConfigField "boolean", "IS_OFFICIAL", "false" buildConfigField "boolean", "IS_OFFICIAL", "false"
} }
e2e {
dimension = "app"
buildConfigField "boolean", "IS_OFFICIAL", "false"
}
foss { foss {
dimension = "type" dimension = "type"
buildConfigField "boolean", "FDROID_BUILD", "true" buildConfigField "boolean", "FDROID_BUILD", "true"
@ -313,6 +311,16 @@ android {
java.srcDirs = ['src/main/java', 'src/play/java'] java.srcDirs = ['src/main/java', 'src/play/java']
manifest.srcFile 'src/play/AndroidManifest.xml' manifest.srcFile 'src/play/AndroidManifest.xml'
} }
e2ePlayDebug {
java.srcDirs = ['src/main/java', 'src/play/java']
res.srcDirs = ['src/experimental/res']
manifest.srcFile 'src/play/AndroidManifest.xml'
}
e2ePlayRelease {
java.srcDirs = ['src/main/java', 'src/play/java']
res.srcDirs = ['src/experimental/res']
manifest.srcFile 'src/play/AndroidManifest.xml'
}
} }
applicationVariants.all { variant -> applicationVariants.all { variant ->
@ -377,9 +385,8 @@ dependencies {
implementation "com.github.bumptech.glide:glide:4.9.0" implementation "com.github.bumptech.glide:glide:4.9.0"
annotationProcessor "com.github.bumptech.glide:compiler:4.9.0" annotationProcessor "com.github.bumptech.glide:compiler:4.9.0"
implementation "com.tencent:mmkv-static:1.2.10" implementation "com.tencent:mmkv-static:1.2.10"
androidTestImplementation('com.wix:detox:+') androidTestImplementation('com.wix:detox:+') { transitive = true }
implementation 'androidx.appcompat:appcompat:1.1.0' androidTestImplementation 'junit:junit:4.12'
implementation 'com.facebook.soloader:soloader:0.10.4'
} }
if (isNewArchitectureEnabled()) { if (isNewArchitectureEnabled()) {

View File

@ -18,7 +18,7 @@ public class DetoxTest {
@Rule @Rule
// Replace 'MainActivity' with the value of android:name entry in // Replace 'MainActivity' with the value of android:name entry in
// <activity> in AndroidManifest.xml // <activity> in AndroidManifest.xml
public ActivityTestRule<chat.rocket.reactnative.MainActivity> mActivityRule = new ActivityTestRule<>(chat.rocket.reactnative.MainActivity.class, false, false); public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
@Test @Test
public void runDetoxTests() { public void runDetoxTests() {

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:tools="http://schemas.android.com/tools">
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates src="user"
tools:ignore="AcceptsUserCertificates" />
</trust-anchors>
</base-config>
</network-security-config>

View File

@ -12,8 +12,14 @@
<uses-permission android:name="android.permission.AUDIO_CAPTURE" /> <uses-permission android:name="android.permission.AUDIO_CAPTURE" />
<!-- permissions related to jitsi call --> <!-- permissions related to jitsi call -->
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" android:usesPermissionFlags="neverForLocation" tools:targetApi="s" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" tools:targetApi="Q"/>
<application <application
android:name="chat.rocket.reactnative.MainApplication" android:name="chat.rocket.reactnative.MainApplication"
android:allowBackup="false" android:allowBackup="false"

View File

@ -7,8 +7,4 @@
tools:ignore="AcceptsUserCertificates" /> tools:ignore="AcceptsUserCertificates" />
</trust-anchors> </trust-anchors>
</base-config> </base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config> </network-security-config>

View File

@ -1,5 +1,9 @@
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase() def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase()
@ -71,38 +75,5 @@ allprojects {
google() google()
maven { url 'https://maven.google.com' } maven { url 'https://maven.google.com' }
maven { url 'https://www.jitpack.io' } maven { url 'https://www.jitpack.io' }
// https://stackoverflow.com/a/74333788/5447468
// TODO: remove once we update RN
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
// NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
url "$rootDir/../node_modules/react-native/android"
}
}
}
}
}
subprojects { subproject ->
afterEvaluate {
if (!project.name.equalsIgnoreCase("app") && project.hasProperty("android")) {
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
minSdkVersion 23
targetSdkVersion 31
}
}
}
} }
} }

View File

@ -40,14 +40,7 @@ export const INQUIRY = createRequestTypes('INQUIRY', [
'QUEUE_UPDATE', 'QUEUE_UPDATE',
'QUEUE_REMOVE' 'QUEUE_REMOVE'
]); ]);
export const APP = createRequestTypes('APP', [ export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT', 'INIT_LOCAL_SETTINGS', 'SET_MASTER_DETAIL']);
'START',
'READY',
'INIT',
'INIT_LOCAL_SETTINGS',
'SET_MASTER_DETAIL',
'SET_NOTIFICATION_PRESENCE_CAP'
]);
export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']); export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']);
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]); export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
export const CREATE_DISCUSSION = createRequestTypes('CREATE_DISCUSSION', [...defaultTypes]); export const CREATE_DISCUSSION = createRequestTypes('CREATE_DISCUSSION', [...defaultTypes]);

View File

@ -12,11 +12,7 @@ interface ISetMasterDetail extends Action {
isMasterDetail: boolean; isMasterDetail: boolean;
} }
interface ISetNotificationPresenceCap extends Action { export type TActionApp = IAppStart & ISetMasterDetail;
show: boolean;
}
export type TActionApp = IAppStart & ISetMasterDetail & ISetNotificationPresenceCap;
interface Params { interface Params {
root: RootEnum; root: RootEnum;
@ -55,10 +51,3 @@ export function setMasterDetail(isMasterDetail: boolean): ISetMasterDetail {
isMasterDetail isMasterDetail
}; };
} }
export function setNotificationPresenceCap(show: boolean): ISetNotificationPresenceCap {
return {
type: APP.SET_NOTIFICATION_PRESENCE_CAP,
show
};
}

View File

@ -1,5 +1,4 @@
export const mappedIcons = { export const mappedIcons = {
'status-disabled': 59837,
'lamp-bulb': 59836, 'lamp-bulb': 59836,
'phone-in': 59835, 'phone-in': 59835,
'basketball': 59776, 'basketball': 59776,

File diff suppressed because one or more lines are too long

View File

@ -1,31 +1,34 @@
import React from 'react'; import React from 'react';
import { useWindowDimensions } from 'react-native';
import { FlatList } from 'react-native-gesture-handler'; import { FlatList } from 'react-native-gesture-handler';
import { IEmoji } from '../../definitions/IEmoji';
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
import { PressableEmoji } from './PressableEmoji';
import { EMOJI_BUTTON_SIZE } from './styles'; import { EMOJI_BUTTON_SIZE } from './styles';
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
import { IEmoji } from '../../definitions/IEmoji';
import { PressableEmoji } from './PressableEmoji';
interface IEmojiCategoryProps { interface IEmojiCategoryProps {
emojis: IEmoji[]; emojis: IEmoji[];
onEmojiSelected: (emoji: IEmoji) => void; onEmojiSelected: (emoji: IEmoji) => void;
tabLabel?: string; // needed for react-native-scrollable-tab-view only tabLabel?: string; // needed for react-native-scrollable-tab-view only
parentWidth: number;
} }
const EmojiCategory = ({ onEmojiSelected, emojis, parentWidth }: IEmojiCategoryProps): React.ReactElement | null => { const EmojiCategory = ({ onEmojiSelected, emojis }: IEmojiCategoryProps): React.ReactElement | null => {
if (!parentWidth) { const { width } = useWindowDimensions();
return null;
}
const numColumns = Math.trunc(parentWidth / EMOJI_BUTTON_SIZE); const numColumns = Math.trunc(width / EMOJI_BUTTON_SIZE);
const marginHorizontal = (parentWidth % EMOJI_BUTTON_SIZE) / 2; const marginHorizontal = (width % EMOJI_BUTTON_SIZE) / 2;
const renderItem = ({ item }: { item: IEmoji }) => <PressableEmoji emoji={item} onPress={onEmojiSelected} />; const renderItem = ({ item }: { item: IEmoji }) => <PressableEmoji emoji={item} onPress={onEmojiSelected} />;
if (!width) {
return null;
}
return ( return (
<FlatList <FlatList
key={`emoji-category-${parentWidth}`} // needed to update the numColumns when the width changes
key={`emoji-category-${width}`}
keyExtractor={item => (typeof item === 'string' ? item : item.name)} keyExtractor={item => (typeof item === 'string' ? item : item.name)}
data={emojis} data={emojis}
renderItem={renderItem} renderItem={renderItem}

View File

@ -1,4 +1,4 @@
import React, { useState } from 'react'; import React from 'react';
import { View } from 'react-native'; import { View } from 'react-native';
import ScrollableTabView from 'react-native-scrollable-tab-view'; import ScrollableTabView from 'react-native-scrollable-tab-view';
@ -20,8 +20,6 @@ const EmojiPicker = ({
searchedEmojis = [] searchedEmojis = []
}: IEmojiPickerProps): React.ReactElement | null => { }: IEmojiPickerProps): React.ReactElement | null => {
const { colors } = useTheme(); const { colors } = useTheme();
const [parentWidth, setParentWidth] = useState(0);
const { frequentlyUsed, loaded } = useFrequentlyUsedEmoji(); const { frequentlyUsed, loaded } = useFrequentlyUsedEmoji();
const allCustomEmojis: ICustomEmojis = useAppSelector( const allCustomEmojis: ICustomEmojis = useAppSelector(
@ -52,14 +50,7 @@ const EmojiPicker = ({
if (!emojis.length) { if (!emojis.length) {
return null; return null;
} }
return ( return <EmojiCategory emojis={emojis} onEmojiSelected={(emoji: IEmoji) => handleEmojiSelect(emoji)} tabLabel={label} />;
<EmojiCategory
parentWidth={parentWidth}
emojis={emojis}
onEmojiSelected={(emoji: IEmoji) => handleEmojiSelect(emoji)}
tabLabel={label}
/>
);
}; };
if (!loaded) { if (!loaded) {
@ -67,13 +58,9 @@ const EmojiPicker = ({
} }
return ( return (
<View style={styles.emojiPickerContainer} onLayout={e => setParentWidth(e.nativeEvent.layout.width)}> <View style={styles.emojiPickerContainer}>
{searching ? ( {searching ? (
<EmojiCategory <EmojiCategory emojis={searchedEmojis} onEmojiSelected={(emoji: IEmoji) => handleEmojiSelect(emoji)} />
emojis={searchedEmojis}
onEmojiSelected={(emoji: IEmoji) => handleEmojiSelect(emoji)}
parentWidth={parentWidth}
/>
) : ( ) : (
<ScrollableTabView <ScrollableTabView
renderTabBar={() => <TabBar />} renderTabBar={() => <TabBar />}

View File

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import { StyleSheet, View } from 'react-native'; import { StyleSheet } from 'react-native';
import { STATUS_COLORS } from '../../lib/constants';
import UnreadBadge from '../UnreadBadge'; import UnreadBadge from '../UnreadBadge';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
@ -16,8 +15,6 @@ const styles = StyleSheet.create({
} }
}); });
export const BadgeUnread = ({ ...props }): React.ReactElement => <UnreadBadge {...props} style={styles.badgeContainer} small />; export const Badge = ({ ...props }): React.ReactElement => <UnreadBadge {...props} style={styles.badgeContainer} small />;
export const BadgeWarn = (): React.ReactElement => ( export default Badge;
<View style={[styles.badgeContainer, { width: 10, height: 10, backgroundColor: STATUS_COLORS.disabled }]} />
);

View File

@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import { View } from 'react-native';
import { Header, HeaderBackground } from '@react-navigation/elements'; import { Header, HeaderBackground } from '@react-navigation/elements';
import { NavigationContainer } from '@react-navigation/native'; import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context'; import { SafeAreaProvider } from 'react-native-safe-area-context';
@ -104,10 +103,9 @@ export const Badge = () => (
<HeaderExample <HeaderExample
left={() => ( left={() => (
<HeaderButton.Container left> <HeaderButton.Container left>
<HeaderButton.Item iconName='threads' badge={() => <HeaderButton.BadgeUnread tunread={[1]} />} /> <HeaderButton.Item iconName='threads' badge={() => <HeaderButton.Badge tunread={[1]} />} />
<HeaderButton.Item iconName='threads' badge={() => <HeaderButton.BadgeUnread tunread={[1]} tunreadUser={[1]} />} /> <HeaderButton.Item iconName='threads' badge={() => <HeaderButton.Badge tunread={[1]} tunreadUser={[1]} />} />
<HeaderButton.Item iconName='threads' badge={() => <HeaderButton.BadgeUnread tunread={[1]} tunreadGroup={[1]} />} /> <HeaderButton.Item iconName='threads' badge={() => <HeaderButton.Badge tunread={[1]} tunreadGroup={[1]} />} />
<HeaderButton.Drawer badge={() => <HeaderButton.BadgeWarn />} />
</HeaderButton.Container> </HeaderButton.Container>
)} )}
/> />
@ -116,23 +114,20 @@ export const Badge = () => (
const ThemeStory = ({ theme }: { theme: TSupportedThemes }) => ( const ThemeStory = ({ theme }: { theme: TSupportedThemes }) => (
<ThemeContext.Provider value={{ theme, colors: colors[theme] }}> <ThemeContext.Provider value={{ theme, colors: colors[theme] }}>
<View style={{ flexDirection: 'column' }}> <HeaderExample
<HeaderExample left={() => (
left={() => ( <HeaderButton.Container left>
<HeaderButton.Container left> <HeaderButton.Item iconName='threads' />
<HeaderButton.Drawer badge={() => <HeaderButton.BadgeWarn />} /> </HeaderButton.Container>
<HeaderButton.Item iconName='threads' /> )}
</HeaderButton.Container> right={() => (
)} <HeaderButton.Container>
right={() => ( <HeaderButton.Item title='Threads' />
<HeaderButton.Container> <HeaderButton.Item iconName='threads' badge={() => <HeaderButton.Badge tunread={[1]} />} />
<HeaderButton.Item title='Threads' /> </HeaderButton.Container>
<HeaderButton.Item iconName='threads' badge={() => <HeaderButton.BadgeUnread tunread={[1]} />} /> )}
</HeaderButton.Container> colors={colors[theme]}
)} />
colors={colors[theme]}
/>
</View>
</ThemeContext.Provider> </ThemeContext.Provider>
); );

View File

@ -1,4 +1,4 @@
export { default as Container } from './HeaderButtonContainer'; export { default as Container } from './HeaderButtonContainer';
export { default as Item } from './HeaderButtonItem'; export { default as Item } from './HeaderButtonItem';
export * from './HeaderButtonItemBadge'; export { default as Badge } from './HeaderButtonItemBadge';
export * from './Common'; export * from './Common';

View File

@ -1062,7 +1062,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
}; };
formatReplyMessage = async (replyingMessage: IMessage, message = '') => { formatReplyMessage = async (replyingMessage: IMessage, message = '') => {
const { user, roomType, replyWithMention, serverVersion } = this.props; const { user, roomType, replyWithMention } = this.props;
const permalink = await this.getPermalink(replyingMessage); const permalink = await this.getPermalink(replyingMessage);
let msg = `[ ](${permalink}) `; let msg = `[ ](${permalink}) `;
@ -1071,8 +1071,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
msg += `@${replyingMessage?.u?.username} `; msg += `@${replyingMessage?.u?.username} `;
} }
const connectionString = compareServerVersion(serverVersion, 'lowerThan', '5.0.0') ? ' ' : '\n'; return `${msg} ${message}`;
return `${msg}${connectionString}${message}`;
}; };
updateMentions = (keyword: any, type: string) => { updateMentions = (keyword: any, type: string) => {

View File

@ -46,7 +46,6 @@ const RoomHeaderContainer = React.memo(
const connecting = useSelector((state: IApplicationState) => state.meteor.connecting || state.server.loading); const connecting = useSelector((state: IApplicationState) => state.meteor.connecting || state.server.loading);
const usersTyping = useSelector((state: IApplicationState) => state.usersTyping, shallowEqual); const usersTyping = useSelector((state: IApplicationState) => state.usersTyping, shallowEqual);
const connected = useSelector((state: IApplicationState) => state.meteor.connected); const connected = useSelector((state: IApplicationState) => state.meteor.connected);
const presenceDisabled = useSelector((state: IApplicationState) => state.settings.Presence_broadcast_disabled);
const activeUser = useSelector( const activeUser = useSelector(
(state: IApplicationState) => (roomUserId ? state.activeUsers?.[roomUserId] : undefined), (state: IApplicationState) => (roomUserId ? state.activeUsers?.[roomUserId] : undefined),
shallowEqual shallowEqual
@ -62,13 +61,9 @@ const RoomHeaderContainer = React.memo(
if (connected) { if (connected) {
if ((type === 'd' || (tmid && roomUserId)) && activeUser) { if ((type === 'd' || (tmid && roomUserId)) && activeUser) {
if (presenceDisabled) { const { status: statusActiveUser, statusText: statusTextActiveUser } = activeUser;
status = 'disabled'; status = statusActiveUser;
} else { statusText = statusTextActiveUser;
const { status: statusActiveUser, statusText: statusTextActiveUser } = activeUser;
status = statusActiveUser;
statusText = statusTextActiveUser;
}
} else if (type === 'l' && visitor?.status) { } else if (type === 'l' && visitor?.status) {
const { status: statusVisitor } = visitor; const { status: statusVisitor } = visitor;
status = statusVisitor; status = statusVisitor;

View File

@ -65,7 +65,6 @@ export const UserStatus = () => (
<RoomItem status='busy' /> <RoomItem status='busy' />
<RoomItem status='offline' /> <RoomItem status='offline' />
<RoomItem status='loading' /> <RoomItem status='loading' />
<RoomItem status='disabled' />
<RoomItem status='wrong' /> <RoomItem status='wrong' />
</> </>
); );

View File

@ -8,17 +8,11 @@ export const useUserStatus = (
id?: string id?: string
): { connected: boolean; status: TUserStatus } => { ): { connected: boolean; status: TUserStatus } => {
const connected = useAppSelector(state => state.meteor.connected); const connected = useAppSelector(state => state.meteor.connected);
const presenceDisabled = useAppSelector(state => state.settings.Presence_broadcast_disabled);
const userStatus = useAppSelector(state => state.activeUsers[id || '']?.status); const userStatus = useAppSelector(state => state.activeUsers[id || '']?.status);
let status = 'loading'; let status = 'loading';
if (connected) { if (connected) {
if (type === 'd') { if (type === 'd') {
if (presenceDisabled) { status = userStatus || 'loading';
status = 'disabled';
} else {
status = userStatus || 'loading';
}
} else if (type === 'l' && liveChatStatus) { } else if (type === 'l' && liveChatStatus) {
status = liveChatStatus; status = liveChatStatus;
} }

View File

@ -1,4 +1,4 @@
import React, { useState } from 'react'; import React from 'react';
import { StyleProp, ViewStyle } from 'react-native'; import { StyleProp, ViewStyle } from 'react-native';
import { SvgUri } from 'react-native-svg'; import { SvgUri } from 'react-native-svg';
@ -29,12 +29,22 @@ interface IOmnichannelRoomIconProps {
} }
export const OmnichannelRoomIcon = ({ size, style, sourceType, status }: IOmnichannelRoomIconProps) => { export const OmnichannelRoomIcon = ({ size, style, sourceType, status }: IOmnichannelRoomIconProps) => {
const [loading, setLoading] = useState(true);
const [svgError, setSvgError] = useState(false);
const baseUrl = useAppSelector(state => state.server?.server); const baseUrl = useAppSelector(state => state.server?.server);
const connected = useAppSelector(state => state.meteor?.connected); const connected = useAppSelector(state => state.meteor?.connected);
const customIcon = ( if (sourceType?.type === OmnichannelSourceType.APP && sourceType.id && sourceType.sidebarIcon && connected) {
return (
<SvgUri
height={size}
width={size}
color={STATUS_COLORS[status || 'offline']}
uri={`${baseUrl}/api/apps/public/${sourceType.id}/get-sidebar-icon?icon=${sourceType.sidebarIcon}`}
style={style}
/>
);
}
return (
<CustomIcon <CustomIcon
name={iconMap[sourceType?.type || 'other']} name={iconMap[sourceType?.type || 'other']}
size={size} size={size}
@ -42,23 +52,4 @@ export const OmnichannelRoomIcon = ({ size, style, sourceType, status }: IOmnich
color={STATUS_COLORS[status || 'offline']} color={STATUS_COLORS[status || 'offline']}
/> />
); );
if (!svgError && sourceType?.type === OmnichannelSourceType.APP && sourceType.id && sourceType.sidebarIcon && connected) {
return (
<>
<SvgUri
height={size}
width={size}
color={STATUS_COLORS[status || 'offline']}
uri={`${baseUrl}/api/apps/public/${sourceType.id}/get-sidebar-icon?icon=${sourceType.sidebarIcon}`}
style={style}
onError={() => setSvgError(true)}
onLoad={() => setLoading(false)}
/>
{loading ? customIcon : null}
</>
);
}
return customIcon;
}; };

View File

@ -6,15 +6,9 @@ import { IStatus } from './definition';
import { useAppSelector } from '../../lib/hooks'; import { useAppSelector } from '../../lib/hooks';
const StatusContainer = ({ id, style, size = 32, ...props }: Omit<IStatus, 'status'>): React.ReactElement => { const StatusContainer = ({ id, style, size = 32, ...props }: Omit<IStatus, 'status'>): React.ReactElement => {
const status = useAppSelector(state => { const status = useAppSelector(state =>
if (state.settings.Presence_broadcast_disabled) { state.meteor.connected ? state.activeUsers[id] && state.activeUsers[id].status : 'loading'
return 'disabled'; ) as TUserStatus;
}
if (state.meteor.connected) {
return state.activeUsers[id] && state.activeUsers[id].status;
}
return 'loading';
}) as TUserStatus;
return <Status size={size} style={style} status={status} {...props} />; return <Status size={size} style={style} status={status} {...props} />;
}; };

View File

@ -6,6 +6,7 @@ import i18n from '../../../../i18n';
import { getSubscriptionByRoomId } from '../../../../lib/database/services/Subscription'; import { getSubscriptionByRoomId } from '../../../../lib/database/services/Subscription';
import { useAppSelector } from '../../../../lib/hooks'; import { useAppSelector } from '../../../../lib/hooks';
import { getRoomAvatar, getUidDirectMessage } from '../../../../lib/methods/helpers'; import { getRoomAvatar, getUidDirectMessage } from '../../../../lib/methods/helpers';
import { videoConfStartAndJoin } from '../../../../lib/methods/videoConf';
import { useTheme } from '../../../../theme'; import { useTheme } from '../../../../theme';
import { useActionSheet } from '../../../ActionSheet'; import { useActionSheet } from '../../../ActionSheet';
import AvatarContainer from '../../../Avatar'; import AvatarContainer from '../../../Avatar';
@ -15,12 +16,12 @@ import { BUTTON_HIT_SLOP } from '../../../message/utils';
import StatusContainer from '../../../Status'; import StatusContainer from '../../../Status';
import useStyle from './styles'; import useStyle from './styles';
export default function StartACallActionSheet({ rid, initCall }: { rid: string; initCall: Function }): React.ReactElement { export default function CallAgainActionSheet({ rid }: { rid: string }): React.ReactElement {
const style = useStyle(); const style = useStyle();
const { colors } = useTheme(); const { colors } = useTheme();
const [user, setUser] = useState({ username: '', avatar: '', uid: '' }); const [user, setUser] = useState({ username: '', avatar: '', uid: '', rid: '' });
const [mic, setMic] = useState(true); const [phone, setPhone] = useState(true);
const [cam, setCam] = useState(false); const [camera, setCamera] = useState(false);
const username = useAppSelector(state => state.login.user.username); const username = useAppSelector(state => state.login.user.username);
const { hideActionSheet } = useActionSheet(); const { hideActionSheet } = useActionSheet();
@ -30,7 +31,7 @@ export default function StartACallActionSheet({ rid, initCall }: { rid: string;
const room = await getSubscriptionByRoomId(rid); const room = await getSubscriptionByRoomId(rid);
const uid = (await getUidDirectMessage(room)) as string; const uid = (await getUidDirectMessage(room)) as string;
const avt = getRoomAvatar(room); const avt = getRoomAvatar(room);
setUser({ uid, username: room?.name || '', avatar: avt }); setUser({ uid, username: room?.name || '', avatar: avt, rid: room?.id || '' });
})(); })();
}, [rid]); }, [rid]);
@ -42,27 +43,25 @@ export default function StartACallActionSheet({ rid, initCall }: { rid: string;
<Text style={style.actionSheetHeaderTitle}>{i18n.t('Start_a_call')}</Text> <Text style={style.actionSheetHeaderTitle}>{i18n.t('Start_a_call')}</Text>
<View style={style.actionSheetHeaderButtons}> <View style={style.actionSheetHeaderButtons}>
<Touchable <Touchable
onPress={() => setCam(!cam)} onPress={() => setCamera(!camera)}
style={[style.iconCallContainer, cam && style.enabledBackground, { marginRight: 6 }]} style={[style.iconCallContainer, camera && style.enabledBackground, { marginRight: 6 }]}
hitSlop={BUTTON_HIT_SLOP} hitSlop={BUTTON_HIT_SLOP}
> >
<CustomIcon name={cam ? 'camera' : 'camera-disabled'} size={20} color={handleColor(cam)} /> <CustomIcon name={camera ? 'camera' : 'camera-disabled'} size={16} color={handleColor(camera)} />
</Touchable> </Touchable>
<Touchable <Touchable
onPress={() => setMic(!mic)} onPress={() => setPhone(!phone)}
style={[style.iconCallContainer, mic && style.enabledBackground]} style={[style.iconCallContainer, phone && style.enabledBackground]}
hitSlop={BUTTON_HIT_SLOP} hitSlop={BUTTON_HIT_SLOP}
> >
<CustomIcon name={mic ? 'microphone' : 'microphone-disabled'} size={20} color={handleColor(mic)} /> <CustomIcon name={phone ? 'microphone' : 'microphone-disabled'} size={16} color={handleColor(phone)} />
</Touchable> </Touchable>
</View> </View>
</View> </View>
<View style={style.actionSheetUsernameContainer}> <View style={style.actionSheetUsernameContainer}>
<AvatarContainer text={user.avatar} size={36} /> <AvatarContainer text={user.avatar} size={36} />
<StatusContainer size={16} id={user.uid} style={{ marginLeft: 8, marginRight: 6 }} /> <StatusContainer size={16} id={user.uid} style={{ marginLeft: 8, marginRight: 6 }} />
<Text style={style.actionSheetUsername} numberOfLines={1}> <Text style={style.actionSheetUsername}>{user.username}</Text>
{user.username}
</Text>
</View> </View>
<View style={style.actionSheetPhotoContainer}> <View style={style.actionSheetPhotoContainer}>
<AvatarContainer size={62} text={username} /> <AvatarContainer size={62} text={username} />
@ -71,7 +70,7 @@ export default function StartACallActionSheet({ rid, initCall }: { rid: string;
onPress={() => { onPress={() => {
hideActionSheet(); hideActionSheet();
setTimeout(() => { setTimeout(() => {
initCall({ cam, mic }); videoConfStartAndJoin(user.rid, camera);
}, 100); }, 100);
}} }}
title={i18n.t('Call')} title={i18n.t('Call')}

View File

@ -3,16 +3,17 @@ import { Text } from 'react-native';
import Touchable from 'react-native-platform-touchable'; import Touchable from 'react-native-platform-touchable';
import i18n from '../../../../i18n'; import i18n from '../../../../i18n';
import { videoConfJoin } from '../../../../lib/methods/videoConf'; import { useVideoConf } from '../../../../lib/hooks/useVideoConf';
import useStyle from './styles'; import useStyle from './styles';
import { VideoConferenceBaseContainer } from './VideoConferenceBaseContainer'; import { VideoConferenceBaseContainer } from './VideoConferenceBaseContainer';
const VideoConferenceDirect = React.memo(({ blockId }: { blockId: string }) => { const VideoConferenceDirect = React.memo(({ blockId }: { blockId: string }) => {
const style = useStyle(); const style = useStyle();
const { joinCall } = useVideoConf();
return ( return (
<VideoConferenceBaseContainer variant='incoming'> <VideoConferenceBaseContainer variant='incoming'>
<Touchable style={style.callToActionButton} onPress={() => videoConfJoin(blockId)}> <Touchable style={style.callToActionButton} onPress={() => joinCall(blockId)}>
<Text style={style.callToActionButtonText}>{i18n.t('Join')}</Text> <Text style={style.callToActionButtonText}>{i18n.t('Join')}</Text>
</Touchable> </Touchable>
<Text style={style.callBack}>{i18n.t('Waiting_for_answer')}</Text> <Text style={style.callBack}>{i18n.t('Waiting_for_answer')}</Text>

View File

@ -6,7 +6,9 @@ import { IUser } from '../../../../definitions';
import { VideoConferenceType } from '../../../../definitions/IVideoConference'; import { VideoConferenceType } from '../../../../definitions/IVideoConference';
import i18n from '../../../../i18n'; import i18n from '../../../../i18n';
import { useAppSelector } from '../../../../lib/hooks'; import { useAppSelector } from '../../../../lib/hooks';
import { useVideoConf } from '../../../../lib/hooks/useVideoConf'; import { useSnaps } from '../../../../lib/hooks/useSnaps';
import { useActionSheet } from '../../../ActionSheet';
import CallAgainActionSheet from './CallAgainActionSheet';
import { CallParticipants, TCallUsers } from './CallParticipants'; import { CallParticipants, TCallUsers } from './CallParticipants';
import useStyle from './styles'; import useStyle from './styles';
import { VideoConferenceBaseContainer } from './VideoConferenceBaseContainer'; import { VideoConferenceBaseContainer } from './VideoConferenceBaseContainer';
@ -24,7 +26,8 @@ export default function VideoConferenceEnded({
}): React.ReactElement { }): React.ReactElement {
const style = useStyle(); const style = useStyle();
const username = useAppSelector(state => state.login.user.username); const username = useAppSelector(state => state.login.user.username);
const { showInitCallActionSheet } = useVideoConf(rid); const { showActionSheet } = useActionSheet();
const snaps = useSnaps([1250]);
const onlyAuthorOnCall = users.length === 1 && users.some(user => user.username === createdBy.username); const onlyAuthorOnCall = users.length === 1 && users.some(user => user.username === createdBy.username);
@ -32,7 +35,15 @@ export default function VideoConferenceEnded({
<VideoConferenceBaseContainer variant='ended'> <VideoConferenceBaseContainer variant='ended'>
{type === 'direct' ? ( {type === 'direct' ? (
<> <>
<Touchable style={style.callToActionCallBack} onPress={showInitCallActionSheet}> <Touchable
style={style.callToActionCallBack}
onPress={() =>
showActionSheet({
children: <CallAgainActionSheet rid={rid} />,
snaps
})
}
>
<Text style={style.callToActionCallBackText}> <Text style={style.callToActionCallBackText}>
{createdBy.username === username ? i18n.t('Call_back') : i18n.t('Call_again')} {createdBy.username === username ? i18n.t('Call_back') : i18n.t('Call_again')}
</Text> </Text>

View File

@ -3,17 +3,18 @@ import { Text } from 'react-native';
import Touchable from 'react-native-platform-touchable'; import Touchable from 'react-native-platform-touchable';
import i18n from '../../../../i18n'; import i18n from '../../../../i18n';
import { videoConfJoin } from '../../../../lib/methods/videoConf'; import { useVideoConf } from '../../../../lib/hooks/useVideoConf';
import { CallParticipants, TCallUsers } from './CallParticipants'; import { CallParticipants, TCallUsers } from './CallParticipants';
import useStyle from './styles'; import useStyle from './styles';
import { VideoConferenceBaseContainer } from './VideoConferenceBaseContainer'; import { VideoConferenceBaseContainer } from './VideoConferenceBaseContainer';
export default function VideoConferenceOutgoing({ users, blockId }: { users: TCallUsers; blockId: string }): React.ReactElement { export default function VideoConferenceOutgoing({ users, blockId }: { users: TCallUsers; blockId: string }): React.ReactElement {
const style = useStyle(); const style = useStyle();
const { joinCall } = useVideoConf();
return ( return (
<VideoConferenceBaseContainer variant='outgoing'> <VideoConferenceBaseContainer variant='outgoing'>
<Touchable style={style.callToActionButton} onPress={() => videoConfJoin(blockId)}> <Touchable style={style.callToActionButton} onPress={() => joinCall(blockId)}>
<Text style={style.callToActionButtonText}>{i18n.t('Join')}</Text> <Text style={style.callToActionButtonText}>{i18n.t('Join')}</Text>
</Touchable> </Touchable>
<CallParticipants users={users} /> <CallParticipants users={users} />

View File

@ -100,8 +100,7 @@ export default function useStyle() {
actionSheetUsername: { actionSheetUsername: {
fontSize: 16, fontSize: 16,
...sharedStyles.textBold, ...sharedStyles.textBold,
color: colors.passcodePrimary, color: colors.passcodePrimary
flexShrink: 1
}, },
enabledBackground: { enabledBackground: {
backgroundColor: colors.conferenceCallEnabledIconBackground backgroundColor: colors.conferenceCallEnabledIconBackground

View File

@ -2,7 +2,7 @@
import { BlockContext } from '@rocket.chat/ui-kit'; import { BlockContext } from '@rocket.chat/ui-kit';
import React, { useContext, useState } from 'react'; import React, { useContext, useState } from 'react';
import { videoConfJoin } from '../../lib/methods/videoConf'; import { useVideoConf } from '../../lib/hooks/useVideoConf';
import { IText } from './interfaces'; import { IText } from './interfaces';
export const textParser = ([{ text }]: IText[]) => text; export const textParser = ([{ text }]: IText[]) => text;
@ -40,6 +40,7 @@ export const useBlockContext = ({ blockId, actionId, appId, initialValue }: IUse
const { action, appId: appIdFromContext, viewId, state, language, errors, values = {} } = useContext(KitContext); const { action, appId: appIdFromContext, viewId, state, language, errors, values = {} } = useContext(KitContext);
const { value = initialValue } = values[actionId] || {}; const { value = initialValue } = values[actionId] || {};
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const { joinCall } = useVideoConf();
const error = errors && actionId && errors[actionId]; const error = errors && actionId && errors[actionId];
@ -57,7 +58,7 @@ export const useBlockContext = ({ blockId, actionId, appId, initialValue }: IUse
try { try {
if (appId === 'videoconf-core' && blockId) { if (appId === 'videoconf-core' && blockId) {
setLoading(false); setLoading(false);
return videoConfJoin(blockId); return joinCall(blockId);
} }
await action({ await action({
blockId, blockId,

View File

@ -16,13 +16,11 @@ const styles = StyleSheet.create({
}, },
bottomContainerText: { bottomContainerText: {
...sharedStyles.textRegular, ...sharedStyles.textRegular,
fontSize: 13, fontSize: 13
textAlign: 'center'
}, },
bottomContainerTextBold: { bottomContainerTextBold: {
...sharedStyles.textSemibold, ...sharedStyles.textSemibold,
fontSize: 13, fontSize: 13
textAlign: 'center'
} }
}); });

View File

@ -18,29 +18,13 @@ import MarkdownContext from './MarkdownContext';
interface IParagraphProps { interface IParagraphProps {
value: ParagraphProps['value']; value: ParagraphProps['value'];
forceTrim?: boolean;
} }
const Inline = ({ value, forceTrim }: IParagraphProps): React.ReactElement | null => { const Inline = ({ value }: IParagraphProps): React.ReactElement | null => {
const { useRealName, username, navToRoomInfo, mentions, channels } = useContext(MarkdownContext); const { useRealName, username, navToRoomInfo, mentions, channels } = useContext(MarkdownContext);
return ( return (
<Text style={styles.inline}> <Text style={styles.inline}>
{value.map((block, index) => { {value.map(block => {
// We are forcing trim when is a `[ ](https://https://open.rocket.chat/) plain_text`
// to clean the empty spaces
if (forceTrim) {
if (index === 0 && block.type === 'LINK') {
block.value.label.value =
// Need to update the @rocket.chat/message-parser to understand that the label can be a Markup | Markup[]
// https://github.com/RocketChat/fuselage/blob/461ecf661d9ff4a46390957c915e4352fa942a7c/packages/message-parser/src/definitions.ts#L141
// @ts-ignore
block.value?.label?.value?.toString().trimLeft() || block?.value?.label?.[0]?.value?.toString().trimLeft();
}
if (index === 1 && block.type !== 'LINK') {
block.value = block.value?.toString().trimLeft();
}
}
switch (block.type) { switch (block.type) {
case 'IMAGE': case 'IMAGE':
return <Image value={block.value} />; return <Image value={block.value} />;

View File

@ -381,6 +381,27 @@ export const BlockQuote = () => (
</View> </View>
); );
const rocketChatLink = [
{
type: 'PARAGRAPH',
value: [
{
type: 'LINK',
value: {
src: {
type: 'PLAIN_TEXT',
value: 'https://rocket.chat'
},
label: {
type: 'PLAIN_TEXT',
value: 'https://rocket.chat'
}
}
}
]
}
];
const markdownLink = [ const markdownLink = [
{ {
type: 'PARAGRAPH', type: 'PARAGRAPH',
@ -466,6 +487,7 @@ const markdownLinkWithEmphasis = [
export const Links = () => ( export const Links = () => (
<View style={styles.container}> <View style={styles.container}>
<NewMarkdown tokens={rocketChatLink} />
<NewMarkdown tokens={markdownLink} /> <NewMarkdown tokens={markdownLink} />
<NewMarkdown tokens={markdownLinkWithEmphasis} /> <NewMarkdown tokens={markdownLinkWithEmphasis} />
</View> </View>
@ -784,128 +806,3 @@ export const InlineKatex = () => (
<NewMarkdown tokens={inlineKatex} /> <NewMarkdown tokens={inlineKatex} />
</View> </View>
); );
const messageQuote = {
/**
# Hello head 1
[ ](https://google.com)
*/
headAndLink: [
{ type: 'HEADING', level: 1, value: [{ type: 'PLAIN_TEXT', value: 'Hello head 1' }] },
{ type: 'LINE_BREAK' },
{
type: 'PARAGRAPH',
value: [
{
type: 'LINK',
value: { src: { type: 'PLAIN_TEXT', value: 'https://google.com' }, label: { type: 'PLAIN_TEXT', value: ' ' } }
}
]
}
],
/**
# Head 1 as the first line then line break and after paragraph
bla bla bla bla bla bla
bla bla bla bla bla bla
[ ](https://google.com)
*/
headTextAndLink: [
{
type: 'HEADING',
level: 1,
value: [{ type: 'PLAIN_TEXT', value: 'Head 1 as the first line then line break and after paragraph' }]
},
{ type: 'LINE_BREAK' },
{ type: 'PARAGRAPH', value: [{ type: 'PLAIN_TEXT', value: 'bla bla bla bla bla bla ' }] },
{ type: 'PARAGRAPH', value: [{ type: 'PLAIN_TEXT', value: 'bla bla bla bla bla bla ' }] },
{
type: 'PARAGRAPH',
value: [
{
type: 'LINK',
value: { src: { type: 'PLAIN_TEXT', value: 'https://google.com' }, label: { type: 'PLAIN_TEXT', value: ' ' } }
}
]
}
],
/**
[ ](permalink from message)\n# Head 1 after a forced line break
asdas asd asd asd
*/
headTextAndQuote: [
{
type: 'PARAGRAPH',
value: [
{
type: 'LINK',
value: {
src: { type: 'PLAIN_TEXT', value: 'https://open.rocket.chat/direct/subaru123?msg=QB42gWcaO6BgqtLTo' },
label: { type: 'PLAIN_TEXT', value: ' ' }
}
},
{ type: 'PLAIN_TEXT', value: ' ' }
]
},
{ type: 'HEADING', level: 1, value: [{ type: 'PLAIN_TEXT', value: 'Head 1 after a forced line break' }] },
{ type: 'LINE_BREAK' },
{ type: 'PARAGRAPH', value: [{ type: 'PLAIN_TEXT', value: 'Description' }] }
],
/**
[ ](https://google.com) *There is a link before this bold separated by single space*
*/
linkAndBoldText: [
{
type: 'PARAGRAPH',
value: [
{
type: 'LINK',
value: { src: { type: 'PLAIN_TEXT', value: 'https://google.com' }, label: { type: 'PLAIN_TEXT', value: ' ' } }
},
{ type: 'PLAIN_TEXT', value: ' ' },
{ type: 'BOLD', value: [{ type: 'PLAIN_TEXT', value: 'There is a link before this bold separated by single space' }] }
]
}
],
simpleQuote: [
{
type: 'PARAGRAPH',
value: [
{
type: 'LINK',
value: {
src: {
type: 'PLAIN_TEXT',
value: 'https://open.rocket.chat/group/quoteeee9798789?msg=ZZp6t2dCRX4TqExht'
},
// format of label for servers greater or equal than 6.0
label: [
{
type: 'PLAIN_TEXT',
value: ' '
}
]
}
}
]
},
{
type: 'PARAGRAPH',
value: [
{
type: 'PLAIN_TEXT',
value: 'Quoting a message wrote before'
}
]
}
]
};
export const MessageQuote = () => (
<View style={styles.container}>
<NewMarkdown tokens={messageQuote.headAndLink} />
<NewMarkdown tokens={messageQuote.headTextAndLink} />
<NewMarkdown tokens={messageQuote.headTextAndQuote} />
<NewMarkdown tokens={messageQuote.linkAndBoldText} />
<NewMarkdown tokens={messageQuote.simpleQuote} />
</View>
);

View File

@ -12,28 +12,10 @@ interface IParagraphProps {
} }
const Paragraph = ({ value }: IParagraphProps) => { const Paragraph = ({ value }: IParagraphProps) => {
let forceTrim = false;
const { theme } = useTheme(); const { theme } = useTheme();
if (
value?.[0]?.type === 'LINK' &&
// Need to update the @rocket.chat/message-parser to understand that the label can be a Markup | Markup[]
// https://github.com/RocketChat/fuselage/blob/461ecf661d9ff4a46390957c915e4352fa942a7c/packages/message-parser/src/definitions.ts#L141
// @ts-ignore
(value?.[0]?.value?.label?.value?.toString().trim() === '' || value?.[0]?.value?.label?.[0]?.value?.toString().trim() === '')
) {
// We are returning null when we receive a message like this: `[ ](https://open.rocket.chat/)\nplain_text`
// to avoid render a line empty above the the message
if (value.length === 1) {
return null;
}
if (value.length === 2 && value?.[1]?.type === 'PLAIN_TEXT' && value?.[1]?.value?.toString().trim() === '') {
return null;
}
forceTrim = true;
}
return ( return (
<Text style={[styles.text, { color: themes[theme].bodyText }]}> <Text style={[styles.text, { color: themes[theme].bodyText }]}>
<Inline value={value} forceTrim={forceTrim} /> <Inline value={value} />
</Text> </Text>
); );
}; };

View File

@ -8,7 +8,7 @@ interface IPlainProps {
value: PlainProps['value']; value: PlainProps['value'];
} }
const Plain = ({ value }: IPlainProps): React.ReactElement => ( const Plain = ({ value }: IPlainProps) => (
<Text accessibilityLabel={value} style={styles.plainText}> <Text accessibilityLabel={value} style={styles.plainText}>
{value} {value}
</Text> </Text>

View File

@ -4,6 +4,7 @@ import { Tasks as TasksProps } from '@rocket.chat/message-parser';
import Inline from './Inline'; import Inline from './Inline';
import styles from '../styles'; import styles from '../styles';
import { themes } from '../../../lib/constants';
import { useTheme } from '../../../theme'; import { useTheme } from '../../../theme';
interface ITasksProps { interface ITasksProps {
@ -11,15 +12,13 @@ interface ITasksProps {
} }
const TaskList = ({ value = [] }: ITasksProps) => { const TaskList = ({ value = [] }: ITasksProps) => {
const { colors } = useTheme(); const { theme } = useTheme();
return ( return (
<View> <View>
{value.map(item => ( {value.map(item => (
<View style={styles.row}> <View style={styles.row}>
<Text style={[styles.text, { color: colors.bodyText }]}>{item.status ? '- [x] ' : '- [ ] '}</Text> <Text style={[styles.text, { color: themes[theme].bodyText }]}>{item.status ? '- [x] ' : '- [ ] '}</Text>
<Text style={[styles.inline, { color: colors.bodyText }]}> <Inline value={item.value} />
<Inline value={item.value} />
</Text>
</View> </View>
))} ))}
</View> </View>

View File

@ -10,12 +10,12 @@ import { themes } from '../../lib/constants';
import { IMessageCallButton } from './interfaces'; import { IMessageCallButton } from './interfaces';
import { useTheme } from '../../theme'; import { useTheme } from '../../theme';
const CallButton = React.memo(({ handleEnterCall }: IMessageCallButton) => { const CallButton = React.memo(({ callJitsi }: IMessageCallButton) => {
const { theme } = useTheme(); const { theme } = useTheme();
return ( return (
<View style={styles.buttonContainer}> <View style={styles.buttonContainer}>
<Touchable <Touchable
onPress={handleEnterCall} onPress={callJitsi}
background={Touchable.Ripple(themes[theme].bannerBackground)} background={Touchable.Ripple(themes[theme].bannerBackground)}
style={[styles.button, { backgroundColor: themes[theme].tintColor }]} style={[styles.button, { backgroundColor: themes[theme].tintColor }]}
hitSlop={BUTTON_HIT_SLOP} hitSlop={BUTTON_HIT_SLOP}

View File

@ -1,20 +1,14 @@
import React from 'react'; import React from 'react';
import { themes } from '../../../../lib/constants';
import { CustomIcon } from '../../../CustomIcon'; import { CustomIcon } from '../../../CustomIcon';
import styles from '../../styles'; import styles from '../../styles';
import { useTheme } from '../../../../theme'; import { useTheme } from '../../../../theme';
const ReadReceipt = React.memo(({ isReadReceiptEnabled, unread }: { isReadReceiptEnabled?: boolean; unread?: boolean }) => { const ReadReceipt = React.memo(({ isReadReceiptEnabled, unread }: { isReadReceiptEnabled?: boolean; unread?: boolean }) => {
const { colors } = useTheme(); const { theme } = useTheme();
if (isReadReceiptEnabled) { if (isReadReceiptEnabled && !unread && unread !== null) {
return ( return <CustomIcon name='check' color={themes[theme].tintColor} size={16} style={styles.rightIcons} />;
<CustomIcon
name='check'
color={!unread && unread !== null ? colors.tintColor : colors.auxiliaryTintColor}
size={16}
style={styles.rightIcons}
/>
);
} }
return null; return null;
}); });

View File

@ -53,7 +53,7 @@ const Content = React.memo(
content = ( content = (
<Markdown <Markdown
msg={props.msg} msg={props.msg}
md={props.type !== 'e2e' ? props.md : undefined} md={props.md}
getCustomEmoji={props.getCustomEmoji} getCustomEmoji={props.getCustomEmoji}
enableMessageParser={user.enableMessageParserEarlyAdoption} enableMessageParser={user.enableMessageParserEarlyAdoption}
username={user.username} username={user.username}

View File

@ -18,7 +18,7 @@ const MessageAvatar = React.memo(({ isHeader, avatar, author, small, navToRoomIn
style={small ? styles.avatarSmall : styles.avatar} style={small ? styles.avatarSmall : styles.avatar}
text={avatar ? '' : author.username} text={avatar ? '' : author.username}
size={small ? 20 : 36} size={small ? 20 : 36}
borderRadius={4} borderRadius={small ? 2 : 4}
onPress={author._id === user.id ? undefined : () => navToRoomInfo(navParam)} onPress={author._id === user.id ? undefined : () => navToRoomInfo(navParam)}
getCustomEmoji={getCustomEmoji} getCustomEmoji={getCustomEmoji}
avatar={avatar} avatar={avatar}

View File

@ -247,8 +247,6 @@ const Reply = React.memo(
> >
<View style={styles.attachmentContainer}> <View style={styles.attachmentContainer}>
<Title attachment={attachment} timeFormat={timeFormat} theme={theme} /> <Title attachment={attachment} timeFormat={timeFormat} theme={theme} />
<Description attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} />
<UrlImage image={attachment.thumb_url} />
<Attachments <Attachments
attachments={attachment.attachments} attachments={attachment.attachments}
getCustomEmoji={getCustomEmoji} getCustomEmoji={getCustomEmoji}
@ -257,6 +255,8 @@ const Reply = React.memo(
isReply isReply
id={messageId} id={messageId}
/> />
<UrlImage image={attachment.thumb_url} />
<Description attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} />
<Fields attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} /> <Fields attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} />
{loading ? ( {loading ? (
<View style={[styles.backdrop]}> <View style={[styles.backdrop]}>

View File

@ -50,7 +50,7 @@ interface IMessageContainerProps {
showAttachment: (file: IAttachment) => void; showAttachment: (file: IAttachment) => void;
onReactionLongPress?: (item: TAnyMessageModel) => void; onReactionLongPress?: (item: TAnyMessageModel) => void;
navToRoomInfo: (navParam: IRoomInfoParam) => void; navToRoomInfo: (navParam: IRoomInfoParam) => void;
handleEnterCall?: () => void; callJitsi?: () => void;
blockAction?: (params: { actionId: string; appId: string; value: string; blockId: string; rid: string; mid: string }) => void; blockAction?: (params: { actionId: string; appId: string; value: string; blockId: string; rid: string; mid: string }) => void;
onAnswerButtonPress?: (message: string, tmid?: string, tshow?: boolean) => void; onAnswerButtonPress?: (message: string, tmid?: string, tshow?: boolean) => void;
threadBadgeColor?: string; threadBadgeColor?: string;
@ -69,6 +69,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
static defaultProps = { static defaultProps = {
getCustomEmoji: () => null, getCustomEmoji: () => null,
onLongPress: () => {}, onLongPress: () => {},
callJitsi: () => {},
blockAction: () => {}, blockAction: () => {},
archived: false, archived: false,
broadcast: false, broadcast: false,
@ -337,7 +338,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
navToRoomInfo, navToRoomInfo,
getCustomEmoji, getCustomEmoji,
isThreadRoom, isThreadRoom,
handleEnterCall, callJitsi,
blockAction, blockAction,
rid, rid,
threadBadgeColor, threadBadgeColor,
@ -455,7 +456,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
showAttachment={showAttachment} showAttachment={showAttachment}
getCustomEmoji={getCustomEmoji} getCustomEmoji={getCustomEmoji}
navToRoomInfo={navToRoomInfo} navToRoomInfo={navToRoomInfo}
handleEnterCall={handleEnterCall} callJitsi={callJitsi}
blockAction={blockAction} blockAction={blockAction}
highlighted={highlighted} highlighted={highlighted}
comment={comment} comment={comment}

View File

@ -40,7 +40,7 @@ export interface IMessageBroadcast {
} }
export interface IMessageCallButton { export interface IMessageCallButton {
handleEnterCall?: () => void; callJitsi?: () => void;
} }
export interface IMessageContent { export interface IMessageContent {

View File

@ -147,7 +147,10 @@ export interface IMessage extends IMessageFromServer {
editedAt?: string | Date; editedAt?: string | Date;
} }
export type TMessageModel = IMessage & Model; export type TMessageModel = IMessage &
Model & {
asPlain: () => IMessage;
};
export type TAnyMessageModel = TMessageModel | TThreadModel | TThreadMessageModel; export type TAnyMessageModel = TMessageModel | TThreadModel | TThreadMessageModel;
export type TTypeMessages = IMessageFromServer | ILoadMoreMessage | IMessage; export type TTypeMessages = IMessageFromServer | ILoadMoreMessage | IMessage;

View File

@ -38,4 +38,7 @@ export interface IThread extends IMessage {
draftMessage?: string; draftMessage?: string;
} }
export type TThreadModel = IThread & Model; export type TThreadModel = IThread &
Model & {
asPlain: () => IMessage;
};

View File

@ -6,4 +6,7 @@ export interface IThreadMessage extends IMessage {
tmsg?: string; tmsg?: string;
} }
export type TThreadMessageModel = IThreadMessage & Model; export type TThreadMessageModel = IThreadMessage &
Model & {
asPlain: () => IMessage;
};

View File

@ -4,34 +4,37 @@ import type { IRoom } from './IRoom';
import type { IUser } from './IUser'; import type { IUser } from './IUser';
import type { IMessage } from './IMessage'; import type { IMessage } from './IMessage';
export declare enum VideoConferenceStatus { export enum VideoConferenceStatus {
CALLING = 0, CALLING = 0,
STARTED = 1, STARTED = 1,
EXPIRED = 2, EXPIRED = 2,
ENDED = 3, ENDED = 3,
DECLINED = 4 DECLINED = 4
} }
export declare type DirectCallInstructions = {
export type DirectCallInstructions = {
type: 'direct'; type: 'direct';
calleeId: IUser['_id']; callee: IUser['_id'];
callId: string; callId: string;
}; };
export declare type ConferenceInstructions = {
export type ConferenceInstructions = {
type: 'videoconference'; type: 'videoconference';
callId: string; callId: string;
rid: IRoom['_id']; rid: IRoom['_id'];
}; };
export declare type LivechatInstructions = {
export type LivechatInstructions = {
type: 'livechat'; type: 'livechat';
callId: string; callId: string;
}; };
export declare type VideoConferenceType =
| DirectCallInstructions['type'] export type VideoConferenceType = DirectCallInstructions['type'] | ConferenceInstructions['type'] | LivechatInstructions['type'];
| ConferenceInstructions['type']
| LivechatInstructions['type'];
export interface IVideoConferenceUser extends Pick<Required<IUser>, '_id' | 'username' | 'name' | 'avatarETag'> { export interface IVideoConferenceUser extends Pick<Required<IUser>, '_id' | 'username' | 'name' | 'avatarETag'> {
ts: Date; ts: Date;
} }
export interface IVideoConference extends IRocketChatRecord { export interface IVideoConference extends IRocketChatRecord {
type: VideoConferenceType; type: VideoConferenceType;
rid: string; rid: string;
@ -42,68 +45,51 @@ export interface IVideoConference extends IRocketChatRecord {
ended?: IMessage['_id']; ended?: IMessage['_id'];
}; };
url?: string; url?: string;
createdBy: Pick<Required<IUser>, '_id' | 'username' | 'name'>;
createdBy: Pick<IUser, '_id' | 'username' | 'name'>;
createdAt: Date; createdAt: Date;
endedBy?: Pick<Required<IUser>, '_id' | 'username' | 'name'>;
endedBy?: Pick<IUser, '_id' | 'username' | 'name'>;
endedAt?: Date; endedAt?: Date;
providerName: string; providerName: string;
providerData?: Record<string, any>; providerData?: Record<string, any>;
ringing?: boolean; ringing?: boolean;
} }
export interface IDirectVideoConference extends IVideoConference { export interface IDirectVideoConference extends IVideoConference {
type: 'direct'; type: 'direct';
} }
export interface IGroupVideoConference extends IVideoConference { export interface IGroupVideoConference extends IVideoConference {
type: 'videoconference'; type: 'videoconference';
anonymousUsers: number; anonymousUsers: number;
title: string; title: string;
} }
export interface ILivechatVideoConference extends IVideoConference { export interface ILivechatVideoConference extends IVideoConference {
type: 'livechat'; type: 'livechat';
} }
export declare type VideoConference = IDirectVideoConference | IGroupVideoConference | ILivechatVideoConference;
export declare type VideoConferenceInstructions = DirectCallInstructions | ConferenceInstructions | LivechatInstructions; export type VideoConference = IDirectVideoConference | IGroupVideoConference | ILivechatVideoConference;
export declare const isDirectVideoConference: (call: VideoConference | undefined | null) => call is IDirectVideoConference;
export declare const isGroupVideoConference: (call: VideoConference | undefined | null) => call is IGroupVideoConference; export type VideoConferenceInstructions = DirectCallInstructions | ConferenceInstructions | LivechatInstructions;
export declare const isLivechatVideoConference: (call: VideoConference | undefined | null) => call is ILivechatVideoConference;
declare type GroupVideoConferenceCreateData = Omit<IGroupVideoConference, 'createdBy'> & { export const isDirectVideoConference = (call: VideoConference | undefined | null): call is IDirectVideoConference =>
createdBy: IUser['_id']; call?.type === 'direct';
};
declare type DirectVideoConferenceCreateData = Omit<IDirectVideoConference, 'createdBy'> & { export const isGroupVideoConference = (call: VideoConference | undefined | null): call is IGroupVideoConference =>
createdBy: IUser['_id']; call?.type === 'videoconference';
};
declare type LivechatVideoConferenceCreateData = Omit<ILivechatVideoConference, 'createdBy'> & { export const isLivechatVideoConference = (call: VideoConference | undefined | null): call is ILivechatVideoConference =>
createdBy: IUser['_id']; call?.type === 'livechat';
};
export declare type VideoConferenceCreateData = AtLeast< type GroupVideoConferenceCreateData = Omit<IGroupVideoConference, 'createdBy'> & { createdBy: IUser['_id'] };
type DirectVideoConferenceCreateData = Omit<IDirectVideoConference, 'createdBy'> & { createdBy: IUser['_id'] };
type LivechatVideoConferenceCreateData = Omit<ILivechatVideoConference, 'createdBy'> & { createdBy: IUser['_id'] };
export type VideoConferenceCreateData = AtLeast<
DirectVideoConferenceCreateData | GroupVideoConferenceCreateData | LivechatVideoConferenceCreateData, DirectVideoConferenceCreateData | GroupVideoConferenceCreateData | LivechatVideoConferenceCreateData,
'createdBy' | 'type' | 'rid' | 'providerName' | 'providerData' 'createdBy' | 'type' | 'rid' | 'providerName' | 'providerData'
>; >;
export type VideoConferenceCapabilities = {
mic?: boolean;
cam?: boolean;
title?: boolean;
};
export type VideoConfStartProps = { roomId: string; title?: string; allowRinging?: boolean };
export type VideoConfJoinProps = {
callId: string;
state?: {
mic?: boolean;
cam?: boolean;
};
};
export type VideoConfCancelProps = {
callId: string;
};
export type VideoConfListProps = {
roomId: string;
count?: number;
offset?: number;
};
export type VideoConfInfoProps = { callId: string };

View File

@ -1,3 +1,3 @@
export const STATUSES = ['offline', 'online', 'away', 'busy', 'disabled'] as const; export const STATUSES = ['offline', 'online', 'away', 'busy'] as const;
export type TUserStatus = typeof STATUSES[number]; export type TUserStatus = typeof STATUSES[number];

View File

@ -1,45 +1,27 @@
import { import { VideoConference } from '../../IVideoConference';
VideoConfCancelProps,
VideoConference,
VideoConferenceCapabilities,
VideoConferenceInstructions,
VideoConfInfoProps,
VideoConfJoinProps,
VideoConfListProps,
VideoConfStartProps
} from '../../IVideoConference';
import { PaginatedResult } from '../helpers/PaginatedResult';
export type VideoConferenceEndpoints = { export type VideoConferenceEndpoints = {
'video-conference.start': {
POST: (params: VideoConfStartProps) => { data: VideoConferenceInstructions & { providerName: string } };
};
'video-conference.join': {
POST: (params: VideoConfJoinProps) => { url: string; providerName: string };
};
'video-conference.cancel': {
POST: (params: VideoConfCancelProps) => void;
};
'video-conference.info': {
GET: (params: VideoConfInfoProps) => VideoConference & { capabilities: VideoConferenceCapabilities };
};
'video-conference.list': {
GET: (params: VideoConfListProps) => PaginatedResult<{ data: VideoConference[] }>;
};
'video-conference.capabilities': {
GET: () => { providerName: string; capabilities: VideoConferenceCapabilities };
};
'video-conference.providers': {
GET: () => { data: { key: string; label: string }[] };
};
'video-conference/jitsi.update-timeout': { 'video-conference/jitsi.update-timeout': {
POST: (params: { roomId: string }) => void; POST: (params: { roomId: string }) => void;
}; };
'video-conference.join': {
POST: (params: { callId: string; state: { cam: boolean } }) => { url: string; providerName: string };
};
'video-conference.start': {
POST: (params: { roomId: string }) => { url: string };
};
'video-conference.cancel': {
POST: (params: { callId: string }) => void;
};
'video-conference.info': {
GET: (params: { callId: string }) => VideoConference & {
capabilities: {
mic?: boolean;
cam?: boolean;
title?: boolean;
};
};
};
}; };

View File

@ -12,6 +12,3 @@ declare module 'react-native-restart';
declare module 'react-native-jitsi-meet'; declare module 'react-native-jitsi-meet';
declare module 'rn-root-view'; declare module 'rn-root-view';
declare module 'react-native-math-view'; declare module 'react-native-math-view';
declare module '@env' {
export const RUNNING_E2E_TESTS: string;
}

View File

@ -876,20 +876,5 @@
"Call": "Call", "Call": "Call",
"Reply_in_direct_message": "Reply in Direct Message", "Reply_in_direct_message": "Reply in Direct Message",
"room_archived": "archived room", "room_archived": "archived room",
"room_unarchived": "unarchived room", "room_unarchived": "unarchived room"
"no-videoconf-provider-app-header": "Conference call not available",
"no-videoconf-provider-app-body": "Conference call apps can be installed in the Rocket.Chat marketplace by a workspace admin.",
"admin-no-videoconf-provider-app-header": "Conference call not enabled",
"admin-no-videoconf-provider-app-body": "Conference call apps are available in the Rocket.Chat marketplace.",
"no-active-video-conf-provider-header": "Conference call not enabled",
"no-active-video-conf-provider-body": "A workspace admin needs to enable the conference call feature first.",
"admin-no-active-video-conf-provider-header": "Conference call not enabled",
"admin-no-active-video-conf-provider-body": "Configure conference calls in order to make it available on this workspace.",
"video-conf-provider-not-configured-header": "Conference call not enabled",
"video-conf-provider-not-configured-body": "A workspace admin needs to enable the conference calls feature first.",
"admin-video-conf-provider-not-configured-header": "Conference call not enabled",
"admin-video-conf-provider-not-configured-body": "Configure conference calls in order to make it available on this workspace.",
"Presence_Cap_Warning_Title": "User status temporarily disabled",
"Presence_Cap_Warning_Description": "Active connections have reached the limit for the workspace, thus the service that handles user status is disabled. It can be re-enabled manually in workspace settings.",
"Learn_more": "Learn more"
} }

View File

@ -875,7 +875,5 @@
"Call": "Ligar", "Call": "Ligar",
"Reply_in_direct_message": "Responder por mensagem direta", "Reply_in_direct_message": "Responder por mensagem direta",
"room_archived": "{{username}} arquivou a sala", "room_archived": "{{username}} arquivou a sala",
"room_unarchived": "{{username}} desarquivou a sala", "room_unarchived": "{{username}} desarquivou a sala"
"Presence_Cap_Warning_Title": "Status do usuário desabilitado temporariamente",
"Presence_Cap_Warning_Description": "O limite de conexões ativas para a workspace foi atingido, por isso o serviço responsável pela presença dos usuários está temporariamente desabilitado. Ele pode ser reabilitado manualmente nas configurações da workspace."
} }

View File

@ -3,8 +3,7 @@ export const STATUS_COLORS: any = {
busy: '#f5455c', busy: '#f5455c',
away: '#ffd21f', away: '#ffd21f',
offline: '#cbced1', offline: '#cbced1',
loading: '#9ea2a8', loading: '#9ea2a8'
disabled: '#F38C39'
}; };
export const SWITCH_TRACK_COLOR = { export const SWITCH_TRACK_COLOR = {

View File

@ -1,4 +1,3 @@
// 🚨🚨 48 settings after login. Pay attention not to reach 50 as that's the limit per request.
export const defaultSettings = { export const defaultSettings = {
Accounts_AllowEmailChange: { Accounts_AllowEmailChange: {
type: 'valueAsBoolean' type: 'valueAsBoolean'
@ -230,8 +229,5 @@ export const defaultSettings = {
}, },
Number_of_users_autocomplete_suggestions: { Number_of_users_autocomplete_suggestions: {
type: 'valueAsNumber' type: 'valueAsNumber'
},
Presence_broadcast_disabled: {
type: 'valueAsBoolean'
} }
} as const; } as const;

View File

@ -8,6 +8,5 @@ export * from './localAuthentication';
export * from './localPath'; export * from './localPath';
export * from './messagesStatus'; export * from './messagesStatus';
export * from './messageTypeLoad'; export * from './messageTypeLoad';
export * from './notifications';
export * from './defaultSettings'; export * from './defaultSettings';
export * from './tablet'; export * from './tablet';

View File

@ -1 +0,0 @@
export const NOTIFICATION_PRESENCE_CAP = 'NOTIFICATION_PRESENCE_CAP';

View File

@ -85,4 +85,47 @@ export default class Message extends Model {
@json('md', sanitizer) md; @json('md', sanitizer) md;
@field('comment') comment; @field('comment') comment;
asPlain() {
return {
id: this.id,
rid: this.subscription.id,
msg: this.msg,
t: this.t,
ts: this.ts,
u: this.u,
alias: this.alias,
parseUrls: this.parseUrls,
groupable: this.groupable,
avatar: this.avatar,
emoji: this.emoji,
attachments: this.attachments,
urls: this.urls,
_updatedAt: this._updatedAt,
status: this.status,
pinned: this.pinned,
starred: this.starred,
editedBy: this.editedBy,
reactions: this.reactions,
role: this.role,
drid: this.drid,
dcount: this.dcount,
dlm: this.dlm,
tmid: this.tmid,
tcount: this.tcount,
tlm: this.tlm,
replies: this.replies,
mentions: this.mentions,
channels: this.channels,
unread: this.unread,
autoTranslate: this.autoTranslate,
translations: this.translations,
tmsg: this.tmsg,
blocks: this.blocks,
e2e: this.e2e,
tshow: this.tshow,
md: this.md,
comment: this.comment
};
}
} }

View File

@ -77,4 +77,42 @@ export default class Thread extends Model {
@field('e2e') e2e; @field('e2e') e2e;
@field('draft_message') draftMessage; @field('draft_message') draftMessage;
asPlain() {
return {
id: this.id,
msg: this.msg,
t: this.t,
ts: this.ts,
u: this.u,
alias: this.alias,
parseUrls: this.parseUrls,
groupable: this.groupable,
avatar: this.avatar,
emoji: this.emoji,
attachments: this.attachments,
urls: this.urls,
_updatedAt: this._updatedAt,
status: this.status,
pinned: this.pinned,
starred: this.starred,
editedBy: this.editedBy,
reactions: this.reactions,
role: this.role,
drid: this.drid,
dcount: this.dcount,
dlm: this.dlm,
tmid: this.tmid,
tcount: this.tcount,
tlm: this.tlm,
replies: this.replies,
mentions: this.mentions,
channels: this.channels,
unread: this.unread,
autoTranslate: this.autoTranslate,
translations: this.translations,
e2e: this.e2e,
draftMessage: this.draftMessage
};
}
} }

View File

@ -77,4 +77,42 @@ export default class ThreadMessage extends Model {
@field('draft_message') draftMessage; @field('draft_message') draftMessage;
@field('e2e') e2e; @field('e2e') e2e;
asPlain() {
return {
id: this.id,
msg: this.msg,
t: this.t,
ts: this.ts,
u: this.u,
rid: this.rid,
alias: this.alias,
parseUrls: this.parseUrls,
groupable: this.groupable,
avatar: this.avatar,
emoji: this.emoji,
attachments: this.attachments,
urls: this.urls,
_updatedAt: this._updatedAt,
status: this.status,
pinned: this.pinned,
starred: this.starred,
editedBy: this.editedBy,
reactions: this.reactions,
role: this.role,
drid: this.drid,
dcount: this.dcount,
dlm: this.dlm,
tcount: this.tcount,
tlm: this.tlm,
replies: this.replies,
mentions: this.mentions,
channels: this.channels,
unread: this.unread,
autoTranslate: this.autoTranslate,
translations: this.translations,
draftMessage: this.draftMessage,
e2e: this.e2e
};
}
} }

View File

@ -13,7 +13,7 @@ export const getMessageById = async (messageId: string | null) => {
try { try {
const result = await messageCollection.find(messageId); const result = await messageCollection.find(messageId);
return result; return result;
} catch (error) { } catch {
return null; return null;
} }
}; };

View File

@ -0,0 +1,25 @@
import { store } from '../../store/auxStore';
import { IAttachment, IMessage } from '../../../definitions';
import { getAvatarURL } from '../../methods/helpers';
export function createQuoteAttachment(message: IMessage, messageLink: string): IAttachment {
const { server, version: serverVersion } = store.getState().server;
const externalProviderUrl = (store.getState().settings?.Accounts_AvatarExternalProviderUrl as string) || '';
return {
text: message.msg,
...('translations' in message && { translations: message?.translations }),
message_link: messageLink,
author_name: message.alias || message.u.username,
author_icon: getAvatarURL({
avatar: message.u?.username && `/avatar/${message.u?.username}`,
type: message.t,
userId: message.u?._id,
server,
serverVersion,
externalProviderUrl
}),
attachments: message.attachments || [],
ts: message.ts
};
}

View File

@ -0,0 +1,12 @@
import { getMessageUrlRegex } from './getMessageUrlRegex';
describe('Should regex', () => {
test('a common quote separated by space', () => {
const quote = '[ ](https://open.rocket.chat/group/room?msg=rid) test';
expect(quote.match(getMessageUrlRegex())).toStrictEqual(['https://open.rocket.chat/group/room?msg=rid']);
});
test('a quote separated by break line', () => {
const quote = '[ ](https://open.rocket.chat/group/room?msg=rid)\ntest';
expect(quote.match(getMessageUrlRegex())).toStrictEqual(['https://open.rocket.chat/group/room?msg=rid']);
});
});

View File

@ -0,0 +1,3 @@
// https://github.com/RocketChat/Rocket.Chat/blob/0226236b871d12c62338111c70b65d5d406447a3/apps/meteor/lib/getMessageUrlRegex.ts#L1-L2
export const getMessageUrlRegex = (): RegExp =>
/([A-Za-z]{3,9}):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+=!:~%\/\.@\,\w]*)?\??([-\+=&!:;%@\/\.\,\w]+)?(?:#([^\s\)]+))?)?/g;

View File

@ -0,0 +1,14 @@
import { IMessage } from '../../../definitions';
export const mapMessageFromAPI = ({ attachments, tlm, ts, _updatedAt, ...message }: IMessage) => ({
...message,
ts: new Date(ts),
...(tlm && { tlm: new Date(tlm) }),
_updatedAt: new Date(_updatedAt),
...(attachments && {
attachments: attachments.map(({ ts, ...attachment }) => ({
...(ts && { ts: new Date(ts) }),
...(attachment as any)
}))
})
});

View File

@ -0,0 +1,17 @@
import { TMessageModel } from '../../../definitions';
export const mapMessageFromDB = (messageModel: TMessageModel) => {
const parsedMessage = messageModel.asPlain();
return {
...parsedMessage,
ts: new Date(parsedMessage.ts),
...(parsedMessage.tlm && { tlm: new Date(parsedMessage.tlm) }),
_updatedAt: new Date(parsedMessage._updatedAt),
...(parsedMessage.attachments && {
attachments: parsedMessage.attachments.map(({ ts, ...attachment }) => ({
...(ts && { ts: new Date(ts) }),
...(attachment as any)
}))
})
};
};

View File

@ -2,7 +2,9 @@ import EJSON from 'ejson';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import SimpleCrypto from 'react-native-simple-crypto'; import SimpleCrypto from 'react-native-simple-crypto';
import ByteBuffer from 'bytebuffer'; import ByteBuffer from 'bytebuffer';
import parse from 'url-parse';
import getSingleMessage from '../methods/getSingleMessage';
import { IMessage, IUser } from '../../definitions'; import { IMessage, IUser } from '../../definitions';
import Deferred from './helpers/deferred'; import Deferred from './helpers/deferred';
import { debounce } from '../methods/helpers'; import { debounce } from '../methods/helpers';
@ -21,6 +23,11 @@ import {
import { Encryption } from './index'; import { Encryption } from './index';
import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../constants'; import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../constants';
import { Services } from '../services'; import { Services } from '../services';
import { getMessageUrlRegex } from './helpers/getMessageUrlRegex';
import { mapMessageFromAPI } from './helpers/mapMessageFromApi';
import { mapMessageFromDB } from './helpers/mapMessageFromDB';
import { createQuoteAttachment } from './helpers/createQuoteAttachment';
import { getMessageById } from '../database/services/Message';
export default class EncryptionRoom { export default class EncryptionRoom {
ready: boolean; ready: boolean;
@ -268,12 +275,15 @@ export default class EncryptionRoom {
tmsg = await this.decryptText(tmsg); tmsg = await this.decryptText(tmsg);
} }
return { const decryptedMessage: IMessage = {
...message, ...message,
tmsg, tmsg,
msg, msg,
e2e: E2E_STATUS.DONE e2e: 'done'
}; };
const decryptedMessageWithQuote = await this.decryptQuoteAttachment(decryptedMessage);
return decryptedMessageWithQuote;
} }
} catch { } catch {
// Do nothing // Do nothing
@ -281,4 +291,37 @@ export default class EncryptionRoom {
return message; return message;
}; };
async decryptQuoteAttachment(message: IMessage) {
const urls = message?.msg?.match(getMessageUrlRegex()) || [];
await Promise.all(
urls.map(async (url: string) => {
const parsedUrl = parse(url, true);
const messageId = parsedUrl.query?.msg;
if (!messageId) {
return;
}
// From local db
const messageFromDB = await getMessageById(messageId);
if (messageFromDB && messageFromDB.e2e === 'done') {
const decryptedQuoteMessage = mapMessageFromDB(messageFromDB);
message.attachments = message.attachments || [];
const quoteAttachment = createQuoteAttachment(decryptedQuoteMessage, url);
return message.attachments.push(quoteAttachment);
}
// From API
const quotedMessageObject = await getSingleMessage(messageId);
if (!quotedMessageObject) {
return;
}
const decryptedQuoteMessage = await this.decrypt(mapMessageFromAPI(quotedMessageObject));
message.attachments = message.attachments || [];
const quoteAttachment = createQuoteAttachment(decryptedQuoteMessage, url);
return message.attachments.push(quoteAttachment);
})
);
return message;
}
} }

View File

@ -0,0 +1,27 @@
import { useCallback } from 'react';
import { TActionSheetOptionsItem, useActionSheet } from '../../containers/ActionSheet';
import i18n from '../../i18n';
import { videoConfJoin } from '../methods/videoConf';
export const useVideoConf = (): { joinCall: (blockId: string) => void } => {
const { showActionSheet } = useActionSheet();
const joinCall = useCallback(blockId => {
const options: TActionSheetOptionsItem[] = [
{
title: i18n.t('Video_call'),
icon: 'camera',
onPress: () => videoConfJoin(blockId, true)
},
{
title: i18n.t('Voice_call'),
icon: 'microphone',
onPress: () => videoConfJoin(blockId, false)
}
];
showActionSheet({ options });
}, []);
return { joinCall };
};

View File

@ -1,113 +0,0 @@
import React, { useEffect, useState } from 'react';
import { Q } from '@nozbe/watermelondb';
import { useActionSheet } from '../../containers/ActionSheet';
import StartACallActionSheet from '../../containers/UIKit/VideoConferenceBlock/components/StartACallActionSheet';
import { ISubscription, SubscriptionType, TSubscriptionModel } from '../../definitions';
import i18n from '../../i18n';
import { getUserSelector } from '../../selectors/login';
import database from '../database';
import { getSubscriptionByRoomId } from '../database/services/Subscription';
import { callJitsi } from '../methods';
import { compareServerVersion, showErrorAlert } from '../methods/helpers';
import { videoConfStartAndJoin } from '../methods/videoConf';
import { Services } from '../services';
import { useAppSelector } from './useAppSelector';
import { useSnaps } from './useSnaps';
const availabilityErrors = {
NOT_CONFIGURED: 'video-conf-provider-not-configured',
NOT_ACTIVE: 'no-active-video-conf-provider',
NO_APP: 'no-videoconf-provider-app'
} as const;
const handleErrors = (isAdmin: boolean, error: typeof availabilityErrors[keyof typeof availabilityErrors]) => {
if (isAdmin) return showErrorAlert(i18n.t(`admin-${error}-body`), i18n.t(`admin-${error}-header`));
return showErrorAlert(i18n.t(`${error}-body`), i18n.t(`${error}-header`));
};
export const useVideoConf = (rid: string): { showInitCallActionSheet: () => Promise<void>; showCallOption: boolean } => {
const [showCallOption, setShowCallOption] = useState(false);
const serverVersion = useAppSelector(state => state.server.version);
const jitsiEnabled = useAppSelector(state => state.settings.Jitsi_Enabled);
const jitsiEnableTeams = useAppSelector(state => state.settings.Jitsi_Enable_Teams);
const jitsiEnableChannels = useAppSelector(state => state.settings.Jitsi_Enable_Channels);
const user = useAppSelector(state => getUserSelector(state));
const isServer5OrNewer = compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.0.0');
const { showActionSheet } = useActionSheet();
const snaps = useSnaps([1250]);
const handleShowCallOption = (room: TSubscriptionModel) => {
if (isServer5OrNewer) return setShowCallOption(true);
const isJitsiDisabledForTeams = room.teamMain && !jitsiEnableTeams;
const isJitsiDisabledForChannels = !room.teamMain && (room.t === 'p' || room.t === 'c') && !jitsiEnableChannels;
if (room.t === SubscriptionType.DIRECT) return setShowCallOption(!!jitsiEnabled);
if (room.t === SubscriptionType.CHANNEL) return setShowCallOption(!isJitsiDisabledForChannels);
if (room.t === SubscriptionType.GROUP) return setShowCallOption(!isJitsiDisabledForTeams);
return setShowCallOption(false);
};
const canInitAnCall = async () => {
if (isServer5OrNewer) {
try {
await Services.videoConferenceGetCapabilities();
return true;
} catch (error: any) {
const isAdmin = !!['admin'].find(role => user.roles?.includes(role));
switch (error?.error) {
case availabilityErrors.NOT_CONFIGURED:
return handleErrors(isAdmin, availabilityErrors.NOT_CONFIGURED);
case availabilityErrors.NOT_ACTIVE:
return handleErrors(isAdmin, availabilityErrors.NOT_ACTIVE);
case availabilityErrors.NO_APP:
return handleErrors(isAdmin, availabilityErrors.NO_APP);
default:
return handleErrors(isAdmin, availabilityErrors.NOT_CONFIGURED);
}
}
}
return true;
};
const initCall = async ({ cam, mic }: { cam: boolean; mic: boolean }) => {
if (isServer5OrNewer) return videoConfStartAndJoin({ rid, cam, mic });
const room = (await getSubscriptionByRoomId(rid)) as ISubscription;
callJitsi({ room, cam });
};
const showInitCallActionSheet = async () => {
const canInit = await canInitAnCall();
if (canInit) {
showActionSheet({
children: <StartACallActionSheet rid={rid} initCall={initCall} />,
snaps
});
}
};
const initSubscription = () => {
try {
const db = database.active;
const observeSubCollection = db.get('subscriptions').query(Q.where('rid', rid)).observe();
const subObserveQuery = observeSubCollection.subscribe(data => {
if (data[0]) {
handleShowCallOption(data[0]);
subObserveQuery.unsubscribe();
}
});
} catch (e) {
console.log("observeSubscriptions: Can't find subscription to observe");
}
};
useEffect(() => {
initSubscription();
}, []);
return { showInitCallActionSheet, showCallOption };
};

View File

@ -52,7 +52,7 @@ export const deleteAllAudioFiles = async (serverUrl: string): Promise<void> => {
try { try {
const serverUrlParsed = sanitizeString(serverUrl); const serverUrlParsed = sanitizeString(serverUrl);
const path = `${FileSystem.documentDirectory}audios/${serverUrlParsed}`; const path = `${FileSystem.documentDirectory}audios/${serverUrlParsed}`;
await FileSystem.deleteAsync(path, { idempotent: true }); await FileSystem.deleteAsync(path);
} catch (error) { } catch (error) {
log(error); log(error);
} }

View File

@ -46,8 +46,8 @@ export function callJitsiWithoutServer(path: string): void {
Navigation.navigate('JitsiMeetView', { url, onlyAudio: false }); Navigation.navigate('JitsiMeetView', { url, onlyAudio: false });
} }
export async function callJitsi({ room, cam = false }: { room: ISubscription; cam?: boolean }): Promise<void> { export async function callJitsi(room: ISubscription, onlyAudio = false): Promise<void> {
logEvent(cam ? events.RA_JITSI_AUDIO : events.RA_JITSI_VIDEO); logEvent(onlyAudio ? events.RA_JITSI_AUDIO : events.RA_JITSI_VIDEO);
const url = await jitsiURL({ room }); const url = await jitsiURL({ room });
Navigation.navigate('JitsiMeetView', { url, onlyAudio: cam, rid: room?.rid }); Navigation.navigate('JitsiMeetView', { url, onlyAudio, rid: room?.rid });
} }

View File

@ -11,7 +11,6 @@ import database from '../database';
import sdk from '../services/sdk'; import sdk from '../services/sdk';
import protectedFunction from './helpers/protectedFunction'; import protectedFunction from './helpers/protectedFunction';
import { parseSettings, _prepareSettings } from './parseSettings'; import { parseSettings, _prepareSettings } from './parseSettings';
import { setPresenceCap } from './getUsersPresence';
const serverInfoKeys = [ const serverInfoKeys = [
'Site_Name', 'Site_Name',
@ -158,11 +157,8 @@ export async function getSettings(): Promise<void> {
const data: IData[] = result.settings || []; const data: IData[] = result.settings || [];
const filteredSettings: IPreparedSettings[] = _prepareSettings(data); const filteredSettings: IPreparedSettings[] = _prepareSettings(data);
const filteredSettingsIds = filteredSettings.map(s => s._id); const filteredSettingsIds = filteredSettings.map(s => s._id);
const parsedSettings = parseSettings(filteredSettings);
reduxStore.dispatch(addSettings(parsedSettings)); reduxStore.dispatch(addSettings(parseSettings(filteredSettings)));
setPresenceCap(parsedSettings.Presence_broadcast_disabled);
// filter server info // filter server info
const serverInfo = filteredSettings.filter(i1 => serverInfoKeys.includes(i1._id)); const serverInfo = filteredSettings.filter(i1 => serverInfoKeys.includes(i1._id));

View File

@ -9,9 +9,6 @@ import database from '../database';
import { IUser } from '../../definitions'; import { IUser } from '../../definitions';
import sdk from '../services/sdk'; import sdk from '../services/sdk';
import { compareServerVersion } from './helpers'; import { compareServerVersion } from './helpers';
import userPreferences from './userPreferences';
import { NOTIFICATION_PRESENCE_CAP } from '../constants';
import { setNotificationPresenceCap } from '../../actions/app';
export const _activeUsersSubTimeout: { activeUsersSubTimeout: boolean | ReturnType<typeof setTimeout> | number } = { export const _activeUsersSubTimeout: { activeUsersSubTimeout: boolean | ReturnType<typeof setTimeout> | number } = {
activeUsersSubTimeout: false activeUsersSubTimeout: false
@ -127,16 +124,3 @@ export function getUserPresence(uid: string) {
usersBatch.push(uid); usersBatch.push(uid);
} }
} }
export const setPresenceCap = async (enabled: boolean) => {
if (enabled) {
const notificationPresenceCap = await userPreferences.getBool(NOTIFICATION_PRESENCE_CAP);
if (notificationPresenceCap !== false) {
userPreferences.setBool(NOTIFICATION_PRESENCE_CAP, true);
reduxStore.dispatch(setNotificationPresenceCap(true));
}
} else {
userPreferences.removeItem(NOTIFICATION_PRESENCE_CAP);
reduxStore.dispatch(setNotificationPresenceCap(false));
}
};

View File

@ -1,7 +1,5 @@
import { Alert, Linking } from 'react-native'; import { Alert, Linking } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
// eslint-disable-next-line import/no-unresolved
import { RUNNING_E2E_TESTS } from '@env';
import I18n from '../../../i18n'; import I18n from '../../../i18n';
import { isFDroidBuild, STORE_REVIEW_LINK } from '../../constants'; import { isFDroidBuild, STORE_REVIEW_LINK } from '../../constants';
@ -88,15 +86,14 @@ class ReviewApp {
positiveEventCount = 0; positiveEventCount = 0;
pushPositiveEvent = () => { pushPositiveEvent = () => {
if (isFDroidBuild || RUNNING_E2E_TESTS === 'true') { if (!isFDroidBuild) {
return; if (this.positiveEventCount >= numberOfPositiveEvent) {
} return;
if (this.positiveEventCount >= numberOfPositiveEvent) { }
return; this.positiveEventCount += 1;
} if (this.positiveEventCount === numberOfPositiveEvent) {
this.positiveEventCount += 1; tryReview();
if (this.positiveEventCount === numberOfPositiveEvent) { }
tryReview();
} }
}; };
} }

View File

@ -38,8 +38,7 @@ export const localSearchSubscription = async ({ text = '', filterUsers = true, f
t: item.t, t: item.t,
encrypted: item.encrypted, encrypted: item.encrypted,
lastMessage: item.lastMessage, lastMessage: item.lastMessage,
status: item.status, status: item.status
teamMain: item.teamMain
})) as ISearchLocal[]; })) as ISearchLocal[];
return search; return search;

View File

@ -138,23 +138,6 @@ export default class RoomSubscription {
reduxStore.dispatch(removeUserTyping(name)); reduxStore.dispatch(removeUserTyping(name));
} }
} }
} else if (ev === 'user-activity') {
const { user } = reduxStore.getState().login;
const { UI_Use_Real_Name } = reduxStore.getState().settings;
const { subscribedRoom } = reduxStore.getState().room;
if (subscribedRoom !== _rid) {
return;
}
const [name, activities] = ddpMessage.fields.args;
const key = UI_Use_Real_Name ? 'name' : 'username';
if (name !== user[key]) {
if (activities.includes('user-typing')) {
reduxStore.dispatch(addUserTyping(name));
}
if (!activities.length) {
reduxStore.dispatch(removeUserTyping(name));
}
}
} else if (ev === 'deleteMessage') { } else if (ev === 'deleteMessage') {
InteractionManager.runAfterInteractions(async () => { InteractionManager.runAfterInteractions(async () => {
if (ddpMessage && ddpMessage.fields && ddpMessage.fields.args.length > 0) { if (ddpMessage && ddpMessage.fields && ddpMessage.fields.args.length > 0) {

View File

@ -16,43 +16,42 @@ class UserPreferences {
getString(key: string): string | null { getString(key: string): string | null {
try { try {
return this.mmkv.getString(key) ?? null; return this.mmkv.getString(key) || null;
} catch { } catch {
return null; return null;
} }
} }
setString(key: string, value: string): boolean | undefined { setString(key: string, value: string): boolean | undefined {
return this.mmkv.setString(key, value) ?? undefined; return this.mmkv.setString(key, value) || undefined;
} }
getBool(key: string): boolean | null { getBool(key: string): boolean | null {
try { try {
console.log(this.mmkv.getBool(key)); return this.mmkv.getBool(key) || null;
return this.mmkv.getBool(key) ?? null;
} catch { } catch {
return null; return null;
} }
} }
setBool(key: string, value: boolean): boolean | undefined { setBool(key: string, value: boolean): boolean | undefined {
return this.mmkv.setBool(key, value) ?? undefined; return this.mmkv.setBool(key, value) || undefined;
} }
getMap(key: string): object | null { getMap(key: string): object | null {
try { try {
return this.mmkv.getMap(key) ?? null; return this.mmkv.getMap(key) || null;
} catch { } catch {
return null; return null;
} }
} }
setMap(key: string, value: object): boolean | undefined { setMap(key: string, value: object): boolean | undefined {
return this.mmkv.setMap(key, value) ?? undefined; return this.mmkv.setMap(key, value) || undefined;
} }
removeItem(key: string): boolean | undefined { removeItem(key: string): boolean | undefined {
return this.mmkv.removeItem(key) ?? undefined; return this.mmkv.removeItem(key) || undefined;
} }
} }

View File

@ -19,9 +19,9 @@ const handleBltPermission = async (): Promise<Permission[]> => {
return [PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION]; return [PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION];
}; };
export const videoConfJoin = async (callId: string, cam?: boolean, mic?: boolean): Promise<void> => { export const videoConfJoin = async (callId: string, cam: boolean) => {
try { try {
const result = await Services.videoConferenceJoin(callId, cam, mic); const result = await Services.videoConferenceJoin(callId, cam);
if (result.success) { if (result.success) {
if (isAndroid) { if (isAndroid) {
const bltPermission = await handleBltPermission(); const bltPermission = await handleBltPermission();
@ -44,11 +44,11 @@ export const videoConfJoin = async (callId: string, cam?: boolean, mic?: boolean
} }
}; };
export const videoConfStartAndJoin = async ({ rid, cam, mic }: { rid: string; cam?: boolean; mic?: boolean }): Promise<void> => { export const videoConfStartAndJoin = async (rid: string, cam: boolean) => {
try { try {
const videoConfResponse = await Services.videoConferenceStart(rid); const videoConfResponse: any = await Services.videoConferenceStart(rid);
if (videoConfResponse.success) { if (videoConfResponse.success) {
videoConfJoin(videoConfResponse.data.callId, cam, mic); videoConfJoin(videoConfResponse.data.callId, cam);
} }
} catch (e) { } catch (e) {
showErrorAlert(i18n.t('error-init-video-conf')); showErrorAlert(i18n.t('error-init-video-conf'));

View File

@ -1,27 +0,0 @@
import BackgroundTimer from 'react-native-background-timer';
import { Services } from '../services';
let interval: number | null = null;
export const initVideoConfTimer = (rid: string): void => {
if (rid) {
Services.updateJitsiTimeout(rid).catch((e: unknown) => console.log(e));
if (interval) {
BackgroundTimer.clearInterval(interval);
BackgroundTimer.stopBackgroundTimer();
interval = null;
}
interval = BackgroundTimer.setInterval(() => {
Services.updateJitsiTimeout(rid).catch((e: unknown) => console.log(e));
}, 10000);
}
};
export const endVideoConfTimer = (): void => {
if (interval) {
BackgroundTimer.clearInterval(interval);
interval = null;
BackgroundTimer.stopBackgroundTimer();
}
};

View File

@ -20,16 +20,7 @@ import { updatePermission } from '../../actions/permissions';
import EventEmitter from '../methods/helpers/events'; import EventEmitter from '../methods/helpers/events';
import { updateSettings } from '../../actions/settings'; import { updateSettings } from '../../actions/settings';
import { defaultSettings, MIN_ROCKETCHAT_VERSION } from '../constants'; import { defaultSettings, MIN_ROCKETCHAT_VERSION } from '../constants';
import { import { getSettings, IActiveUsers, unsubscribeRooms, _activeUsers, _setUser, _setUserTimer, onRolesChanged } from '../methods';
getSettings,
IActiveUsers,
unsubscribeRooms,
_activeUsers,
_setUser,
_setUserTimer,
onRolesChanged,
setPresenceCap
} from '../methods';
import { compareServerVersion, isIOS, isSsl } from '../methods/helpers'; import { compareServerVersion, isIOS, isSsl } from '../methods/helpers';
interface IServices { interface IServices {
@ -153,10 +144,6 @@ function connect({ server, logoutOnError = false }: { server: string; logoutOnEr
}); });
} }
store.dispatch(updateSettings(_id, value)); store.dispatch(updateSettings(_id, value));
if (_id === 'Presence_broadcast_disabled') {
setPresenceCap(value);
}
} catch (e) { } catch (e) {
log(e); log(e);
} }

View File

@ -812,14 +812,10 @@ export const addUsersToRoom = (rid: string): Promise<boolean> => {
}; };
export const emitTyping = (room: IRoom, typing = true) => { export const emitTyping = (room: IRoom, typing = true) => {
const { login, settings, server } = reduxStore.getState(); const { login, settings } = reduxStore.getState();
const { UI_Use_Real_Name } = settings; const { UI_Use_Real_Name } = settings;
const { version: serverVersion } = server;
const { user } = login; const { user } = login;
const name = UI_Use_Real_Name ? user.name : user.username; const name = UI_Use_Real_Name ? user.name : user.username;
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '4.0.0')) {
return sdk.methodCall('stream-notify-room', `${room}/user-activity`, name, typing ? ['user-typing'] : []);
}
return sdk.methodCall('stream-notify-room', `${room}/typing`, name, typing); return sdk.methodCall('stream-notify-room', `${room}/typing`, name, typing);
}; };
@ -936,10 +932,8 @@ export function getUserInfo(userId: string) {
export const toggleFavorite = (roomId: string, favorite: boolean) => sdk.post('rooms.favorite', { roomId, favorite }); export const toggleFavorite = (roomId: string, favorite: boolean) => sdk.post('rooms.favorite', { roomId, favorite });
export const videoConferenceJoin = (callId: string, cam?: boolean, mic?: boolean) => export const videoConferenceJoin = (callId: string, cam: boolean) =>
sdk.post('video-conference.join', { callId, state: { cam: !!cam, mic: mic === undefined ? true : mic } }); sdk.post('video-conference.join', { callId, state: { cam } });
export const videoConferenceGetCapabilities = () => sdk.get('video-conference.capabilities');
export const videoConferenceStart = (roomId: string) => sdk.post('video-conference.start', { roomId }); export const videoConferenceStart = (roomId: string) => sdk.post('video-conference.start', { roomId });

View File

@ -6,7 +6,7 @@ import { twoFactor } from './twoFactor';
import { isSsl } from '../methods/helpers/url'; import { isSsl } from '../methods/helpers/url';
import { store as reduxStore } from '../store/auxStore'; import { store as reduxStore } from '../store/auxStore';
import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../definitions/rest/helpers'; import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../definitions/rest/helpers';
import { compareServerVersion, random } from '../methods/helpers'; import { random } from '../methods/helpers';
class Sdk { class Sdk {
private sdk: typeof Rocketchat; private sdk: typeof Rocketchat;
@ -162,22 +162,7 @@ class Sdk {
} }
subscribeRoom(...args: any[]) { subscribeRoom(...args: any[]) {
const { server } = reduxStore.getState(); return this.current.subscribeRoom(...args);
const { version: serverVersion } = server;
const topic = 'stream-notify-room';
let eventUserTyping;
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '4.0.0')) {
eventUserTyping = this.subscribe(topic, `${args[0]}/user-activity`, ...args);
} else {
eventUserTyping = this.subscribe(topic, `${args[0]}/typing`, ...args);
}
// Taken from https://github.com/RocketChat/Rocket.Chat.js.SDK/blob/454b4ba784095057b8de862eb99340311b672e15/lib/drivers/ddp.ts#L555
return Promise.all([
this.subscribe('stream-room-messages', args[0], ...args),
eventUserTyping,
this.subscribe(topic, `${args[0]}/deleteMessage`, ...args)
]);
} }
unsubscribe(subscription: any[]) { unsubscribe(subscription: any[]) {

View File

@ -1,4 +1,4 @@
import { appStart, appInit, setMasterDetail, setNotificationPresenceCap, appReady } from '../actions/app'; import { appStart, appInit, setMasterDetail } from '../actions/app';
import { initialState } from './app'; import { initialState } from './app';
import { mockedStore } from './mockedStore'; import { mockedStore } from './mockedStore';
import { RootEnum } from '../definitions'; import { RootEnum } from '../definitions';
@ -20,9 +20,6 @@ describe('test reducer', () => {
mockedStore.dispatch(appInit()); mockedStore.dispatch(appInit());
const { ready } = mockedStore.getState().app; const { ready } = mockedStore.getState().app;
expect(ready).toEqual(false); expect(ready).toEqual(false);
mockedStore.dispatch(appReady());
const { ready: ready2 } = mockedStore.getState().app;
expect(ready2).toEqual(true);
}); });
it('should return ready state after dispatch setMasterDetail action', () => { it('should return ready state after dispatch setMasterDetail action', () => {
@ -44,13 +41,4 @@ describe('test reducer', () => {
expect(foreground).toEqual(false); expect(foreground).toEqual(false);
expect(background).toEqual(true); expect(background).toEqual(true);
}); });
it('should return correct state after dispatch setNotificationPresenceCap action', () => {
mockedStore.dispatch(setNotificationPresenceCap(true));
const { notificationPresenceCap } = mockedStore.getState().app;
expect(notificationPresenceCap).toEqual(true);
mockedStore.dispatch(setNotificationPresenceCap(false));
const { notificationPresenceCap: notificationPresenceCap2 } = mockedStore.getState().app;
expect(notificationPresenceCap2).toEqual(false);
});
}); });

View File

@ -9,7 +9,6 @@ export interface IApp {
ready: boolean; ready: boolean;
foreground: boolean; foreground: boolean;
background: boolean; background: boolean;
notificationPresenceCap: boolean;
} }
export const initialState: IApp = { export const initialState: IApp = {
@ -18,8 +17,7 @@ export const initialState: IApp = {
text: undefined, text: undefined,
ready: false, ready: false,
foreground: true, foreground: true,
background: false, background: false
notificationPresenceCap: false
}; };
export default function app(state = initialState, action: TActionApp): IApp { export default function app(state = initialState, action: TActionApp): IApp {
@ -57,11 +55,6 @@ export default function app(state = initialState, action: TActionApp): IApp {
...state, ...state,
isMasterDetail: action.isMasterDetail isMasterDetail: action.isMasterDetail
}; };
case APP.SET_NOTIFICATION_PRESENCE_CAP:
return {
...state,
notificationPresenceCap: action.show
};
default: default:
return state; return state;
} }

View File

@ -105,7 +105,11 @@ const ChatsStackNavigator = () => {
/> />
<ChatsStack.Screen name='SelectedUsersView' component={SelectedUsersView} /> <ChatsStack.Screen name='SelectedUsersView' component={SelectedUsersView} />
<ChatsStack.Screen name='InviteUsersView' component={InviteUsersView} /> <ChatsStack.Screen name='InviteUsersView' component={InviteUsersView} />
<ChatsStack.Screen name='InviteUsersEditView' component={InviteUsersEditView} /> <ChatsStack.Screen
name='InviteUsersEditView'
component={InviteUsersEditView}
options={InviteUsersEditView.navigationOptions}
/>
<ChatsStack.Screen name='MessagesView' component={MessagesView} /> <ChatsStack.Screen name='MessagesView' component={MessagesView} />
<ChatsStack.Screen name='AutoTranslateView' component={AutoTranslateView} options={AutoTranslateView.navigationOptions} /> <ChatsStack.Screen name='AutoTranslateView' component={AutoTranslateView} options={AutoTranslateView.navigationOptions} />
<ChatsStack.Screen name='DirectoryView' component={DirectoryView} options={DirectoryView.navigationOptions} /> <ChatsStack.Screen name='DirectoryView' component={DirectoryView} options={DirectoryView.navigationOptions} />

View File

@ -142,7 +142,11 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => {
component={AddExistingChannelView} component={AddExistingChannelView}
options={AddExistingChannelView.navigationOptions} options={AddExistingChannelView.navigationOptions}
/> />
<ModalStack.Screen name='InviteUsersEditView' component={InviteUsersEditView} /> <ModalStack.Screen
name='InviteUsersEditView'
component={InviteUsersEditView}
options={InviteUsersEditView.navigationOptions}
/>
<ModalStack.Screen name='MessagesView' component={MessagesView} /> <ModalStack.Screen name='MessagesView' component={MessagesView} />
<ModalStack.Screen name='AutoTranslateView' component={AutoTranslateView} options={AutoTranslateView.navigationOptions} /> <ModalStack.Screen name='AutoTranslateView' component={AutoTranslateView} options={AutoTranslateView.navigationOptions} />
<ModalStack.Screen <ModalStack.Screen

View File

@ -243,7 +243,7 @@ class DirectoryView extends React.Component<IDirectoryViewProps, IDirectoryViewS
title: item.name as string, title: item.name as string,
onPress: () => this.onPressItem(item), onPress: () => this.onPressItem(item),
baseUrl, baseUrl,
testID: `directory-view-item-${item.name}`, testID: `directory-view-item-${item.name}`.toLowerCase(),
style, style,
user, user,
theme, theme,

View File

@ -1,92 +0,0 @@
import React from 'react';
import { TextInputProps } from 'react-native';
import RNPickerSelect from 'react-native-picker-select';
import { useDispatch } from 'react-redux';
import { inviteLinksSetParams } from '../../actions/inviteLinks';
import { useTheme } from '../../theme';
import { useAppSelector } from '../../lib/hooks';
import I18n from '../../i18n';
import styles from './styles';
import { events, logEvent } from '../../lib/methods/helpers/log';
const OPTIONS = {
days: [
{
label: '1',
value: 1
},
{
label: '7',
value: 7
},
{
label: '15',
value: 15
},
{
label: '30',
value: 30
}
],
maxUses: [
{
label: '1',
value: 1
},
{
label: '5',
value: 5
},
{
label: '10',
value: 10
},
{
label: '25',
value: 25
},
{
label: '50',
value: 50
},
{
label: '100',
value: 100
}
]
};
const Picker = ({ param, first }: { param: 'days' | 'maxUses'; first: string }): JSX.Element => {
const { colors } = useTheme();
const inviteLinkParam = useAppSelector(state => state.inviteLinks[param]);
const dispatch = useDispatch();
const onValueChangePicker = (value: number) => {
logEvent(events.IU_EDIT_SET_LINK_PARAM);
const params = {
[param]: value
};
dispatch(inviteLinksSetParams(params));
};
const textInputStyle: TextInputProps = { style: { ...styles.pickerText, color: colors.actionTintColor } };
const firstEl = [
{
label: I18n.t(first),
value: 0
}
];
return (
<RNPickerSelect
style={{ viewContainer: styles.viewContainer }}
value={inviteLinkParam}
textInputProps={textInputStyle}
useNativeAndroidPickerStyle={false}
onValueChange={value => onValueChangePicker(value)}
items={firstEl.concat(OPTIONS[param])}
/>
);
};
export default Picker;

View File

@ -1,54 +1,149 @@
import { StackNavigationProp } from '@react-navigation/stack'; import { StackNavigationOptions } from '@react-navigation/stack';
import React, { useLayoutEffect } from 'react'; import React from 'react';
import { View } from 'react-native'; import { TextInputProps, View } from 'react-native';
import { useDispatch } from 'react-redux'; import RNPickerSelect from 'react-native-picker-select';
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'; import { connect } from 'react-redux';
import { inviteLinksCreate } from '../../actions/inviteLinks'; import { inviteLinksCreate, inviteLinksSetParams } from '../../actions/inviteLinks';
import { themes } from '../../lib/constants';
import Button from '../../containers/Button'; import Button from '../../containers/Button';
import * as List from '../../containers/List'; import * as List from '../../containers/List';
import SafeAreaView from '../../containers/SafeAreaView'; import SafeAreaView from '../../containers/SafeAreaView';
import StatusBar from '../../containers/StatusBar'; import StatusBar from '../../containers/StatusBar';
import { IApplicationState, IBaseScreen } from '../../definitions';
import I18n from '../../i18n'; import I18n from '../../i18n';
import { ChatsStackParamList } from '../../stacks/types'; import { ChatsStackParamList } from '../../stacks/types';
import { withTheme } from '../../theme';
import { events, logEvent } from '../../lib/methods/helpers/log'; import { events, logEvent } from '../../lib/methods/helpers/log';
import styles from './styles'; import styles from './styles';
import Picker from './Picker';
const InviteUsersEditView = () => { const OPTIONS = {
const navigation = useNavigation<StackNavigationProp<ChatsStackParamList, 'InviteUsersEditView'>>(); days: [
const { rid } = useRoute<RouteProp<ChatsStackParamList, 'InviteUsersEditView'>>().params; {
const dispatch = useDispatch(); label: '1',
value: 1
},
{
label: '7',
value: 7
},
{
label: '15',
value: 15
},
{
label: '30',
value: 30
}
],
maxUses: [
{
label: '1',
value: 1
},
{
label: '5',
value: 5
},
{
label: '10',
value: 10
},
{
label: '25',
value: 25
},
{
label: '50',
value: 50
},
{
label: '100',
value: 100
}
]
};
useLayoutEffect(() => { interface IInviteUsersEditViewProps extends IBaseScreen<ChatsStackParamList, 'InviteUsersEditView'> {
navigation.setOptions({ days: number;
title: I18n.t('Invite_users') maxUses: number;
}); }
}, [navigation]);
const createInviteLink = () => { class InviteUsersEditView extends React.Component<IInviteUsersEditViewProps, any> {
static navigationOptions = (): StackNavigationOptions => ({
title: I18n.t('Invite_users')
});
private rid: string;
constructor(props: IInviteUsersEditViewProps) {
super(props);
this.rid = props.route.params?.rid;
}
onValueChangePicker = (key: string, value: number) => {
const { dispatch } = this.props;
logEvent(events.IU_EDIT_SET_LINK_PARAM);
const params = {
[key]: value
};
dispatch(inviteLinksSetParams(params));
};
createInviteLink = () => {
const { dispatch, navigation } = this.props;
logEvent(events.IU_EDIT_CREATE_LINK); logEvent(events.IU_EDIT_CREATE_LINK);
dispatch(inviteLinksCreate(rid)); dispatch(inviteLinksCreate(this.rid));
navigation.pop(); navigation.pop();
}; };
return ( renderPicker = (key: 'days' | 'maxUses', first: string) => {
<SafeAreaView> const { props } = this;
<List.Container> const { theme } = props;
<StatusBar /> const textInputStyle: TextInputProps = { style: { ...styles.pickerText, color: themes[theme].actionTintColor } };
<List.Section> const firstEl = [
<List.Separator /> {
<List.Item title='Expiration_Days' right={() => <Picker param={'days'} first={'Never'} />} /> label: I18n.t(first),
<List.Separator /> value: 0
<List.Item title='Max_number_of_uses' right={() => <Picker param='maxUses' first='No_limit' />} /> }
<List.Separator /> ];
</List.Section> return (
<View style={styles.innerContainer}> <RNPickerSelect
<Button title={I18n.t('Generate_New_Link')} type='primary' onPress={createInviteLink} /> style={{ viewContainer: styles.viewContainer }}
</View> value={props[key]}
</List.Container> textInputProps={textInputStyle}
</SafeAreaView> useNativeAndroidPickerStyle={false}
); placeholder={{}}
}; onValueChange={value => this.onValueChangePicker(key, value)}
items={firstEl.concat(OPTIONS[key])}
/>
);
};
export default InviteUsersEditView; render() {
return (
<SafeAreaView>
<List.Container>
<StatusBar />
<List.Section>
<List.Separator />
<List.Item title='Expiration_Days' right={() => this.renderPicker('days', 'Never')} />
<List.Separator />
<List.Item title='Max_number_of_uses' right={() => this.renderPicker('maxUses', 'No_limit')} />
<List.Separator />
</List.Section>
<View style={styles.innerContainer}>
<Button title={I18n.t('Generate_New_Link')} type='primary' onPress={this.createInviteLink} />
</View>
</List.Container>
</SafeAreaView>
);
}
}
const mapStateToProps = (state: IApplicationState) => ({
days: state.inviteLinks.days,
maxUses: state.inviteLinks.maxUses
});
export default connect(mapStateToProps)(withTheme(InviteUsersEditView));

View File

@ -1,13 +1,14 @@
import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake';
import React from 'react'; import React from 'react';
import { BackHandler, NativeEventSubscription } from 'react-native'; import { BackHandler, NativeEventSubscription } from 'react-native';
import BackgroundTimer from 'react-native-background-timer';
import { isAppInstalled, openAppWithUri } from 'react-native-send-intent'; import { isAppInstalled, openAppWithUri } from 'react-native-send-intent';
import WebView from 'react-native-webview'; import WebView from 'react-native-webview';
import { WebViewMessage, WebViewNavigation } from 'react-native-webview/lib/WebViewTypes'; import { WebViewMessage, WebViewNavigation } from 'react-native-webview/lib/WebViewTypes';
import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake';
import { IBaseScreen } from '../definitions'; import { IBaseScreen } from '../definitions';
import { events, logEvent } from '../lib/methods/helpers/log'; import { events, logEvent } from '../lib/methods/helpers/log';
import { endVideoConfTimer, initVideoConfTimer } from '../lib/methods/videoConfTimer'; import { Services } from '../lib/services';
import { ChatsStackParamList } from '../stacks/types'; import { ChatsStackParamList } from '../stacks/types';
import { withTheme } from '../theme'; import { withTheme } from '../theme';
@ -19,6 +20,7 @@ class JitsiMeetView extends React.Component<TJitsiMeetViewProps> {
private rid: string; private rid: string;
private url: string; private url: string;
private videoConf: boolean; private videoConf: boolean;
private jitsiTimeout: number | null;
private backHandler!: NativeEventSubscription; private backHandler!: NativeEventSubscription;
constructor(props: TJitsiMeetViewProps) { constructor(props: TJitsiMeetViewProps) {
@ -26,6 +28,7 @@ class JitsiMeetView extends React.Component<TJitsiMeetViewProps> {
this.rid = props.route.params?.rid; this.rid = props.route.params?.rid;
this.url = props.route.params?.url; this.url = props.route.params?.url;
this.videoConf = !!props.route.params?.videoConf; this.videoConf = !!props.route.params?.videoConf;
this.jitsiTimeout = null;
} }
componentDidMount() { componentDidMount() {
@ -47,8 +50,10 @@ class JitsiMeetView extends React.Component<TJitsiMeetViewProps> {
componentWillUnmount() { componentWillUnmount() {
logEvent(this.videoConf ? events.LIVECHAT_VIDEOCONF_TERMINATE : events.JM_CONFERENCE_TERMINATE); logEvent(this.videoConf ? events.LIVECHAT_VIDEOCONF_TERMINATE : events.JM_CONFERENCE_TERMINATE);
if (!this.videoConf) { if (this.jitsiTimeout && !this.videoConf) {
endVideoConfTimer(); BackgroundTimer.clearInterval(this.jitsiTimeout);
this.jitsiTimeout = null;
BackgroundTimer.stopBackgroundTimer();
} }
this.backHandler.remove(); this.backHandler.remove();
deactivateKeepAwake(); deactivateKeepAwake();
@ -59,7 +64,15 @@ class JitsiMeetView extends React.Component<TJitsiMeetViewProps> {
onConferenceJoined = () => { onConferenceJoined = () => {
logEvent(this.videoConf ? events.LIVECHAT_VIDEOCONF_JOIN : events.JM_CONFERENCE_JOIN); logEvent(this.videoConf ? events.LIVECHAT_VIDEOCONF_JOIN : events.JM_CONFERENCE_JOIN);
if (this.rid && !this.videoConf) { if (this.rid && !this.videoConf) {
initVideoConfTimer(this.rid); Services.updateJitsiTimeout(this.rid).catch((e: unknown) => console.log(e));
if (this.jitsiTimeout) {
BackgroundTimer.clearInterval(this.jitsiTimeout);
BackgroundTimer.stopBackgroundTimer();
this.jitsiTimeout = null;
}
this.jitsiTimeout = BackgroundTimer.setInterval(() => {
Services.updateJitsiTimeout(this.rid).catch((e: unknown) => console.log(e));
}, 10000);
} }
}; };
@ -77,7 +90,7 @@ class JitsiMeetView extends React.Component<TJitsiMeetViewProps> {
render() { render() {
return ( return (
<WebView <WebView
source={{ uri: `${this.url}${this.url.includes('#config') ? '&' : '#'}config.disableDeepLinking=true` }} source={{ uri: `${this.url}&config.disableDeepLinking=true` }}
onMessage={({ nativeEvent }) => this.onNavigationStateChange(nativeEvent)} onMessage={({ nativeEvent }) => this.onNavigationStateChange(nativeEvent)}
onNavigationStateChange={this.onNavigationStateChange} onNavigationStateChange={this.onNavigationStateChange}
style={{ flex: 1 }} style={{ flex: 1 }}

View File

@ -9,7 +9,6 @@ import { useAppSelector } from '../lib/hooks';
import { events, logEvent } from '../lib/methods/helpers/log'; import { events, logEvent } from '../lib/methods/helpers/log';
import { getUserSelector } from '../selectors/login'; import { getUserSelector } from '../selectors/login';
import { ChatsStackParamList } from '../stacks/types'; import { ChatsStackParamList } from '../stacks/types';
import { endVideoConfTimer, initVideoConfTimer } from '../lib/methods/videoConfTimer';
const formatUrl = (url: string, baseUrl: string, uriSize: number, avatarAuthURLFragment: string) => const formatUrl = (url: string, baseUrl: string, uriSize: number, avatarAuthURLFragment: string) =>
`${baseUrl}/avatar/${url}?format=png&width=${uriSize}&height=${uriSize}${avatarAuthURLFragment}`; `${baseUrl}/avatar/${url}?format=png&width=${uriSize}&height=${uriSize}${avatarAuthURLFragment}`;
@ -17,7 +16,7 @@ const formatUrl = (url: string, baseUrl: string, uriSize: number, avatarAuthURLF
const JitsiMeetView = (): React.ReactElement => { const JitsiMeetView = (): React.ReactElement => {
const { goBack } = useNavigation(); const { goBack } = useNavigation();
const { const {
params: { url, onlyAudio, videoConf, rid } params: { url, onlyAudio, videoConf }
} = useRoute<RouteProp<ChatsStackParamList, 'JitsiMeetView'>>(); } = useRoute<RouteProp<ChatsStackParamList, 'JitsiMeetView'>>();
const user = useAppSelector(state => getUserSelector(state)); const user = useAppSelector(state => getUserSelector(state));
const baseUrl = useAppSelector(state => state.server.server); const baseUrl = useAppSelector(state => state.server.server);
@ -61,10 +60,8 @@ const JitsiMeetView = (): React.ReactElement => {
} }
}; };
logEvent(videoConf ? events.LIVECHAT_VIDEOCONF_JOIN : events.JM_CONFERENCE_JOIN); logEvent(videoConf ? events.LIVECHAT_VIDEOCONF_JOIN : events.JM_CONFERENCE_JOIN);
if (!videoConf) initVideoConfTimer(rid);
await JitsiMeet.launchJitsiMeetView(conferenceOptions); await JitsiMeet.launchJitsiMeetView(conferenceOptions);
logEvent(videoConf ? events.LIVECHAT_VIDEOCONF_TERMINATE : events.JM_CONFERENCE_TERMINATE); logEvent(videoConf ? events.LIVECHAT_VIDEOCONF_TERMINATE : events.JM_CONFERENCE_TERMINATE);
if (!videoConf) endVideoConfTimer();
goBack(); goBack();
}; };

View File

@ -1,25 +0,0 @@
import React from 'react';
import * as List from '../../../containers/List';
import i18n from '../../../i18n';
import { useVideoConf } from '../../../lib/hooks/useVideoConf';
export default function CallSection({ rid }: { rid: string }): React.ReactElement | null {
const { showCallOption, showInitCallActionSheet } = useVideoConf(rid);
if (showCallOption)
return (
<List.Section>
<List.Separator />
<List.Item
title={i18n.t('Call')}
onPress={showInitCallActionSheet}
testID='room-actions-call'
left={() => <List.Icon name='phone' />}
showActionIndicator
/>
<List.Separator />
</List.Section>
);
return null;
}

View File

@ -33,7 +33,7 @@ import sharedStyles from '../Styles';
import styles from './styles'; import styles from './styles';
import { ERoomType } from '../../definitions/ERoomType'; import { ERoomType } from '../../definitions/ERoomType';
import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
import { getPermalinkChannel } from '../../lib/methods'; import { callJitsi, getPermalinkChannel } from '../../lib/methods';
import { import {
canAutoTranslate as canAutoTranslateMethod, canAutoTranslate as canAutoTranslateMethod,
getRoomAvatar, getRoomAvatar,
@ -48,9 +48,9 @@ import { getSubscriptionByRoomId } from '../../lib/database/services/Subscriptio
import { IActionSheetProvider, withActionSheet } from '../../containers/ActionSheet'; import { IActionSheetProvider, withActionSheet } from '../../containers/ActionSheet';
import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types'; import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types';
import { closeLivechat } from '../../lib/methods/helpers/closeLivechat'; import { closeLivechat } from '../../lib/methods/helpers/closeLivechat';
import { videoConfStartAndJoin } from '../../lib/methods/videoConf';
import { ILivechatDepartment } from '../../definitions/ILivechatDepartment'; import { ILivechatDepartment } from '../../definitions/ILivechatDepartment';
import { ILivechatTag } from '../../definitions/ILivechatTag'; import { ILivechatTag } from '../../definitions/ILivechatTag';
import CallSection from './components/CallSection';
interface IOnPressTouch { interface IOnPressTouch {
<T extends keyof ChatsStackParamList>(item: { route?: T; params?: ChatsStackParamList[T]; event?: Function }): void; <T extends keyof ChatsStackParamList>(item: { route?: T; params?: ChatsStackParamList[T]; event?: Function }): void;
@ -730,6 +730,16 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
} }
}; };
startVideoConf = ({ video }: { video: boolean }): void => {
const { room } = this.state;
const { serverVersion } = this.props;
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.0.0')) {
videoConfStartAndJoin(room.rid, video);
} else {
callJitsi(room, !video);
}
};
renderRoomInfo = () => { renderRoomInfo = () => {
const { room, member } = this.state; const { room, member } = this.state;
const { rid, name, t, topic, source } = room; const { rid, name, t, topic, source } = room;
@ -805,6 +815,63 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
); );
}; };
renderJitsi = () => {
const { room } = this.state;
const {
jitsiEnabled,
jitsiEnableTeams,
jitsiEnableChannels,
serverVersion,
videoConf_Enable_DMs,
videoConf_Enable_Channels,
videoConf_Enable_Groups,
videoConf_Enable_Teams
} = this.props;
const isJitsiDisabledForTeams = room.teamMain && !jitsiEnableTeams;
const isJitsiDisabledForChannels = !room.teamMain && (room.t === 'p' || room.t === 'c') && !jitsiEnableChannels;
const isVideoConfDisabledForTeams = !!room.teamMain && !videoConf_Enable_Teams;
const isVideoConfDisabledForChannels = !room.teamMain && room.t === 'c' && !videoConf_Enable_Channels;
const isVideoConfDisabledForGroups = !room.teamMain && room.t === 'p' && !videoConf_Enable_Groups;
const isVideoConfDisabledForDirect = !room.teamMain && room.t === 'd' && !videoConf_Enable_DMs;
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.0.0')) {
if (
isVideoConfDisabledForTeams ||
isVideoConfDisabledForChannels ||
isVideoConfDisabledForGroups ||
isVideoConfDisabledForDirect
) {
return null;
}
} else if (!jitsiEnabled || isJitsiDisabledForTeams || isJitsiDisabledForChannels) {
return null;
}
return (
<List.Section>
<List.Separator />
<List.Item
title='Voice_call'
onPress={() => this.startVideoConf({ video: false })}
testID='room-actions-voice'
left={() => <List.Icon name='phone' />}
showActionIndicator
/>
<List.Separator />
<List.Item
title='Video_call'
onPress={() => this.startVideoConf({ video: true })}
testID='room-actions-video'
left={() => <List.Icon name='camera' />}
showActionIndicator
/>
<List.Separator />
</List.Section>
);
};
renderE2EEncryption = () => { renderE2EEncryption = () => {
const { room } = this.state; const { room } = this.state;
const { encryptionEnabled } = this.props; const { encryptionEnabled } = this.props;
@ -1041,7 +1108,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
<StatusBar /> <StatusBar />
<List.Container testID='room-actions-scrollview'> <List.Container testID='room-actions-scrollview'>
{this.renderRoomInfo()} {this.renderRoomInfo()}
<CallSection rid={rid} /> {this.renderJitsi()}
{this.renderE2EEncryption()} {this.renderE2EEncryption()}
<List.Section> <List.Section>
<List.Separator /> <List.Separator />
@ -1232,6 +1299,13 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
const mapStateToProps = (state: IApplicationState) => ({ const mapStateToProps = (state: IApplicationState) => ({
userId: getUserSelector(state).id, userId: getUserSelector(state).id,
jitsiEnabled: (state.settings.Jitsi_Enabled || false) as boolean,
jitsiEnableTeams: (state.settings.Jitsi_Enable_Teams || false) as boolean,
jitsiEnableChannels: (state.settings.Jitsi_Enable_Channels || false) as boolean,
videoConf_Enable_DMs: (state.settings.VideoConf_Enable_DMs ?? true) as boolean,
videoConf_Enable_Channels: (state.settings.VideoConf_Enable_Channels ?? true) as boolean,
videoConf_Enable_Groups: (state.settings.VideoConf_Enable_Groups ?? true) as boolean,
videoConf_Enable_Teams: (state.settings.VideoConf_Enable_Teams ?? true) as boolean,
encryptionEnabled: state.encryption.enabled, encryptionEnabled: state.encryption.enabled,
serverVersion: state.server.version, serverVersion: state.server.version,
isMasterDetail: state.app.isMasterDetail, isMasterDetail: state.app.isMasterDetail,

View File

@ -655,6 +655,7 @@ class RoomInfoEditView extends React.Component<IRoomInfoEditViewProps, IRoomInfo
label={I18n.t('Password')} label={I18n.t('Password')}
value={joinCode} value={joinCode}
onChangeText={value => this.setState({ joinCode: value })} onChangeText={value => this.setState({ joinCode: value })}
onSubmitEditing={this.submit}
secureTextEntry secureTextEntry
testID='room-info-edit-view-password' testID='room-info-edit-view-password'
/> />

View File

@ -1,48 +0,0 @@
import React from 'react';
import { Text } from 'react-native';
import { BorderlessButton } from 'react-native-gesture-handler';
import { CustomIcon, TIconsName } from '../../../containers/CustomIcon';
import styles from '../styles';
import { useTheme } from '../../../theme';
import { useVideoConf } from '../../../lib/hooks/useVideoConf';
import i18n from '../../../i18n';
import { useAppSelector } from '../../../lib/hooks';
import { compareServerVersion } from '../../../lib/methods/helpers';
// TODO: change other icons on future
function UserInfoButton({
danger,
iconName,
onPress,
label,
showIcon
}: {
danger?: boolean;
iconName: TIconsName;
onPress?: (prop: any) => void;
label: string;
showIcon?: boolean;
}): React.ReactElement | null {
const { colors } = useTheme();
const color = danger ? colors.dangerColor : colors.actionTintColor;
if (showIcon)
return (
<BorderlessButton testID={`room-info-view-${iconName}`} onPress={onPress} style={styles.roomButton}>
<CustomIcon name={iconName} size={30} color={color} />
<Text style={[styles.roomButtonText, { color }]}>{label}</Text>
</BorderlessButton>
);
return null;
}
export function CallButton({ rid, isDirect }: { rid: string; isDirect: boolean }): React.ReactElement | null {
const { showCallOption, showInitCallActionSheet } = useVideoConf(rid);
const serverVersion = useAppSelector(state => state.server.version);
const greaterThanFive = compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.0.0');
const showIcon = greaterThanFive ? showCallOption : showCallOption && isDirect;
return <UserInfoButton onPress={showInitCallActionSheet} iconName='phone' label={i18n.t('Call')} showIcon={showIcon} />;
}

Some files were not shown because too many files have changed in this diff Show More