Skip to content

Commit

Permalink
Janky updating
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay committed May 29, 2024
1 parent 36d2dc7 commit e075988
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fission/src/modals/spawning/ManageAssembliesModal.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import React, { RefObject, useEffect, useRef } from "react"
import React, { useReducer } from "react"
import Modal, { ModalPropsImpl } from "../../components/Modal"
import { FaPlus } from "react-icons/fa6"
import ScrollView from "@/components/ScrollView"
import Button from "@/components/Button";
import Label, { LabelSize } from "@/components/Label";
import World from "@/systems/World";
import MirabufSceneObject from "@/mirabuf/MirabufSceneObject";

interface AssemblyCardProps {
id: number;
update: React.DispatchWithoutAction;
}

const AssemblyCard: React.FC<AssemblyCardProps> = ({ id }) => {
const AssemblyCard: React.FC<AssemblyCardProps> = ({ id, update }) => {
return (
<div key={id} className="flex flex-row align-middle justify-between items-center bg-background rounded-sm p-2 gap-2">
<Label className="text-wrap break-all">{id}</Label>
<Button
value="Delete"
onClick={() => World.SceneRenderer.RemoveSceneObject(id)}
onClick={() => { World.SceneRenderer.RemoveSceneObject(id); update() }}
/>
</div>
)
Expand All @@ -27,6 +27,8 @@ const ManageAssembliesModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
// update tooltip based on type of drivetrain, receive message from Synthesis
// const { showTooltip } = useTooltipControlContext()

const [_, update] = useReducer((x) => !x, false)

const assemblies = [...World.SceneRenderer.sceneObjects.entries()].filter(x => { const y = (x[1] instanceof MirabufSceneObject); return y }).map(x => x[0])

return (
Expand All @@ -46,7 +48,7 @@ const ManageAssembliesModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
<div className="flex overflow-y-auto flex-col gap-2 min-w-[50vw] max-h-[60vh] bg-background-secondary rounded-md p-2">
<Label size={LabelSize.Medium} className="text-center border-b-[1pt] mt-[4pt] mb-[2pt] mx-[5%]">{assemblies ? `${assemblies.length} Assemblies` : 'No Assemblies'}</Label>
{
assemblies.map(x => AssemblyCard({id: x}))
assemblies.map(x => AssemblyCard({id: x, update: update}))
}
</div>
</Modal>
Expand Down

0 comments on commit e075988

Please sign in to comment.