MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    .resume() is executed whenever even with wrong lockString?

    Scheduled Pinned Locked Moved Development
    10 Posts 3 Posters 1.1k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      sdetweil @Guest
      last edited by sdetweil

      @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)

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @Guest
        last edited by

        @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

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        ? 1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User @sdetweil
          last edited by

          @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 called test1.show() 5 times, and test1.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.

          S 3 Replies Last reply Reply Quote 0
          • S Offline
            sdetweil @Guest
            last edited by

            @Sean in module1, what is this.hidden?

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            ? 1 Reply Last reply Reply Quote 0
            • ? Offline
              A Former User @sdetweil
              last edited by

              @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.)

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @Guest
                last edited by

                @Sean thanks. Forgot these attributes

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @Guest
                  last edited by

                  @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);
                  	}
                  

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @Guest
                    last edited by

                    @Sean i see they have developed and accepted a fix for this. for next release

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • ? Offline
                      A Former User
                      last edited by

                      Yes. I fix it with @eouia

                      1 Reply Last reply Reply Quote 1
                      • 1 / 1
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy