Skip to content

Conversation

mitchell-foote
Copy link
Contributor

Description

This adds two different macros that people have asked me for.

  1. addMultipleInventory - This allows FDs to programmatically add inventory outside of the starting simulator config inventory. If you've got a mission that has custom inventory, this'll help with a lot of that. The macro does some lookups after the fact to make sure it's being added to the correct simulator/rooms, but overall is still pretty slick.

  2. addRnDToSimulator - This allows a custom system to be added to the RnD queue. The Magellan team has asked for this to assist with their transition. This is a cheese easy macro, single field.

Related Issue

Screenshots (if appropriate):

Screenshot 2025-06-07 at 9 01 55 PM Screenshot 2025-06-07 at 10 05 18 PM
  • I submitted a pull request or created an issue for documenting this
    feature on the Thorium Docs
    repo. (Include the issue or pull request url below.)

}
pubsub.publish("systemsUpdate", App.systems);
};
App.on("addRnDToSimulator", ({ simulatorId, className, name, cb }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we could change this to be generic, where which is an option. That way this macro includes RnD and Engineering reports.

addExtraReportToSimulator is what I would call it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me! Updated!

}
extend type Mutation {
"""
Macro: Systems: Add RnD to Simulator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note above about making this generic. Also, be sure to include the word "Report" or "Damage" here.

});
console.log("baseInventorySelectionArray", baseInventorySelectionArray);
const filteredBaseInventorySelectionArray = baseInventorySelectionArray.filter((s) => (s?.inventoryAdded?.length || 0) > 0);
console.log("filteredBaseInventorySelectionArray", filteredBaseInventorySelectionArray);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console logs please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. Embarrassing. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

}, [apolloClient, selectedSimulatorId]);

useEffect(() => {
apolloClient && apolloClient.query({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting approach. Is there a reason useQuery doesn't work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! I just forgot that useQuery existed, and just stuck with the direct method instead of the react lifecycle version.

I did some research and switched it over to the useQuery version. Looks like that's the recommended way in this case. 👍

/>
</div>
<div style={{ display: "flex", flexDirection: "column", gap: "2px", width: '40px', height: "100%", alignSelf: "center" }}>
<button style={{ width: '40px', height: '40px' }} onClick={() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using unstyled buttons here instead of the standard UI buttons that are used everywhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I just looked nice and made the save button stand out. 😅 I'll do some styling with the reactstrap buttons and see if it looks better.

@mitchell-foote
Copy link
Contributor Author

Here's the updated UX for the inventory stuff

Screenshot 2025-06-09 at 5 32 03 PM

Copy link
Member

@alexanderson1993 alexanderson1993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much improved. It'd be great if you could get rid of more of those useEffects, though not strictly required. Feel free to merge when you're satisfied.

}
`);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna nitpick again. This requires two entire React render cycles

  • 1 cycle for useQuery to evaluate
  • 1 cycle for useEffect

Is there a specific reason you don't do this

const availableSimulators = simulatorsData?.simulators || [];

Likewise with decks

const decks = decksData?.decks || [];

(This also means replace useLazyQuery with useQuery and get rid of the unnecessary useEffect)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through and removed the extra state variables. 👍

}, [decks]);

// Initialize local state from args
useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another improvement - it's better to initialize state inside of useState, not with useEffect. Is it possible to rearrange things so all of this code is called inside the initializer function for the localInventorySelections useState?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through and tried to get this working, but ran into some issues. For now, I'm going to merge with the improvements. If we start seeing any issues with it, I'll go back and refactor. 👍

@mitchell-foote mitchell-foote merged commit 4fb8c82 into develop Jun 10, 2025
1 of 2 checks passed
@mitchell-foote mitchell-foote deleted the feature/additional-macros branch June 10, 2025 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants