Skip to content

Commit

Permalink
[MIRROR] Fixes features not updating when changing character slots (#568
Browse files Browse the repository at this point in the history
)

* Fixes features not updating when changing character slots (#81018)

## About The Pull Request

What it says on the tin. The entire bottom half of the prefs was not
updating on switching character slots.

~~We need to use the old hook here because it needs the key to
differentiate the active slot.~~

edit: useEffect can work in its stead here as mothblocks pointed out 👍 

## Why It's Good For The Game

Bugfix for a kind of serious issue for downstreams, not so much here
because there aren't really any text fields being used as features.

## Changelog

:cl:
fix: fixes features not updating when changing character slots
/:cl:

* Fixes features not updating when changing character slots

---------

Co-authored-by: Bloop <[email protected]>
  • Loading branch information
2 people authored and FFMirrorBot committed Jan 23, 2024
1 parent 17d9562 commit 5321ea3
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { sortBy, sortStrings } from 'common/collections';
import { BooleanLike, classes } from 'common/react';
import { ComponentType, createElement, ReactNode, useState } from 'react';
import {
ComponentType,
createElement,
ReactNode,
useEffect,
useState,
} from 'react';

import { sendAct, useBackend } from '../../../../backend';
import {
Expand Down Expand Up @@ -349,6 +355,10 @@ export const FeatureValueInput = (props: {
createSetPreference(props.act, props.featureId)(newValue);
};

useEffect(() => {
setPredictedValue(props.value);
}, [data.active_slot]);

return (
<ServerPreferencesFetcher
render={(serverData) => {
Expand Down

0 comments on commit 5321ea3

Please sign in to comment.