From 5532b81285ef5d02e274eb590b6074f232c415b8 Mon Sep 17 00:00:00 2001 From: phyzical Date: Mon, 21 Mar 2022 20:13:28 +0800 Subject: [PATCH 1/3] add similar sort to the faction invite list --- src/Faction/ui/FactionsRoot.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Faction/ui/FactionsRoot.tsx b/src/Faction/ui/FactionsRoot.tsx index 45e750232..ccd57d556 100644 --- a/src/Faction/ui/FactionsRoot.tsx +++ b/src/Faction/ui/FactionsRoot.tsx @@ -79,6 +79,9 @@ export function FactionsRoot(props: IProps): React.ReactElement { (augmentation: string) => !player.hasAugmentation(augmentation) ).length; } + let allJoinedFactions = props.player.factions + allJoinedFactions = allJoinedFactions.sort((a, b) => + allJoinedFactions.indexOf(a) - allJoinedFactions.indexOf(b)); return ( @@ -92,11 +95,11 @@ export function FactionsRoot(props: IProps): React.ReactElement { Factions you have joined: - {(props.player.factions.length > 0 && ( + {(allJoinedFactions.length > 0 && ( - {props.player.factions.map((faction: string) => ( + {allJoinedFactions.map((faction: string) => ( From 796881f35d63f8374cac37f559b2ca97c7bdfbf0 Mon Sep 17 00:00:00 2001 From: phyzical Date: Mon, 21 Mar 2022 21:23:34 +0800 Subject: [PATCH 2/3] fix the correct base point for sorting --- src/Faction/ui/FactionsRoot.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Faction/ui/FactionsRoot.tsx b/src/Faction/ui/FactionsRoot.tsx index ccd57d556..46bfdf5e2 100644 --- a/src/Faction/ui/FactionsRoot.tsx +++ b/src/Faction/ui/FactionsRoot.tsx @@ -19,6 +19,7 @@ import { IRouter } from "../../ui/Router"; import { Faction } from "../Faction"; import { joinFaction } from "../FactionHelpers"; import { Factions } from "../Factions"; +import { FactionNames } from "../data/FactionNames"; export const InvitationsSeen: string[] = []; @@ -79,9 +80,10 @@ export function FactionsRoot(props: IProps): React.ReactElement { (augmentation: string) => !player.hasAugmentation(augmentation) ).length; } - let allJoinedFactions = props.player.factions - allJoinedFactions = allJoinedFactions.sort((a, b) => - allJoinedFactions.indexOf(a) - allJoinedFactions.indexOf(b)); + + const allFactions = Object.values(FactionNames).map(faction => faction as string) + const allJoinedFactions = props.player.factions.sort((a, b) => + allFactions.indexOf(a) - allFactions.indexOf(b)); return ( From 4c862ef313ed445d081346f914a1ee8f10d19cfe Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 21 Mar 2022 23:11:04 +0800 Subject: [PATCH 3/3] Update src/Faction/ui/FactionsRoot.tsx --- src/Faction/ui/FactionsRoot.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Faction/ui/FactionsRoot.tsx b/src/Faction/ui/FactionsRoot.tsx index 46bfdf5e2..4d2ccc367 100644 --- a/src/Faction/ui/FactionsRoot.tsx +++ b/src/Faction/ui/FactionsRoot.tsx @@ -82,7 +82,8 @@ export function FactionsRoot(props: IProps): React.ReactElement { } const allFactions = Object.values(FactionNames).map(faction => faction as string) - const allJoinedFactions = props.player.factions.sort((a, b) => + const allJoinedFactions = props.player.factions.slice(0); + allJoinedFactions.sort((a, b) => allFactions.indexOf(a) - allFactions.indexOf(b)); return (