Load projects and initialize form with last project and task

This commit is contained in:
Manuel Bouza
2019-02-06 18:55:10 +01:00
parent 49aa36bf54
commit 7ad7cab5c0
16 changed files with 783 additions and 125 deletions

View File

@@ -1,11 +1,8 @@
import DomainCheck from "./services/DomainCheck"
import apiClient from "api/client"
import config from "./config"
apiClient.registerStorage(chrome.storage)
apiClient.setClientVersion(chrome.runtime.getManifest().version)
const domainCheck = new DomainCheck(config)
const { version } = chrome.runtime.getManifest()
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
// run only after the page is fully loaded
@@ -16,9 +13,16 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
const service = domainCheck.match(tab.url)
if (service) {
chrome.tabs.sendMessage(tabId, { type: "mountBubble", service }, () => {
console.log("bubble mounted")
})
chrome.storage.sync.get(
["subdomain", "apiKey"],
({ subdomain, apiKey }) => {
const settings = { subdomain, apiKey, version }
const payload = { service, settings }
chrome.tabs.sendMessage(tabId, { type: "mountBubble", payload }, () => {
console.log("bubble mounted")
})
}
)
} else {
chrome.tabs.sendMessage(tabId, { type: "unmountBubble" }, () => {
console.log("bubble unmounted")