Network detection by pinging Mattermost server (#1130)
This commit is contained in:
parent
2792e3bab1
commit
a299cdb5c5
3 changed files with 6 additions and 5 deletions
|
|
@ -126,7 +126,7 @@ export default class OfflineIndicator extends Component {
|
|||
switch (this.state.network) {
|
||||
case OFFLINE:
|
||||
i18nId = 'mobile.offlineIndicator.offline';
|
||||
defaultMessage = 'No internet connection';
|
||||
defaultMessage = 'Cannot connect to the server';
|
||||
break;
|
||||
case CONNECTING:
|
||||
i18nId = 'mobile.offlineIndicator.connecting';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import {NetInfo} from 'react-native';
|
||||
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
|
||||
export async function checkConnection() {
|
||||
// If the websocket cannot connect probably is because the Mattermost server
|
||||
// is down and we don't want to make the app think the device is offline
|
||||
const server = 'https://www.google.com';
|
||||
// Ping the Mattermost server to detect if the we have network connection even if the websocket cannot connect
|
||||
const server = `${Client4.getBaseRoute()}/system/ping?time=${Date.now()}`;
|
||||
|
||||
try {
|
||||
await fetch(server);
|
||||
|
|
|
|||
|
|
@ -2013,7 +2013,7 @@
|
|||
"mobile.notification_settings_mobile.vibrate": "Vibrate",
|
||||
"mobile.offlineIndicator.connected": "Connected",
|
||||
"mobile.offlineIndicator.connecting": "Connecting...",
|
||||
"mobile.offlineIndicator.offline": "No internet connection",
|
||||
"mobile.offlineIndicator.offline": "Cannot connect to the server",
|
||||
"mobile.open_dm.error": "We couldn't open a direct message with {displayName}. Please check your connection and try again.",
|
||||
"mobile.open_gm.error": "We couldn't open a group message with those users. Please check your connection and try again.",
|
||||
"mobile.post.cancel": "Cancel",
|
||||
|
|
|
|||
Loading…
Reference in a new issue