Read the statement by Michael Teeuw here.
(2.1.0, API) Revising the Show/Hide mechanism
-
Neither can I, but the moment we say that, someone will come up with a reason to need that. :)
-
Does this fit the use case?
ModuleA is configured to be hidden at 9am and shown at 6pm by ModuleB using a schedule.
At 9am ModuleB (the scheduler) hides ModuleA.
At 11am ModuleC (Remote Control) is used to show ModuleA.
At 11:30am ModuleC (Remote Control) is used to hide ModuleA.
At 6pm, ModuleB (the scheduler) shows ModuleA
Am I correct in thinking that without the force flag, neither ModuleB or ModuleC could show ModuleA at 11am or 6pm respectively?
-
Yeah, but I think that is the exact reason why this method should be implemented. One can argue what the desired result is. But by implementing the force option, both scenarios will be possible. Implementing a force function isn’t really a big deal.
Thanks for your input!
-
Agreed.
And perhaps best practice should be that any module wishing to show/hide other modules should include a config option to toggle the use of the force flag.
Let the user decide!
-
Agee! I’ll make sure to add that to the documentation.
-
Method is implemented. See documentation:
https://github.com/MichMich/MagicMirror/tree/develop/modules#thishidespeed-callback-options
https://github.com/MichMich/MagicMirror/tree/develop/modules#thisshowspeed-callback-options
https://github.com/MichMich/MagicMirror/tree/develop/modules#visibility-locking -
@MichMich Did you have any concerns about making this an opt-out instead of an opt-in? I.e. make the default options
{this.identifier}
instead of{}
. Or is there a specific reason against it? The overall concept seems reasonable, if we assume the meaning of thehide()
method always was to “keep this module hidden until I want it to reappear”.I do not think anyone does something like hiding module A from module B and then purposely showing module A again from module C. This is the only way I think of, which would make the default option using the modules identifier weird.
-
@Jopyth one way would be hide a module with the scheduler and show it again with the remote control or voice or something else
-
@Jopyth: The problem is that there is no way to find out which module requested the hide method. Therefor I can’t use that identifier by default. This must be provided by the module itself.
-
Oh, I see. My
this.identifier
would have been the identifier of the module to be hidden.