Skip to content

Commit

Permalink
Fixes to maintenance stuff (#5746)
Browse files Browse the repository at this point in the history
* Fixes to maintenance stuff

* remove leftover code

* eslint
  • Loading branch information
farhatahmad authored Mar 11, 2024
1 parent 78c4776 commit e7dd4c9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@
"brand_image_deleted": "The brand image has been deleted.",
"privacy_policy_updated": "The privacy policy has been updated.",
"helpcenter_updated": "The help center link has been updated.",
"terms_of_service_updated": "The terms of service have been updated."
"terms_of_service_updated": "The terms of service have been updated.",
"maintenance_updated": "The maintenance banner has been updated."
},
"recording": {
"recording_visibility_updated": "The recording visibility has been updated.",
Expand Down
8 changes: 1 addition & 7 deletions app/javascript/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ export default function App() {

// useEffect hook for running notify maintenance banner on page load
useEffect(() => {
// set a cookie for a day after maintenance banner dismissed
const maintenanceClosedAt = localStorage.getItem('maintenanceClosedAt');
const now = new Date();
const oneDayInMilliseconds = 24 * 60 * 60 * 1000;

if (maintenanceBanner.data && (!maintenanceClosedAt || now.getTime() - new Date(maintenanceClosedAt).getTime() > oneDayInMilliseconds)) {
if (maintenanceBanner.data) {
const toastId = toast.info(maintenanceBanner.data, {
position: 'top-center',
autoClose: false,
Expand All @@ -50,7 +45,6 @@ export default function App() {
progress: undefined,
theme: 'light',
className: 'text-center',
onClose: () => localStorage.setItem('maintenanceClosedAt', new Date().toISOString()),
});
localStorage.setItem('maintenanceBannerId', toastId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ export default function LinksForm({ id, value, mutation: useUpdateSiteSettingsAP
LinksForm.propTypes = {
id: PropTypes.string.isRequired,
mutation: PropTypes.func.isRequired,
value: PropTypes.string.isRequired,
value: PropTypes.string,
};

LinksForm.defaultProps = {
value: '',
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function TextForm({ id, value, mutation: useUpdateSiteSettingsAPI
const clearForm = () => {
methods.reset({ value: '' });
toast.dismiss(maintenanceBannerId);
updateSiteSettingsAPI.mutate('');
};

return (
Expand All @@ -60,5 +61,9 @@ export default function TextForm({ id, value, mutation: useUpdateSiteSettingsAPI
TextForm.propTypes = {
id: PropTypes.string.isRequired,
mutation: PropTypes.func.isRequired,
value: PropTypes.string.isRequired,
value: PropTypes.string,
};

TextForm.defaultProps = {
value: '',
};
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export default function useUpdateSiteSetting(name) {
case 'TermsOfService':
toast.success(t('toast.success.site_settings.terms_of_service_updated'));
break;
case 'Maintenance':
toast.success(t('toast.success.site_settings.maintenance_updated'));
break;
default:
toast.success(t('toast.success.site_settings.site_setting_updated'));
}
Expand Down

0 comments on commit e7dd4c9

Please sign in to comment.