offline-qr-code icon indicating copy to clipboard operation
offline-qr-code copied to clipboard

Radio options not correctly reset when reset button is pressed

Open rugk opened this issue 6 years ago • 18 comments

STR:

  1. Go to options.
  2. Change some radio options (qr code size or type)
  3. Click "reset".

What happens: Old setting is still displayed.

What should happen: Reset this option, too.

(discovered in https://github.com/rugk/offline-qr-code/commit/918e423b25dec4624acda2393579b673e3324632, may be there in other versions, too)

rugk avatar May 18 '18 22:05 rugk

I will work on this, forked the repo, however, I am contributing for the first time.

TauseefMalik avatar Jun 18 '18 10:06 TauseefMalik

Okay, note that this may not be an easy issue (I have not looked into it, but some debugging skills may be required). If you have any questions feel free to ask.

rugk avatar Jun 18 '18 13:06 rugk

So only QR code type and size properties are not reset. High level debugging revealed that QR code type has not handling in apply option. And the size has to be handled for all conditions.

TauseefMalik avatar Jun 19 '18 20:06 TauseefMalik

Need a bit more understanding on the approach for resetting. I see there is a constant object for default values but applyOptionLive method utilize that in case of reset.

TauseefMalik avatar Jun 19 '18 20:06 TauseefMalik

Need a bit more understanding on the approach for resetting.

Speaking on a high level the resetting works like this:

  • backup old settings for restoring them
  • deletes all settings from storage
  • fetches new default settings (indirectly from that object you've mentioned AFAIK) and applies them as if they had been re-loaded

applyOptionLive does not directly relate to resetting, but could be a culprit/mess some things up, indeed. As the JSdoc hopefully explains (:wink:) it just applies some special features of custom options (such as disabling the input field of the qr code size when the option is not selected).

rugk avatar Jun 19 '18 21:06 rugk

You can also try to look which commit introduced that behaviour, but I am not sure whether this is helpful…

rugk avatar Jun 19 '18 21:06 rugk

@rugk I do have an idea about code changes to be done. But I have never worked on extensions so I looked in contributing.md and tried editing src in add-on debugger (which doesn't allow edit). Can you please guide me with that?

TauseefMalik avatar Jun 22 '18 19:06 TauseefMalik

Actually the Contributing.md has a small part for getting starting. I guess you checked that out already. So for testing/changing things, you actually need to modify the source code in any text/file editor/IDE outside of the browser and reload the add-on.

rugk avatar Jun 22 '18 19:06 rugk

I have installed the addon from the store. I haven’t generated it using make.sh So I suppose I need to build and install that addon?

TauseefMalik avatar Jun 22 '18 20:06 TauseefMalik

You don't need to run any build script. You can load the add-on instantly, you just have to clone the repo here and you can load the manifest.json directly. How to do that is explained here.

rugk avatar Jun 22 '18 20:06 rugk

@TauseefMalik Any progress, do you need any help ?

OogieBoogieInJSON avatar Jul 10 '18 20:07 OogieBoogieInJSON

@OogieBoogieInJSON I was able to get to the cause however kinda packed up with other work. I will continue to work on it this weekend!

TauseefMalik avatar Jul 12 '18 15:07 TauseefMalik

If you can describe it in a compact way, it would certainly also not hurt to describe the cause in this issue, even if you have not a PR ready yet. :wink: (So others could confirm/pick it up, even if you do implement it or so, but well… if you fix it anyway) So srsly, it does not matter if you really just get to it this weekend. We are not in hurry… :wink:

rugk avatar Jul 12 '18 19:07 rugk

@OogieBoogieInJSON Take a close look at ApplyLive() method. It is being called while setting custom options & resetting to default options. It is missing a handler for 'qrcodesize' and 'qrcodetype'. Therefore, other options reset to default just fine but these two don't reflect the change on reset.

TauseefMalik avatar Jul 15 '18 13:07 TauseefMalik

Might be the culprit, but actually the applyOptionLive() method should only apply custom stuff of options, i.e. not every option needs to be defined there just to be saved/reset. I've explained that high-level stuff above, already.

FYI I've seen the JSDOC for this method is bad, I'll improve it.

rugk avatar Jul 15 '18 14:07 rugk

@TauseefMalik BTW, can you still reproduce this with the latest version? Note we now have proper unit tests for all used (TinyWebExt) modules and they are also properly implemented.

rugk avatar Jan 22 '19 20:01 rugk

I suspect https://github.com/rugk/offline-qr-code/issues/180 could fix this issue. Needs verification though… :smiley:

rugk avatar Apr 16 '19 09:04 rugk

Result: Still fails. Also when updating AddonSettings and AutomaticSettings modules, the initial reset now works, but when I press "Undo", it does not correctly reset the options to their previous values…

rugk avatar May 11 '19 08:05 rugk