Add SettingsUtil utility class
ClosedPublic

Authored by broulik on Sep 23 2019, 4:31 PM.

Details

Summary

For reading and writing of settings.
Promise-based API taking into account defaults values.
Also drop unused loadSettings callback in options page.

Test Plan
  • Settings page loads and write settings fine
  • Content script loads settings fine
  • Extension script loads settings fine and sends them to the host
  • Error propagates fine (e.g. reloaded extension while settings page was open and then tried to save settings)

Probably needs some Firefox ESR 60 testing to see whether it can deal with the class stuff...

Diff Detail

Repository
R856 Plasma Browser Integration
Lint
Lint Skipped
Unit
Unit Tests Skipped
broulik created this revision.Sep 23 2019, 4:31 PM
Restricted Application added a project: Plasma. · View Herald TranscriptSep 23 2019, 4:31 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik requested review of this revision.Sep 23 2019, 4:31 PM
broulik edited the summary of this revision. (Show Details)
broulik edited the test plan for this revision. (Show Details)
fvogt added a comment.Sep 23 2019, 5:04 PM

Probably needs some Firefox ESR 60 testing to see whether it can deal with the class stuff...

I can try if you'd like.

extension/options.js
137

This can be caught in SettingsUtils now

extension/utils.js
19

Wow, ES6 does indeed not support static members...

50

So on FF nothing using onChanged will actually work?

I can try if you'd like.

That would be appreciated.

extension/utils.js
19

Yeah... :/

50

Yes. The settings page actually sends a signal when the user changes something, which I might be able to catch... but this is for a later revision, I don't actually use the onChanged stuff just yet. The plan is mostly meant for some Schmankerl to have e.g. media controls turn on/off live, nothing essential.

broulik updated this revision to Diff 66690.Sep 23 2019, 5:29 PM
broulik edited the summary of this revision. (Show Details)
  • Drop changed stuff for now
  • Catch exception directly in get and reject

+1 but I couldn't test it (changed my distro recently and can't get pbi to work yet).

The js class is available in firefox since Firefox 45 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Browser_compatibility so it should work in firefox esr

fvogt accepted this revision.Sep 24 2019, 1:46 PM

Appears to work on ESR

This revision is now accepted and ready to land.Sep 24 2019, 1:46 PM
This revision was automatically updated to reflect the committed changes.