fix and create constant setting for new words period
This commit is contained in:
parent
0a710fcc06
commit
ecb269cb85
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
import { Component } from "react";
|
import { Component } from "react";
|
||||||
import {
|
import {
|
||||||
|
capitalizeFirstLetter,
|
||||||
defaultTextOptions,
|
defaultTextOptions,
|
||||||
revertSpelling,
|
revertSpelling,
|
||||||
standardizePashto,
|
standardizePashto,
|
||||||
|
@ -73,6 +74,8 @@ import { searchAllInflections } from "./lib/search-all-inflections";
|
||||||
import { addToWordlist } from "./lib/wordlist-database";
|
import { addToWordlist } from "./lib/wordlist-database";
|
||||||
import ScriptToPhonetics from "./screens/ScriptToPhonetics";
|
import ScriptToPhonetics from "./screens/ScriptToPhonetics";
|
||||||
|
|
||||||
|
const newWordsPeriod: "week" | "month" = "month";
|
||||||
|
|
||||||
// to allow Moustrap key combos even when input fields are in focus
|
// to allow Moustrap key combos even when input fields are in focus
|
||||||
Mousetrap.prototype.stopCallback = function () {
|
Mousetrap.prototype.stopCallback = function () {
|
||||||
return false;
|
return false;
|
||||||
|
@ -203,7 +206,7 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
}
|
}
|
||||||
if (this.props.location.pathname === "/new-entries") {
|
if (this.props.location.pathname === "/new-entries") {
|
||||||
this.setState({
|
this.setState({
|
||||||
results: dictionary.getNewWords("week"),
|
results: dictionary.getNewWords(newWordsPeriod),
|
||||||
page: 1,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -335,7 +338,7 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
}
|
}
|
||||||
if (this.props.location.pathname === "/new-entries") {
|
if (this.props.location.pathname === "/new-entries") {
|
||||||
this.setState({
|
this.setState({
|
||||||
results: dictionary.getNewWords("week"),
|
results: dictionary.getNewWords(newWordsPeriod),
|
||||||
page: 1,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -647,7 +650,7 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
to="/new-entries"
|
to="/new-entries"
|
||||||
className="plain-link font-weight-light"
|
className="plain-link font-weight-light"
|
||||||
>
|
>
|
||||||
<div className="my-4">New words this week</div>
|
<div className="my-4">New words this {newWordsPeriod}</div>
|
||||||
</Link>
|
</Link>
|
||||||
<div className="my-4 pt-3">
|
<div className="my-4 pt-3">
|
||||||
<Link
|
<Link
|
||||||
|
@ -694,7 +697,9 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/new-entries">
|
<Route path="/new-entries">
|
||||||
<h4 className="mb-3">New Words This Month</h4>
|
<h4 className="mb-3">
|
||||||
|
New Words This {capitalizeFirstLetter(newWordsPeriod)}
|
||||||
|
</h4>
|
||||||
{this.state.results.length ? (
|
{this.state.results.length ? (
|
||||||
<Results
|
<Results
|
||||||
state={this.state}
|
state={this.state}
|
||||||
|
@ -702,7 +707,7 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
handleInflectionSearch={this.handleInflectionSearch}
|
handleInflectionSearch={this.handleInflectionSearch}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div>No new words added this month 😓</div>
|
<div>No new words added this {newWordsPeriod}</div>
|
||||||
)}
|
)}
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/account">
|
<Route path="/account">
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
import * as AT from "../types/account-types";
|
import * as AT from "../types/account-types";
|
||||||
|
|
||||||
export function objIsEqual(obj1: any, obj2: any): boolean {
|
export function objIsEqual(obj1: any, obj2: any): boolean {
|
||||||
if (!obj1 || !obj2) return false;
|
if (!obj1 || !obj2) return false;
|
||||||
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function userObjIsEqual(u1: AT.LingdocsUser | undefined, u2: AT.LingdocsUser | undefined): boolean {
|
export function userObjIsEqual(
|
||||||
if (!u1 || !u2) return false;
|
u1: AT.LingdocsUser | undefined,
|
||||||
function removeFrills(u: AT.LingdocsUser) {
|
u2: AT.LingdocsUser | undefined
|
||||||
if (!("_rev" in u)) return u;
|
): boolean {
|
||||||
const { lastActive, _rev, ...rest } = u;
|
if (!u1 || !u2) return false;
|
||||||
return rest;
|
function removeFrills(u: AT.LingdocsUser) {
|
||||||
}
|
if (!("_rev" in u)) return u;
|
||||||
return objIsEqual(removeFrills(u1), removeFrills(u2));
|
const { lastActive, _rev, ...rest } = u;
|
||||||
}
|
return rest;
|
||||||
|
}
|
||||||
|
return objIsEqual(removeFrills(u1), removeFrills(u2));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue