adding dev files to master
adding all the dev files, package, webpack etc, including build which will contain minified release
This commit is contained in:
38
src/background/Setup.js
Normal file
38
src/background/Setup.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import PersistentSyncStorage from '../helpers/PersistentSyncStorage';
|
||||
import CONFIG from '../config';
|
||||
|
||||
const ensure = () => {
|
||||
return new Promise((res, rej) => {
|
||||
|
||||
// Resolves if setup is complete
|
||||
if(PersistentSyncStorage.data.setupComplete) {
|
||||
// Ensure new options (on extension update) are added to options object
|
||||
PersistentSyncStorage.set({
|
||||
options: Object.assign({}, CONFIG.defaultOptions, PersistentSyncStorage.data.options)
|
||||
});
|
||||
|
||||
return res();
|
||||
}
|
||||
|
||||
// Otherwise inits setup
|
||||
const onSetupComplete = (request, sender, sendResponse) => {
|
||||
if(request.name === 'setupComplete') {
|
||||
chrome.runtime.onMessage.removeListener(onSetupComplete);
|
||||
|
||||
PersistentSyncStorage.set({
|
||||
setupComplete: true
|
||||
});
|
||||
|
||||
res();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
chrome.tabs.create({ url: './html/welcome.html' });
|
||||
chrome.runtime.onMessage.addListener(onSetupComplete);
|
||||
console.log('Setup Complete');
|
||||
});
|
||||
};
|
||||
|
||||
export default {ensure};
|
||||
27
src/background/index.js
Normal file
27
src/background/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import PersistentSyncStorage from 'src/helpers/PersistentSyncStorage';
|
||||
|
||||
import Setup from './Setup';
|
||||
|
||||
import CONFIG from 'src/config';
|
||||
|
||||
class Main {
|
||||
constructor() {
|
||||
this.init = this.init.bind(this);
|
||||
|
||||
PersistentSyncStorage.on('ready', () => {
|
||||
this.setupOptions();
|
||||
Setup.ensure().then(this.init);
|
||||
});
|
||||
}
|
||||
|
||||
init() {}
|
||||
|
||||
setupOptions() {
|
||||
// Ensure options store is setup
|
||||
if(!PersistentSyncStorage.has('options')) {
|
||||
PersistentSyncStorage.set({ options: CONFIG.defaultOptions });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const main = new Main();
|
||||
Reference in New Issue
Block a user