+
{children}
)
diff --git a/src/App/Views/Wiki/Wiki.tsx b/src/App/Views/Wiki/Wiki.tsx
index ecc71ef3..330e7825 100644
--- a/src/App/Views/Wiki/Wiki.tsx
+++ b/src/App/Views/Wiki/Wiki.tsx
@@ -5,6 +5,7 @@ import { Just, Maybe, maybe, Nothing } from "../../../Data/Maybe";
import { Record } from "../../../Data/Record";
import { WikiInfoContainer } from "../../Containers/WikiInfoContainer";
import { CultureCombined } from "../../Models/View/CultureCombined";
+import { DropdownOption } from "../../Models/View/DropdownOption";
import { ProfessionCombined } from "../../Models/View/ProfessionCombined";
import { RaceCombined } from "../../Models/View/RaceCombined";
import { Advantage } from "../../Models/Wiki/Advantage";
@@ -22,7 +23,7 @@ import { InlineWikiEntry } from "../../Models/Wiki/wikiTypeHelpers";
import { translate } from "../../Utilities/I18n";
import { pipe } from "../../Utilities/pipe";
import { sortRecordsByName } from "../../Utilities/sortBy";
-import { Dropdown, DropdownOption } from "../Universal/Dropdown";
+import { Dropdown } from "../Universal/Dropdown";
import { ListPlaceholder } from "../Universal/ListPlaceholder";
import { MainContent } from "../Universal/MainContent";
import { Options } from "../Universal/Options";
@@ -77,13 +78,13 @@ export interface WikiDispatchProps {
setItemTemplatesGroup (group: Maybe
): void
}
-export type WikiProps = WikiStateProps & WikiDispatchProps & WikiOwnProps
+type Props = WikiStateProps & WikiDispatchProps & WikiOwnProps
export interface WikiState {
infoId: Maybe
}
-export const Wiki: React.FC = props => {
+export const Wiki: React.FC = props => {
const {
category: maybeCategory,
filterText,
@@ -109,7 +110,7 @@ export const Wiki: React.FC = props => {
...other
} = props
- const [infoId, setInfoId] = React.useState> (Nothing)
+ const [ infoId, setInfoId ] = React.useState> (Nothing)
const mxs: Maybe> =
fmapF (maybeCategory) (category => other[category as keyof WikiTabLists])
@@ -117,7 +118,7 @@ export const Wiki: React.FC = props => {
const handleShowInfo =
React.useCallback (
(id: string) => setInfoId (Just (id)),
- [setInfoId]
+ [ setInfoId ]
)
return (
diff --git a/src/App/Views/Wiki/WikiList.tsx b/src/App/Views/Wiki/WikiList.tsx
index d3c9db6b..c2a48904 100644
--- a/src/App/Views/Wiki/WikiList.tsx
+++ b/src/App/Views/Wiki/WikiList.tsx
@@ -16,91 +16,138 @@ import { getNameBySex, getNameBySexM } from "../../Utilities/rcpUtils";
import { ListView } from "../Universal/List";
import { WikiListItem } from "./WikiListItem";
-export interface WikiListProps {
+interface Props {
list: List
sex?: Sex
currentInfoId: Maybe
showInfo (id: string): void
}
-export class WikiList extends React.Component {
- shouldComponentUpdate (nextProps: WikiListProps) {
- return nextProps.list !== this.props.list
- || nextProps.sex !== this.props.sex
- || nextProps.currentInfoId !== this.props.currentInfoId
- }
+const WikiList: React.FC = ({ list, sex = "m", currentInfoId, showInfo }) => (
+
+ {pipe_ (
+ list,
+ map (x => {
+ if (RaceCombined.is (x)) {
+ const id = RaceCombinedA_.id (x)
+ const name = getNameBySex (sex) (RaceCombinedA_.name (x))
- render () {
- const { list, sex = "m" } = this.props
+ return (
+
+ )
+ }
+ else if (CultureCombined.is (x)) {
+ const id = CultureCombinedA_.id (x)
+ const name = CultureCombinedA_.name (x)
- return (
-
- {pipe_ (
- list,
- map (x => {
- if (RaceCombined.is (x)) {
- const id = RaceCombinedA_.id (x)
- const name = getNameBySex (sex) (RaceCombinedA_.name (x))
+ return (
+
+ )
+ }
+ else if (ProfessionCombined.is (x)) {
+ const id = ProfessionCombinedA_.id (x)
+ const name = getNameBySex (sex) (ProfessionCombinedA_.name (x))
+ const msubname = getNameBySexM (sex) (ProfessionCombinedA_.subname (x))
- return
- }
- else if (CultureCombined.is (x)) {
- const id = CultureCombinedA_.id (x)
- const name = CultureCombinedA_.name (x)
+ return (
+ `${name} (${subname})`) (msubname)}
+ currentInfoId={currentInfoId}
+ showInfo={showInfo}
+ />
+ )
+ }
+ else {
+ const id = SpecialAbility.AL.id (x)
- return
- }
- else if (ProfessionCombined.is (x)) {
- const id = ProfessionCombinedA_.id (x)
- const name = getNameBySex (sex) (ProfessionCombinedA_.name (x))
- const msubname = getNameBySexM (sex) (ProfessionCombinedA_.subname (x))
+ if (SpecialAbility.is (x)) {
+ const name = addLevelToName (fromMaybe (SpecialAbility.A.name (x))
+ (SpecialAbility.A.nameInWiki (x)))
+ (SpecialAbility.A.tiers (x))
- return (
- `${name} (${subname})`) (msubname)}
- />
- )
- }
- else {
- const id = SpecialAbility.AL.id (x)
+ return (
+
+ )
+ }
+ else if (Advantage.is (x)) {
+ const name = addLevelToName (Advantage.A.name (x))
+ (Advantage.A.tiers (x))
- if (SpecialAbility.is (x)) {
- const name = addLevelToName (fromMaybe (SpecialAbility.A.name (x))
- (SpecialAbility.A.nameInWiki (x)))
- (SpecialAbility.A.tiers (x))
+ return (
+
+ )
+ }
+ else if (Disadvantage.is (x)) {
+ const name = addLevelToName (Disadvantage.A.name (x))
+ (Disadvantage.A.tiers (x))
- return
- }
- else if (Advantage.is (x)) {
- const name = addLevelToName (Advantage.A.name (x))
- (Advantage.A.tiers (x))
+ return (
+
+ )
+ }
+ else {
+ const name = Skill.AL.name (x)
- return
- }
- else if (Disadvantage.is (x)) {
- const name = addLevelToName (Disadvantage.A.name (x))
- (Disadvantage.A.tiers (x))
-
- return
- }
- else {
- const name = Skill.AL.name (x)
-
- return
- }
- }
- }),
- toArray
- )}
-
- )
- }
-}
+ return (
+
+ )
+ }
+ }
+ }),
+ toArray
+ )}
+
+)
const addLevelToName =
(name: string) =>
(mlevel: Maybe) =>
maybe (name) ((level: number) => `${name} I-${toRoman (level)}`) (mlevel)
+
+const MemoWikiList = React.memo (
+ WikiList,
+ (prevProps, nextProps) =>
+ nextProps.list !== prevProps.list
+ || nextProps.sex !== prevProps.sex
+ || nextProps.currentInfoId !== prevProps.currentInfoId
+)
+
+export { MemoWikiList as WikiList };
diff --git a/src/App/Views/Wiki/WikiListItem.tsx b/src/App/Views/Wiki/WikiListItem.tsx
index f399e6a0..9162f158 100644
--- a/src/App/Views/Wiki/WikiListItem.tsx
+++ b/src/App/Views/Wiki/WikiListItem.tsx
@@ -4,33 +4,35 @@ import { ListItem } from "../Universal/ListItem";
import { ListItemName } from "../Universal/ListItemName";
import { ListItemSeparator } from "../Universal/ListItemSeparator";
-export interface WikiListItemProps {
+interface Props {
id: string
name: string
currentInfoId: Maybe
showInfo (id: string): void
}
-export class WikiListItem extends React.Component {
- shouldComponentUpdate (nextProps: WikiListItemProps) {
- const nextActive = Maybe.elem (nextProps.id) (nextProps.currentInfoId)
- const active = Maybe.elem (this.props.id) (this.props.currentInfoId)
+const WikiListItem: React.FC = ({ id, name, currentInfoId, showInfo }) => {
+ const handleShow = React.useCallback (
+ () => showInfo (id),
+ [ id, showInfo ]
+ )
- return nextActive !== active
- }
-
- render () {
- const { id, name, currentInfoId, showInfo } = this.props
-
- return (
- showInfo (id)}
- >
-
-
-
- )
- }
+ return (
+
+
+
+
+ )
}
+
+const MemoWikiListItem = React.memo (
+ WikiListItem,
+ (prevProps, nextProps) => Maybe.elem (nextProps.id) (nextProps.currentInfoId)
+ !== Maybe.elem (prevProps.id) (prevProps.currentInfoId)
+)
+
+export { MemoWikiListItem as WikiListItem };