Skip to content

Commit

Permalink
Fix objective selection, fix indicator style
Browse files Browse the repository at this point in the history
  • Loading branch information
miku448 committed Dec 12, 2024
1 parent 16fda45 commit 0cc2518
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

&__name-field {
flex: 2;
min-width: 203px;
}

&__type-color {
Expand All @@ -44,6 +45,7 @@

&__type-dropdown {
flex: 3;
min-width: 297px;
}

&__color,
Expand Down Expand Up @@ -83,8 +85,8 @@
&__color-picker-popover {
position: absolute;
z-index: 2;
top: 27px;
left: 37px;
left: -184px;
top: 100%;
background-color: $background-2;
padding: 0.75rem;
border-radius: 0.5rem;
Expand Down
4 changes: 2 additions & 2 deletions apps/interactor/src/libs/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const useFillTextTemplateFunction = () => {
const characters = useAppSelector((state) => state.novel.characters);
const userName = useAppSelector((state) => state.settings.user.name);
const scene = useAppSelector(selectCurrentScene);
return (text: string, characterId?: string) => {
return (text: string, characterId: string = scene?.characters[0]?.characterId || '') => {
return fillTextTemplate(text, {
user: userName,
bot: characterId ? characters.find(({ id }) => id === characterId)?.name || '' : characters[0]?.name || '',
bot: characters.find((char) => characterId === char.id)?.name || '',
characters: scene?.characters.reduce((prev, { characterId }) => {
prev[characterId] = characters.find(({ id }) => id === characterId)?.name || '';
return prev;
Expand Down
23 changes: 15 additions & 8 deletions apps/interactor/src/state/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,21 @@ export const selectAllParentDialoguesWhereCharactersArePresent = createSelector(
);

export const selectCurrentSceneObjectives = createSelector(
[(state: RootState) => state.objectives, selectCurrentScene],
(objectives, scene) => {
return objectives.filter(
(objective) =>
objective.stateCondition?.type === 'IN_SCENE' &&
(objective.stateCondition?.config?.sceneIds?.includes(scene?.id || '') ||
!objective.stateCondition?.config?.sceneIds?.length),
);
[
(state: RootState) => state.objectives,
selectCurrentScene,
(state: RootState) => state.novel.scenes,
(state: RootState) => state.settings.user.nsfw,
],
(objectives, scene, scenes, nsfw) => {
return objectives.filter((objective) => {
const sceneIds = objective.stateCondition?.config?.sceneIds || [];
const scenesFromObjectives = scenes.filter((scene) => sceneIds.includes(scene.id));
if (nsfw === NovelNSFW.NONE && scenesFromObjectives.some((scene) => scene.nsfw > NovelNSFW.NONE)) {
return false;
}
return objective.stateCondition?.type === 'IN_SCENE' && (sceneIds.includes(scene?.id || '') || !sceneIds.length);
});
},
);

Expand Down

0 comments on commit 0cc2518

Please sign in to comment.