Skip to content

Commit 78b1964

Browse files
committed
only filter on search page, fix stats page in dark mode, show n/a for recently added app DL counts
1 parent 3d3d083 commit 78b1964

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

src/AppDetails.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@ class AppDetails extends Component {
207207
</div>
208208
) : null;
209209

210+
const isWithinOneWeek = timestamp => {
211+
// check if the given timestamp is within the last 7 days
212+
const twoDaysInMilliseconds = 7 * 24 * 60 * 60 * 1000;
213+
const currentTime = new Date().getTime();
214+
const appUpdateTime = new Date(timestamp).getTime();
215+
return (currentTime - appUpdateTime) < twoDaysInMilliseconds;
216+
};
217+
218+
const formatWithCommas = number => {
219+
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
220+
}
221+
210222
return (
211223
<div className="AppDetails">
212224
<Mobile />
@@ -234,7 +246,7 @@ class AppDetails extends Component {
234246
<div><span>{t("updated")}</span> {formattedUpdate}</div>
235247
<br />
236248
<div className="sideHeader">{t("downloadStats")}</div>
237-
<div><span>{t("count")}</span> {app_dls}</div>
249+
<div><span>{t("count")}</span> {app_dls === 0 && isWithinOneWeek(updated) ? "n/a" : formatWithCommas(app_dls)}</div>
238250
<div><span>md5</span><input className="md5text" defaultValue={md5} type="text" readonly></input></div>
239251
{shaBlock}
240252
</div>

src/AppList.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class AppList extends Component {
7373
doesSearchMatch(query = "", pkg = {}) {
7474
const { title, description, author } = pkg;
7575
const { showLegacy } = this.state;
76-
// skip if package category is legacy and they're disabled
76+
// skip if package category is legacy and legacy is disabled
7777
if (!showLegacy && pkg.category === "legacy") return false;
7878
const searchUs = [title, description, author];
7979
return searchUs.filter(a => a && a.toLowerCase().indexOf(query.toLowerCase()) >= 0).length > 0;
@@ -106,7 +106,10 @@ class AppList extends Component {
106106
(me.query);
107107
});
108108

109-
packages = packages.filter(pkg => me.doesSearchMatch(me.query, pkg));
109+
// filter packages if we have a search query only
110+
if (me.query) {
111+
packages = packages.filter(pkg => me.doesSearchMatch(me.query, pkg));
112+
}
110113

111114
me.setState({ packages, query: me.query });
112115
}

src/AppStatsChart.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const AppStatsChart = () => {
197197
// actual chart
198198
const chartInfo = (<div
199199
style={{
200-
width: '100%',
200+
width: '100%'
201201
}}>
202202
<LineChart
203203
width={800}
@@ -219,9 +219,11 @@ const AppStatsChart = () => {
219219
type = 'number'
220220
/>
221221
<YAxis />
222-
<Tooltip
222+
<Tooltip
223223
labelFormatter={(unixTime) => {
224-
return moment.unix(unixTime / 1000).format('MMM DD YYYY');
224+
return <span style={{color: "black"}}>
225+
{moment.unix(unixTime / 1000).format('MMM DD YYYY')}
226+
</span>
225227
}}
226228
/>
227229
<Legend />
@@ -252,31 +254,15 @@ const AppStatsChart = () => {
252254
}
253255
}
254256

255-
const darkStyles = {
256-
control: (provided, state) => ({
257-
...provided,
258-
backgroundColor: "black",
259-
color: "#000000",
260-
261-
}),
262-
option: (provided, state) => ({
263-
...provided,
264-
backgroundColor: 'black',
265-
})
266-
};
267-
268-
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)') && window.matchMedia('(prefers-color-scheme: dark)').matches;
269-
270257
const customStyle = {
271258
multiValue: (base, state) => ({
272259
...base,
273260
backgroundColor: state.data.color,
274-
}),
275-
...(isDarkMode ? darkStyles : {})
261+
})
276262
};
277263

278264
const maxOptions = 8; // gets a bit laggy after this, also we only have 8 colors
279-
const pkgSelector = <div style={{ width: 450 }}>
265+
const pkgSelector = <div style={{ width: 450, color: "black" }}>
280266
<Select
281267
styles={customStyle}
282268
isMulti={true}

0 commit comments

Comments
 (0)