Skip to content

Commit

Permalink
Hide "Data updated" for invalid dates
Browse files Browse the repository at this point in the history
A bad value could show as an inaccuracy such as "Data updated today",
which shouldn't be allowed. I discovered this upon looking at the mers
example dataset provided by get-data.sh.
  • Loading branch information
victorlin committed Dec 12, 2023
1 parent 19f5c2c commit 97089b7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"path": "./dist/auspice.?(chunk.)core-vendors.bundle.*.js",
"maxSize": "220 kB"
"maxSize": "250 kB"
},
{
"path": "./dist/auspice.?(chunk.)other-vendors.bundle.*.js",
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"linspace": "^1.0.0",
"lodash": "^4.17.21",
"lodash-webpack-plugin": "^0.11.6",
"luxon": "^3.4.4",
"marked": "^0.7.0",
"mousetrap": "^1.6.2",
"null-loader": "^4.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/components/framework/fine-print.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { connect } from "react-redux";
import styled from 'styled-components';
import { withTranslation } from "react-i18next";
import { FaDownload } from "react-icons/fa";
import { DateTime } from "luxon";
import { dataFont, medGrey, materialButton } from "../../globalStyles";
import { TRIGGER_DOWNLOAD_MODAL } from "../../actions/types";
import Flex from "./flex";
Expand Down Expand Up @@ -72,7 +73,7 @@ class FinePrint extends React.Component {

getUpdated() {
const { t } = this.props;
if (this.props.metadata.updated) {
if (DateTime.fromISO(this.props.metadata.updated).isValid) {
return (<span>{t("Data updated")} {this.props.metadata.updated}</span>);
}
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/components/info/byline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { connect } from "react-redux";
import { withTranslation } from 'react-i18next';
import styled from 'styled-components';
import { DateTime } from "luxon";
import { headerFont } from "../../globalStyles";

/**
Expand Down Expand Up @@ -107,7 +108,7 @@ function renderMaintainers(t, metadata) {
* Renders a <span> containing "Data updated X", where X derives from `metadata.updated`
*/
function renderDataUpdated(t, metadata) {
if (metadata.updated) {
if (DateTime.fromISO(metadata.updated).isValid) {
return (
<span>
{`${t("Data updated")} ${metadata.updated}. `}
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
"style-loader",
"@hot-loader/react-dom",
"react(-(redux|select|helmet|i18next))?",
"luxon",
"leaflet",
"redux",
"leaflet(-gesture-handling)?",
Expand Down

0 comments on commit 97089b7

Please sign in to comment.