diff --git a/website/src/App.tsx b/website/src/App.tsx index 94dfb0c..35fdf46 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -11,6 +11,7 @@ import { Component } from "react"; import { + capitalizeFirstLetter, defaultTextOptions, revertSpelling, standardizePashto, @@ -73,6 +74,8 @@ import { searchAllInflections } from "./lib/search-all-inflections"; import { addToWordlist } from "./lib/wordlist-database"; import ScriptToPhonetics from "./screens/ScriptToPhonetics"; +const newWordsPeriod: "week" | "month" = "month"; + // to allow Moustrap key combos even when input fields are in focus Mousetrap.prototype.stopCallback = function () { return false; @@ -203,7 +206,7 @@ class App extends Component { } if (this.props.location.pathname === "/new-entries") { this.setState({ - results: dictionary.getNewWords("week"), + results: dictionary.getNewWords(newWordsPeriod), page: 1, }); } @@ -335,7 +338,7 @@ class App extends Component { } if (this.props.location.pathname === "/new-entries") { this.setState({ - results: dictionary.getNewWords("week"), + results: dictionary.getNewWords(newWordsPeriod), page: 1, }); } @@ -647,7 +650,7 @@ class App extends Component { to="/new-entries" className="plain-link font-weight-light" > -
New words this week
+
New words this {newWordsPeriod}
{ /> -

New Words This Month

+

+ New Words This {capitalizeFirstLetter(newWordsPeriod)} +

{this.state.results.length ? ( { handleInflectionSearch={this.handleInflectionSearch} /> ) : ( -
No new words added this month 😓
+
No new words added this {newWordsPeriod}
)}
diff --git a/website/src/lib/misc-helpers.ts b/website/src/lib/misc-helpers.ts index a5931cb..8370f7a 100644 --- a/website/src/lib/misc-helpers.ts +++ b/website/src/lib/misc-helpers.ts @@ -1,16 +1,19 @@ import * as AT from "../types/account-types"; export function objIsEqual(obj1: any, obj2: any): boolean { - if (!obj1 || !obj2) return false; - return JSON.stringify(obj1) === JSON.stringify(obj2); + if (!obj1 || !obj2) return false; + return JSON.stringify(obj1) === JSON.stringify(obj2); } -export function userObjIsEqual(u1: AT.LingdocsUser | undefined, u2: AT.LingdocsUser | undefined): boolean { - if (!u1 || !u2) return false; - function removeFrills(u: AT.LingdocsUser) { - if (!("_rev" in u)) return u; - const { lastActive, _rev, ...rest } = u; - return rest; - } - return objIsEqual(removeFrills(u1), removeFrills(u2)); -} \ No newline at end of file +export function userObjIsEqual( + u1: AT.LingdocsUser | undefined, + u2: AT.LingdocsUser | undefined +): boolean { + if (!u1 || !u2) return false; + function removeFrills(u: AT.LingdocsUser) { + if (!("_rev" in u)) return u; + const { lastActive, _rev, ...rest } = u; + return rest; + } + return objIsEqual(removeFrills(u1), removeFrills(u2)); +}