Show activity form in popup after timer was stoped
This commit is contained in:
@@ -118,8 +118,8 @@ html {
|
||||
background-color: $red;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
|
||||
@@ -2,13 +2,14 @@ import "@babel/polyfill"
|
||||
import ApiClient from "api/Client"
|
||||
import { isChrome, getCurrentTab, getSettings, isBrowserTab } from "utils/browser"
|
||||
import { BackgroundMessenger } from "utils/messaging"
|
||||
import { tabUpdated, settingsChanged, togglePopup } from "utils/messageHandlers"
|
||||
import { tabUpdated, settingsChanged, togglePopup, openPopup } from "utils/messageHandlers"
|
||||
|
||||
const messenger = new BackgroundMessenger()
|
||||
|
||||
function resetBubble({ tab, apiClient, service }) {
|
||||
messenger.postMessage(tab, { type: "closePopup" })
|
||||
apiClient.activitiesStatus(service).then(({ data }) => {
|
||||
function resetBubble({ tab, apiClient, service }, closePopup = true) {
|
||||
apiClient
|
||||
.activitiesStatus(service)
|
||||
.then(({ data }) => {
|
||||
messenger.postMessage(tab, {
|
||||
type: "showBubble",
|
||||
payload: {
|
||||
@@ -18,6 +19,13 @@ function resetBubble({ tab, apiClient, service }) {
|
||||
},
|
||||
})
|
||||
})
|
||||
.then(() => {
|
||||
if (closePopup) {
|
||||
messenger.postMessage(tab, { type: "closePopup" })
|
||||
} else {
|
||||
openPopup(tab, { service, messenger })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
messenger.on("togglePopup", () => {
|
||||
@@ -65,7 +73,7 @@ chrome.runtime.onMessage.addListener(action => {
|
||||
const apiClient = new ApiClient(settings)
|
||||
apiClient
|
||||
.stopTimer(timedActivity)
|
||||
.then(() => resetBubble({ tab, apiClient, service }))
|
||||
.then(() => resetBubble({ tab, apiClient, service }, false))
|
||||
.catch(() => null)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { get, forEach, reject, isNil } from "lodash/fp"
|
||||
import { createMatcher } from "utils/urlMatcher"
|
||||
import remoteServices from "remoteServices"
|
||||
import { queryTabs, isBrowserTab, getSettings, setStorage } from "utils/browser"
|
||||
import { queryTabs, isBrowserTab, getSettings } from "utils/browser"
|
||||
|
||||
const matcher = createMatcher(remoteServices)
|
||||
|
||||
@@ -76,7 +76,7 @@ export function togglePopup(tab, { messenger }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function openPopup(tab, { service, messenger }) {
|
||||
export async function openPopup(tab, { service, messenger }) {
|
||||
messenger.postMessage(tab, { type: "openPopup", payload: { loading: true } })
|
||||
|
||||
const fromDate = getStartOfWeek()
|
||||
|
||||
Reference in New Issue
Block a user