-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor options storage #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hrrrrrrrrrrrm
mv web_extension/shared/version.js.dev web_extension/shared/version.js | ||
} | ||
|
||
trap restore_version EXIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wat
|
||
cat << JS > web_extension/shared/version.js | ||
// this file automatically updated at build time by bin/package | ||
class Version { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Version {
static number = "v$version"
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs say static properties must declared outside the class. Because reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel yo
Version.number = "v$version" | ||
JS | ||
|
||
pushd web_extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to think of switching directories as a stack more than just cd -
'ing
'use strict'; | ||
|
||
async function fetchImage() { | ||
let feed_url = options.feed.url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a lot of these could be const
'd
document.querySelector('info by-line').appendChild( link(item.author.url, item.author.name) ) | ||
document.querySelector('info venue').appendChild( link(item._meta.venue.url, item._meta.venue.name) ) | ||
document.querySelector('info name').appendChild( | ||
Builder.link(item.external_url, item.content_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm highly skeptical but also at this rate you'll have re-invented react or something soon 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too heavyweight. Unfortunately the innerHTML = template
thing doesn't work because it's not safe and things
let hideIfChecked = (checkboxes, toggled_control) => { | ||
let visible = false | ||
checkboxes = [].concat(checkboxes) | ||
checkboxes.forEach(function(box_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stylistically, you're mixing arrow functions with non-arrows ¯\_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a truth. I learned how to arrow things this morning...
} | ||
|
||
async function read_storage(){ | ||
current_storage = await browser.storage.sync.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is current_storage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just here..in the function...I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ಠ_ಠ
web_extension/shared/options.js
Outdated
} | ||
|
||
async read () { | ||
let promise = browser.storage.sync.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let promise = browser.storage.sync.get() | |
const stored_options = await browser.storage.sync.get() | |
[...] | |
return stored_options |
but also is it .sync
if its returning a promise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it this way because I want to return the promise up the chain, so I can await it elsewhere. I had a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the deceptively named .sync is for configuration which is sync'd by the firefox browser
this.clock_persistence = "Subtle" | ||
this.info_persistence = "Subtle" | ||
this.clock_flash = false | ||
this.date_format = "good" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<_<
class FeedOptions extends OptionsSubset { | ||
constructor () { | ||
super() | ||
this.url = "https://robacarp.github.io/photographic_start/feed.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make this an option too! 🎉 🐠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#someday
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well technically, it is an option now. You just have to devtools it to change it. But whatever is stored in the browser.sync storage will prevail.
a29aeac
to
c0c82b0
Compare
No description provided.