Add a helper function to check if GUI is running in Scratch Desktop#4113
Add a helper function to check if GUI is running in Scratch Desktop#4113cwillisf merged 5 commits intoscratchfoundation:developfrom
Conversation
rschamp
left a comment
There was a problem hiding this comment.
Maybe this should just be a prop we pass in? This is a bit of guesswork and engineering for something we can tell GUI definitively. And Scratch Desktop can also pass in props like the one to disable the backpack.
|
@rschamp I'm cool with adding it as a prop but I'm not completely sure how to make it work. For example, how would you recommend handling the changes I made in If there's a good way to handle that then yeah, I'd definitely prefer an externally-driven approach! |
|
From discussion with @rschamp just now, the new plan is:
The tutorial deck filter will probably move out of Changes coming soon... |
|
I added |
This was intended as a safety check but it causes problems with some tests.
Resolves
Resolves scratchfoundation/scratch-desktop#12
Proposed Changes
This adds a function,
isScratchDesktop, which returnstruewhen run from inside Scratch Desktop (or any other Electron host) and false otherwise. This new function can be overridden manually by setting anoverridevalue, or by calling an associated function which can parsewindow.location.hrefto extract an override value if present.This change also includes an example of using
isScratchDesktopto exclude tutorial decks which require a project by ID, since those won't be possible to follow without an Internet connection.Reason for Changes
Scratch Desktop has some special requirements of the GUI, such as enabling or disabling certain features or labeling some menus and buttons differently.
I would just do this in my special scratch-desktop branch of scratch-gui, but I want to make the helper function available for #3964 and any other similar upcoming work.
Test Coverage
Currently the testing process is manual, but it's possible to test through the playground by adding
?isScratchDesktop=1to the playground URL.Browser Coverage
Check the OS/browser combinations tested (At least 2)
Mac
Windows
Chromebook
iPad
Android Tablet