feat: button to refresh cloud data on support window expired screen (#5528)
This commit is contained in:
parent
50d534f71b
commit
d9dd6a3dd8
|
@ -1,17 +1,49 @@
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { View, Text, Linking } from 'react-native';
|
import { View, Text, Linking } from 'react-native';
|
||||||
|
import { useDispatch } from 'react-redux';
|
||||||
|
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import { useAppSelector } from '../../lib/hooks';
|
import { useAppSelector } from '../../lib/hooks';
|
||||||
|
import { getServerById } from '../../lib/database/services/Server';
|
||||||
|
import log from '../../lib/methods/helpers/log';
|
||||||
|
import database from '../../lib/database';
|
||||||
import { useTheme } from '../../theme';
|
import { useTheme } from '../../theme';
|
||||||
import { CustomIcon } from '../CustomIcon';
|
import { CustomIcon } from '../CustomIcon';
|
||||||
import Button from '../Button';
|
import Button from '../Button';
|
||||||
import { styles } from './styles';
|
import { styles } from './styles';
|
||||||
import { LEARN_MORE_URL } from './constants';
|
import { LEARN_MORE_URL } from './constants';
|
||||||
|
import { selectServerRequest } from '../../actions/server';
|
||||||
|
|
||||||
|
const checkAgainTimeout = 3000;
|
||||||
|
|
||||||
export const SupportedVersionsExpired = () => {
|
export const SupportedVersionsExpired = () => {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { name } = useAppSelector(state => state.server);
|
const [checking, setChecking] = useState(false);
|
||||||
|
const { name, server } = useAppSelector(state => state.server);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
const checkAgain = async () => {
|
||||||
|
try {
|
||||||
|
setChecking(true);
|
||||||
|
const serversDB = database.servers;
|
||||||
|
const serverRecord = await getServerById(server);
|
||||||
|
if (serverRecord) {
|
||||||
|
await serversDB.write(async () => {
|
||||||
|
await serverRecord.update(r => {
|
||||||
|
r.supportedVersionsUpdatedAt = null;
|
||||||
|
r.supportedVersionsWarningAt = null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
dispatch(selectServerRequest(server));
|
||||||
|
// forces loading state a little longer until redux is finished
|
||||||
|
await new Promise(res => setTimeout(res, checkAgainTimeout));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log(e);
|
||||||
|
} finally {
|
||||||
|
setChecking(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, { paddingTop: 120, backgroundColor: colors.focusedBackground }]}>
|
<View style={[styles.container, { paddingTop: 120, backgroundColor: colors.focusedBackground }]}>
|
||||||
|
@ -22,6 +54,7 @@ export const SupportedVersionsExpired = () => {
|
||||||
{I18n.t('Supported_versions_expired_title', { workspace_name: name })}
|
{I18n.t('Supported_versions_expired_title', { workspace_name: name })}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[styles.description, { color: colors.bodyText }]}>{I18n.t('Supported_versions_expired_description')}</Text>
|
<Text style={[styles.description, { color: colors.bodyText }]}>{I18n.t('Supported_versions_expired_description')}</Text>
|
||||||
|
<Button title={I18n.t('Check_again')} type='primary' onPress={checkAgain} loading={checking} />
|
||||||
<Button
|
<Button
|
||||||
title={I18n.t('Learn_more')}
|
title={I18n.t('Learn_more')}
|
||||||
type='secondary'
|
type='secondary'
|
||||||
|
|
|
@ -80,8 +80,8 @@ export interface IServer {
|
||||||
enterpriseModules: IEnterpriseModules;
|
enterpriseModules: IEnterpriseModules;
|
||||||
E2E_Enable: boolean;
|
E2E_Enable: boolean;
|
||||||
supportedVersions?: ISupportedVersionsData;
|
supportedVersions?: ISupportedVersionsData;
|
||||||
supportedVersionsWarningAt?: Date;
|
supportedVersionsWarningAt?: Date | null;
|
||||||
supportedVersionsUpdatedAt?: Date;
|
supportedVersionsUpdatedAt?: Date | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TServerModel = IServer & Model;
|
export type TServerModel = IServer & Model;
|
||||||
|
|
|
@ -805,5 +805,6 @@
|
||||||
"Add_thread_reply": "Add thread reply",
|
"Add_thread_reply": "Add thread reply",
|
||||||
"Message_roomname": "Message {{roomName}}",
|
"Message_roomname": "Message {{roomName}}",
|
||||||
"Microphone_access_needed_to_record_audio": "Microphone access needed to record audio",
|
"Microphone_access_needed_to_record_audio": "Microphone access needed to record audio",
|
||||||
"Go_to_your_device_settings_and_allow_microphone": "Go to your device settings and allow microphone access for Rocket.Chat"
|
"Go_to_your_device_settings_and_allow_microphone": "Go to your device settings and allow microphone access for Rocket.Chat",
|
||||||
|
"Check_again": "Check again"
|
||||||
}
|
}
|
|
@ -797,5 +797,6 @@
|
||||||
"Microphone_access_needed_to_record_audio": "Acesso ao microfone necessário para gravar áudio",
|
"Microphone_access_needed_to_record_audio": "Acesso ao microfone necessário para gravar áudio",
|
||||||
"Go_to_your_device_settings_and_allow_microphone": "Vá para as configurações do seu dispositivo e permita o acesso ao microfone pelo aplicativo Rocket.Chat",
|
"Go_to_your_device_settings_and_allow_microphone": "Vá para as configurações do seu dispositivo e permita o acesso ao microfone pelo aplicativo Rocket.Chat",
|
||||||
"In_app_message_notifications": "Notificações de mensagens in-app",
|
"In_app_message_notifications": "Notificações de mensagens in-app",
|
||||||
"Vibrate": "Vibrar"
|
"Vibrate": "Vibrar",
|
||||||
|
"Check_again": "Verificar novamente"
|
||||||
}
|
}
|
Loading…
Reference in New Issue