From fa5861d7bb468e2c000b4c01dd47e15c1fab34a8 Mon Sep 17 00:00:00 2001 From: vocksel Date: Sat, 18 Nov 2023 16:21:00 -0800 Subject: [PATCH] Filter out storybooks in CoreGui (#220) # Problem When opening flipbook several warnings appear in the output from it attempting to load Roblox-created storybooks in CoreGui ``` 12:37:42.545 Failed to load storybook CoreGui.RobloxGui.Modules.VoiceChatPrompt.VoiceChatPrompt.storybook. Error: table expected, got nil - Edit - useStorybooks:40 12:37:42.545 Failed to load storybook CoreGui.RobloxGui.Modules.Settings.Settings.storybook. Error: table expected, got nil - Edit - useStorybooks:40 12:37:42.545 Failed to load storybook CoreGui.RobloxGui.Modules.InGameChat.BubbleChat.BubbleChat.storybook. Error: table expected, got nil - Edit - useStorybooks:40 12:37:42.545 Failed to load storybook CoreGui.RobloxGui.Modules.TopBar.TopBar.storybook. Error: table expected, got nil - Edit - useStorybooks:40 12:37:42.545 Failed to load storybook CoreGui.RobloxGui.Modules.ContactList.ContactList.storybook. Error: table expected, got nil - Edit - useStorybooks:40 ``` # Solution To fix this, I've updated `isStorybookModule` to return `false` for any storybook in CoreGui Closes #218 # Checklist - [x] Ran `./bin/test.sh` locally before merging --------- Co-authored-by: pashleyy <64950564+passhley@users.noreply.github.com> --- src/Story/isStorybookModule.lua | 6 +++++- src/Story/isStorybookModule.spec.lua | 12 ++++++++++++ wally.toml | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Story/isStorybookModule.lua b/src/Story/isStorybookModule.lua index 3c3610fe..e7bb3d9e 100644 --- a/src/Story/isStorybookModule.lua +++ b/src/Story/isStorybookModule.lua @@ -1,9 +1,13 @@ local flipbook = script:FindFirstAncestor("flipbook") +local CoreGui = game:GetService("CoreGui") + local constants = require(flipbook.constants) local function isStorybookModule(instance: Instance): boolean - return instance:IsA("ModuleScript") and instance.Name:match(constants.STORYBOOK_NAME_PATTERN) ~= nil + return instance:IsA("ModuleScript") + and instance.Name:match(constants.STORYBOOK_NAME_PATTERN) ~= nil + and not instance:IsDescendantOf(CoreGui) end return isStorybookModule diff --git a/src/Story/isStorybookModule.spec.lua b/src/Story/isStorybookModule.spec.lua index 1fae9f14..92eb022d 100644 --- a/src/Story/isStorybookModule.spec.lua +++ b/src/Story/isStorybookModule.spec.lua @@ -1,4 +1,6 @@ return function() + local CoreGui = game:GetService("CoreGui") + local isStorybookModule = require(script.Parent.isStorybookModule) it("should return true for ModuleScripts with the .storybook extension", function() @@ -28,4 +30,14 @@ return function() expect(isStorybookModule(storybook)).to.equal(false) end) + + it("should return false for storybooks in CoreGui", function() + local storybook = Instance.new("ModuleScript") + storybook.Name = "Foo.storybook" + storybook.Parent = CoreGui + + expect(isStorybookModule(storybook)).to.equal(false) + + storybook:Destroy() + end) end diff --git a/wally.toml b/wally.toml index 34f3b101..ecc1a169 100644 --- a/wally.toml +++ b/wally.toml @@ -9,7 +9,7 @@ exclude = ["*"] [dependencies] Roact = "roblox/roact@1.4.4" React = "jsdotlua/react@17.0.2" -ReactRoblox = "jsdotlua/react-roblox@17.0.1" +ReactRoblox = "jsdotlua/react-roblox@17.0.2" Sift = "csqrl/sift@0.0.4" t = "osyrisrblx/t@3.0.0" ModuleLoader = "flipbook-labs/module-loader@0.6.1"