Read the statement by Michael Teeuw here.
.resume() is executed whenever even with wrong lockString?
-
@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