@@ -31,7 +31,8 @@ import { api } from "@/api/api";
3131import { CharacterMenu } from "@/character/components/character-menu" ;
3232
3333export function DatabasePage ( ) {
34- const game = useGame ( ( state ) => state ) ;
34+ const { gameState, updateGameState } = useGame . getState ( ) ;
35+ const debugRevealCharacters = gameState . debug . revealCharacters ;
3536 const [ charactersPage , setCharactersPage ] = useState ( 1 ) ;
3637 const [ companiesPage , setCompaniesPage ] = useState ( 1 ) ;
3738 const [ characterSearch , setCharacterSearch ] = useState ( "" ) ;
@@ -41,12 +42,19 @@ export function DatabasePage() {
4142 const itemsPerPage = 50 ;
4243
4344 const filteredCharacters = useMemo ( ( ) => {
44- return game . gameState . characters . filter ( ( character ) => {
45+ return gameState . characters . filter ( ( character ) => {
46+ if (
47+ ! api . util . hasTag ( character , "known:character" ) &&
48+ debugRevealCharacters != true
49+ ) {
50+ return ;
51+ }
52+
4553 const searchLower = characterSearch . toLowerCase ( ) ;
4654 const fullName =
4755 `${ character . first_name } ${ character . last_name } ` . toLowerCase ( ) ;
4856 const company =
49- game . gameState . companies
57+ gameState . companies
5058 . find ( ( c ) => c . employees . some ( ( e ) => e . characterID === character . id ) )
5159 ?. name . toLowerCase ( ) || "" ;
5260
@@ -57,10 +65,15 @@ export function DatabasePage() {
5765 company . includes ( searchLower )
5866 ) ;
5967 } ) ;
60- } , [ game . gameState . characters , game . gameState . companies , characterSearch ] ) ;
68+ } , [
69+ gameState . characters ,
70+ gameState . companies ,
71+ characterSearch ,
72+ debugRevealCharacters ,
73+ ] ) ;
6174
6275 const filteredCompanies = useMemo ( ( ) => {
63- return game . gameState . companies . filter ( ( company ) => {
76+ return gameState . companies . filter ( ( company ) => {
6477 const searchLower = companySearch . toLowerCase ( ) ;
6578 const employeeNames = company . employees
6679 . map ( ( e ) => {
@@ -74,7 +87,7 @@ export function DatabasePage() {
7487 employeeNames . includes ( searchLower )
7588 ) ;
7689 } ) ;
77- } , [ game . gameState . companies , companySearch , game . gameState ] ) ;
90+ } , [ gameState . companies , companySearch , gameState ] ) ;
7891
7992 const paginateData = ( data , page ) => {
8093 const startIndex = ( page - 1 ) * itemsPerPage ;
@@ -168,17 +181,18 @@ export function DatabasePage() {
168181 </ div >
169182 < div className = "grid grid-cols-2 gap-4" >
170183 { charactersData . map ( ( character , index ) => {
171- const company = game . gameState . companies . find ( ( c ) =>
184+ const company = gameState . companies . find ( ( c ) =>
172185 c . employees . some ( ( e ) => e . characterID === character . id )
173186 ) ;
187+
174188 return (
175189 < Card key = { character . id } >
176190 < CardHeader >
177191 < div className = "flex justify-between items-center" >
178192 < CardTitle > { `${ character . first_name } ${
179193 character . last_name
180194 } ${
181- character . id == game . gameState . player_id ? " (you)" : ""
195+ character . id == gameState . player_id ? " (you)" : ""
182196 } `} </ CardTitle >
183197 < CharacterMenu character = { character } />
184198 </ div >
0 commit comments