|
|
@@ -1,14 +1,12 @@
|
|
1
|
1
|
// @flow
|
|
2
|
2
|
|
|
3
|
3
|
import React, { Component } from 'react';
|
|
4
|
|
-import { Text } from 'react-native';
|
|
5
|
4
|
import { connect } from 'react-redux';
|
|
6
|
5
|
|
|
7
|
|
-import { Dialog } from '../../base/dialog';
|
|
|
6
|
+import { ConfirmDialog } from '../../base/dialog';
|
|
8
|
7
|
import { translate } from '../../base/i18n';
|
|
9
|
8
|
|
|
10
|
9
|
import { cancelWaitForOwner, _openLoginDialog } from '../actions';
|
|
11
|
|
-import styles from './styles';
|
|
12
|
10
|
|
|
13
|
11
|
/**
|
|
14
|
12
|
* The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
|
|
|
@@ -60,22 +58,19 @@ class WaitForOwnerDialog extends Component<Props> {
|
|
60
|
58
|
*/
|
|
61
|
59
|
render() {
|
|
62
|
60
|
const {
|
|
63
|
|
- _room: room,
|
|
64
|
|
- t
|
|
|
61
|
+ _room: room
|
|
65
|
62
|
} = this.props;
|
|
66
|
63
|
|
|
67
|
64
|
return (
|
|
68
|
|
- <Dialog
|
|
69
|
|
- okTitleKey = { 'dialog.IamHost' }
|
|
70
|
|
- onCancel = { this._onCancel }
|
|
71
|
|
- onSubmit = { this._onLogin }
|
|
72
|
|
- titleKey = 'dialog.WaitingForHost'>
|
|
73
|
|
- <Text style = { styles.waitForOwnerDialog }>
|
|
|
65
|
+ <ConfirmDialog
|
|
|
66
|
+ contentKey = {
|
|
74
|
67
|
{
|
|
75
|
|
- this._renderHTML(t('dialog.WaitForHostMsg', { room }))
|
|
|
68
|
+ key: 'dialog.WaitForHostMsgWOk',
|
|
|
69
|
+ params: { room }
|
|
76
|
70
|
}
|
|
77
|
|
- </Text>
|
|
78
|
|
- </Dialog>
|
|
|
71
|
+ }
|
|
|
72
|
+ onCancel = { this._onCancel }
|
|
|
73
|
+ onSubmit = { this._onLogin } />
|
|
79
|
74
|
);
|
|
80
|
75
|
}
|
|
81
|
76
|
|
|
|
@@ -102,59 +97,6 @@ class WaitForOwnerDialog extends Component<Props> {
|
|
102
|
97
|
_onLogin() {
|
|
103
|
98
|
this.props.dispatch(_openLoginDialog());
|
|
104
|
99
|
}
|
|
105
|
|
-
|
|
106
|
|
- /**
|
|
107
|
|
- * Renders a specific {@code string} which may contain HTML.
|
|
108
|
|
- *
|
|
109
|
|
- * @param {string|undefined} html - The {@code string} which may
|
|
110
|
|
- * contain HTML to render.
|
|
111
|
|
- * @returns {ReactElement[]|string}
|
|
112
|
|
- */
|
|
113
|
|
- _renderHTML(html: ?string) {
|
|
114
|
|
- if (typeof html === 'string') {
|
|
115
|
|
- // At the time of this writing, the specified HTML contains a couple
|
|
116
|
|
- // of spaces one after the other. They do not cause a visible
|
|
117
|
|
- // problem on Web, because the specified HTML is rendered as, well,
|
|
118
|
|
- // HTML. However, we're not rendering HTML here.
|
|
119
|
|
-
|
|
120
|
|
- // eslint-disable-next-line no-param-reassign
|
|
121
|
|
- html = html.replace(/\s{2,}/gi, ' ');
|
|
122
|
|
-
|
|
123
|
|
- // Render text in <b>text</b> in bold.
|
|
124
|
|
- const opening = /<\s*b\s*>/gi;
|
|
125
|
|
- const closing = /<\s*\/\s*b\s*>/gi;
|
|
126
|
|
- let o;
|
|
127
|
|
- let c;
|
|
128
|
|
- let prevClosingLastIndex = 0;
|
|
129
|
|
- const r = [];
|
|
130
|
|
-
|
|
131
|
|
- // eslint-disable-next-line no-cond-assign
|
|
132
|
|
- while (o = opening.exec(html)) {
|
|
133
|
|
- closing.lastIndex = opening.lastIndex;
|
|
134
|
|
-
|
|
135
|
|
- // eslint-disable-next-line no-cond-assign
|
|
136
|
|
- if (c = closing.exec(html)) {
|
|
137
|
|
- r.push(html.substring(prevClosingLastIndex, o.index));
|
|
138
|
|
- r.push(
|
|
139
|
|
- <Text style = { styles.boldDialogText }>
|
|
140
|
|
- { html.substring(opening.lastIndex, c.index) }
|
|
141
|
|
- </Text>);
|
|
142
|
|
- opening.lastIndex
|
|
143
|
|
- = prevClosingLastIndex
|
|
144
|
|
- = closing.lastIndex;
|
|
145
|
|
- } else {
|
|
146
|
|
- break;
|
|
147
|
|
- }
|
|
148
|
|
- }
|
|
149
|
|
- if (prevClosingLastIndex < html.length) {
|
|
150
|
|
- r.push(html.substring(prevClosingLastIndex));
|
|
151
|
|
- }
|
|
152
|
|
-
|
|
153
|
|
- return r;
|
|
154
|
|
- }
|
|
155
|
|
-
|
|
156
|
|
- return html;
|
|
157
|
|
- }
|
|
158
|
100
|
}
|
|
159
|
101
|
|
|
160
|
102
|
/**
|