ICRAR / EAGLE

Editor for the Astronomical Graph Language Environment
GNU Lesser General Public License v3.0
0 stars 1 forks source link

EAGLE-1337: Fixed bug when loading graphs with no graph configs #756

Closed james-strauss-uwa closed 1 week ago

james-strauss-uwa commented 1 week ago

Fixed bug where code would try to set last graph config as active, even when no graph configs exist.

Now the code checks that at least one graph config exists. If none exist, then graph.activeGraphConfigId is set to undefined.

Summary by Sourcery

Bug Fixes:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

The PR fixes a bug in the graph loading logic by adding a check for empty graph configurations. When no graph configs exist, the code now explicitly sets the activeGraphConfigId to undefined instead of attempting to access a non-existent array element.

Updated class diagram for LogicalGraph

classDiagram
    class LogicalGraph {
        +activeGraphConfigId: GraphConfig.Id
        +graphConfigs(): GraphConfig[]
        +loadGraph(dataObject)
    }
    class GraphConfig {
        +getId(): Id
    }
    LogicalGraph --> GraphConfig
    note for LogicalGraph "Added check for empty graphConfigs array before setting activeGraphConfigId."

File-Level Changes

Change Details Files
Added null check for empty graph configurations
  • Added condition to check if graphConfigs array is empty
  • Set activeGraphConfigId to undefined when no configs exist
  • Wrapped existing last-config selection in else clause
src/LogicalGraph.ts

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).