瀏覽代碼

feat: Adds visitors count in conference info.

factor2
damencho 2 年之前
父節點
當前提交
abe2fa4dd4

+ 1
- 0
lang/main.json 查看文件

@@ -1333,6 +1333,7 @@
1333 1333
         "webAssemblyWarning": "WebAssembly not supported",
1334 1334
         "webAssemblyWarningDescription": "WebAssembly disabled or not supported by this browser"
1335 1335
     },
1336
+    "visitorsLabel": "Number of visitors: {{count}}",
1336 1337
     "volumeSlider": "Volume slider",
1337 1338
     "welcomepage": {
1338 1339
         "accessibilityLabel": {

+ 1
- 0
react/features/conference/components/constants.ts 查看文件

@@ -8,6 +8,7 @@ export const CONFERENCE_INFO = {
8 8
         'e2ee',
9 9
         'transcribing',
10 10
         'video-quality',
11
+        'visitors-count',
11 12
         'insecure-room',
12 13
         'top-panel-toggle'
13 14
     ]

+ 5
- 0
react/features/conference/components/web/ConferenceInfo.js 查看文件

@@ -12,6 +12,7 @@ import RecordingLabel from '../../../recording/components/web/RecordingLabel';
12 12
 import { isToolboxVisible } from '../../../toolbox/functions.web';
13 13
 import TranscribingLabel from '../../../transcribing/components/TranscribingLabel.web';
14 14
 import VideoQualityLabel from '../../../video-quality/components/VideoQualityLabel.web';
15
+import VisitorsCountLabel from '../../../visitors/components/web/VisitorsCountLabel';
15 16
 import ConferenceTimer from '../ConferenceTimer';
16 17
 import { getConferenceInfo } from '../functions';
17 18
 
@@ -80,6 +81,10 @@ const COMPONENTS = [
80 81
         Component: VideoQualityLabel,
81 82
         id: 'video-quality'
82 83
     },
84
+    {
85
+        Component: VisitorsCountLabel,
86
+        id: 'visitors-count'
87
+    },
83 88
     {
84 89
         Component: InsecureRoomNameLabel,
85 90
         id: 'insecure-room'

+ 48
- 0
react/features/visitors/components/web/VisitorsCountLabel.tsx 查看文件

@@ -0,0 +1,48 @@
1
+import React from 'react';
2
+import { useTranslation } from 'react-i18next';
3
+import { useSelector } from 'react-redux';
4
+import { makeStyles } from 'tss-react/mui';
5
+
6
+import { IReduxState } from '../../../app/types';
7
+import { IconUsers } from '../../../base/icons/svg';
8
+import Label from '../../../base/label/components/web/Label';
9
+// eslint-disable-next-line lines-around-comment
10
+// @ts-ignore
11
+import { Tooltip } from '../../../base/tooltip';
12
+
13
+const useStyles = makeStyles()(theme => {
14
+    return {
15
+        label: {
16
+            backgroundColor: theme.palette.warning02,
17
+            color: theme.palette.uiBackground
18
+        }
19
+    };
20
+});
21
+
22
+const VisitorsCountLabel = () => {
23
+    const { classes: styles, theme } = useStyles();
24
+    const visitorsMode = useSelector((state: IReduxState) => state['features/visitors'].enabled);
25
+    const visitorsCount = useSelector((state: IReduxState) =>
26
+        state['features/visitors'].count || 0);
27
+    const { t } = useTranslation();
28
+
29
+    let visitorsCountLabel = String(visitorsCount);
30
+
31
+    // over 100 we show numbers lik 0.2 K or 9.5 K.
32
+    if (visitorsCount > 100) {
33
+        visitorsCountLabel = `${Math.round(visitorsCount / 100) / 10} K`;
34
+    }
35
+
36
+    return visitorsMode && (<Tooltip
37
+        content = { t('visitorsLabel', { count: visitorsCount }) }
38
+        position = { 'bottom' }>
39
+        <Label
40
+            className = { styles.label }
41
+            icon = { IconUsers }
42
+            iconColor = { theme.palette.icon04 }
43
+            id = 'visitorsCountLabel'
44
+            text = { `${visitorsCountLabel}` } />
45
+    </Tooltip>);
46
+};
47
+
48
+export default VisitorsCountLabel;

Loading…
取消
儲存