Read the statement by Michael Teeuw here.
.resume() is executed whenever even with wrong lockString?
-
@Sean I am not near my system at the moment, but I would examine the core mm code in js/module.js and js/main,js the actual worker)
-
@Sean said in .resume() is executed whenever even with wrong lockString?:
myTimer.resume()
i always keep my own state flag… once hidden (1st time) I don’t do what hide says… same for show…
main.js/showmodule does this
// remove lockString if set in options. if (options.lockString) { var index = module.lockStrings.indexOf(options.lockString); if ( index !== -1) { module.lockStrings.splice(index, 1); } } // Check if there are no more lockstrings set, or the force option is set. // Otherwise cancel show action. if (module.lockStrings.length !== 0 && options.force !== true) { Log.log("Will not show " + module.name + ". LockStrings active: " + module.lockStrings.join(",")); return; } module.hidden = false; // If forced show, clean current lockstrings. if (module.lockStrings.length !== 0 && options.force === true) { Log.log("Force show of module: " + module.name); module.lockStrings = []; }
it does not check if shown already… only if lockstrings exist does it reject show
-
@sdetweil
Here is my test.module:test1
Module.register("test1", { start: function(){ this.showing = true }, suspend: function () { console.log("@stop", this.lockStrings, this.hidden) this.showing = false }, resume: function() { console.log("@resume", this.lockStrings, this.hidden) this.showing = true }, })
module:test2
Module.register("test2", { notificationReceived: function(noti, payload, sender) { if (noti == "DOM_OBJECTS_CREATED") { this.test() } }, test: function() { const asleep = async (ms) => { return new Promise(resolve => setTimeout(resolve, ms)) } var target = null MM.getModules().enumerate((m)=>{ if (m.name == "test1") target = m }) const scenario = async () => { await asleep(1000) console.log("1. Try to show when target is revealed already") target.show() await asleep(1000) console.log("2. Try to hide with lockString 'abcd'") target.hide(0, {lockString:'abcd'}) await asleep(1000) console.log("3. Try to show with wrong lockString '1234'") target.show(0, {lockString:'1234'}) await asleep(1000) console.log("4. Try to show with right lockString 'abcd'") target.show(0, {lockString:'abcd'}) await asleep(1000) console.log("5. Try to hide twice (lockString 'a', 'b')") target.hide(0, {lockString:'a'}) await asleep(500) target.hide(0, {lockString:'b'}) await asleep(1000) console.log("6. Try to unlock once. module will not be shown.") target.show(0, {lockString:'b'}) await asleep(1000) console.log("7. Try to unlock once more. now module will be shown.") target.show(0, {lockString:'a'}) } scenario() } })
The result is;
As you see,
.resume()
is always called. (@ resume , current lockStrings, current hidden
would be logged when it is called)
test2
calledtest1.show()
5 times, andtest1.resume()
would be executed 5 times regardless of context.So, What can I do with this
.resume()
? It is useless except counting how many times.show()
is called.
It might not be a bug, but probably out-of-sense. -
@Sean in module1, what is this.hidden?
-
@sdetweil said in .resume() is executed whenever even with wrong lockString?:
@Sean in module1, what is this.hidden?
https://github.com/MichMich/MagicMirror/blob/master/modules/README.md#available-module-instance-properties
It’s one of default module attributes. (But in this case, useless.) -
@Sean thanks. Forgot these attributes
-
@Sean I reported the bug in your issue
show: function (speed, callback, options) { if (typeof callback === "object") { options = callback; callback = function () { }; } callback = callback || function () { }; options = options || {}; this.resume(); // < --- should not be done, MM.showModule will call back if allowed MM.showModule(this, speed, callback, options); }
-
@Sean i see they have developed and accepted a fix for this. for next release
-
Yes. I fix it with @eouia