Use booked seconds instead of hours
This commit is contained in:
@@ -12,7 +12,7 @@ function resetBubble({ tab, apiClient, service }) {
|
|||||||
messenger.postMessage(tab, {
|
messenger.postMessage(tab, {
|
||||||
type: "showBubble",
|
type: "showBubble",
|
||||||
payload: {
|
payload: {
|
||||||
bookedHours: parseFloat(data.hours),
|
bookedSeconds: data.seconds,
|
||||||
timedActivity: data.timed_activity,
|
timedActivity: data.timed_activity,
|
||||||
service,
|
service,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import mocoTimerLogo from "images/moco-timer-32x32.png"
|
|||||||
import { parseISO } from "date-fns"
|
import { parseISO } from "date-fns"
|
||||||
import Timer from "./shared/Timer"
|
import Timer from "./shared/Timer"
|
||||||
|
|
||||||
const Bubble = ({ bookedHours, timedActivity }) => {
|
const Bubble = ({ bookedSeconds, timedActivity }) => {
|
||||||
const logo = timedActivity ? mocoTimerLogo : mocoLogo
|
const logo = timedActivity ? mocoTimerLogo : mocoLogo
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="moco-bx-bubble-inner">
|
<div className="moco-bx-bubble-inner">
|
||||||
<img className="moco-bx-logo" src={chrome.extension.getURL(logo)} />
|
<img className="moco-bx-logo" src={chrome.extension.getURL(logo)} />
|
||||||
{!timedActivity && bookedHours > 0 && (
|
{!timedActivity && bookedSeconds > 0 && (
|
||||||
<span className="moco-bx-booked-hours">{bookedHours.toFixed(2)}</span>
|
<span className="moco-bx-booked-hours">{(bookedSeconds / 3600).toFixed(2)}</span>
|
||||||
)}
|
)}
|
||||||
{timedActivity && (
|
{timedActivity && (
|
||||||
<Timer
|
<Timer
|
||||||
@@ -26,7 +26,7 @@ const Bubble = ({ bookedHours, timedActivity }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bubble.propTypes = {
|
Bubble.propTypes = {
|
||||||
bookedHours: PropTypes.number,
|
bookedSeconds: PropTypes.number,
|
||||||
timedActivity: PropTypes.shape({
|
timedActivity: PropTypes.shape({
|
||||||
timer_started_at: PropTypes.string.isRequired,
|
timer_started_at: PropTypes.string.isRequired,
|
||||||
seconds: PropTypes.number.isRequired,
|
seconds: PropTypes.number.isRequired,
|
||||||
@@ -34,7 +34,7 @@ Bubble.propTypes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bubble.defaultProps = {
|
Bubble.defaultProps = {
|
||||||
bookedHours: 0,
|
bookedSeconds: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Bubble
|
export default Bubble
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ chrome.runtime.onConnect.addListener(function(port) {
|
|||||||
document.removeEventListener("click", clickHandler, true)
|
document.removeEventListener("click", clickHandler, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
function updateBubble({ service, bookedHours, timedActivity } = {}) {
|
function updateBubble({ service, bookedSeconds, timedActivity } = {}) {
|
||||||
if (!document.getElementById("moco-bx-root")) {
|
if (!document.getElementById("moco-bx-root")) {
|
||||||
const domRoot = document.createElement("div")
|
const domRoot = document.createElement("div")
|
||||||
domRoot.setAttribute("id", "moco-bx-root")
|
domRoot.setAttribute("id", "moco-bx-root")
|
||||||
@@ -47,7 +47,11 @@ chrome.runtime.onConnect.addListener(function(port) {
|
|||||||
// eslint-disable-next-line react/display-name
|
// eslint-disable-next-line react/display-name
|
||||||
(props => (
|
(props => (
|
||||||
<animated.div className="moco-bx-bubble" style={{ ...props, ...service.position }}>
|
<animated.div className="moco-bx-bubble" style={{ ...props, ...service.position }}>
|
||||||
<Bubble key={service.url} bookedHours={bookedHours} timedActivity={timedActivity} />
|
<Bubble
|
||||||
|
key={service.url}
|
||||||
|
bookedSeconds={bookedSeconds}
|
||||||
|
timedActivity={timedActivity}
|
||||||
|
/>
|
||||||
</animated.div>
|
</animated.div>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
import { get, forEach, reject, isNil } from "lodash/fp"
|
import { get, forEach, reject, isNil } from "lodash/fp"
|
||||||
import { createMatcher } from "utils/urlMatcher"
|
import { createMatcher } from "utils/urlMatcher"
|
||||||
import remoteServices from "remoteServices"
|
import remoteServices from "remoteServices"
|
||||||
import { queryTabs, isBrowserTab, getSettings } from "utils/browser"
|
import { queryTabs, isBrowserTab, getSettings, setStorage } from "utils/browser"
|
||||||
|
|
||||||
const matcher = createMatcher(remoteServices)
|
const matcher = createMatcher(remoteServices)
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export function tabUpdated(tab, { messenger, settings }) {
|
|||||||
messenger.postMessage(tab, {
|
messenger.postMessage(tab, {
|
||||||
type: "showBubble",
|
type: "showBubble",
|
||||||
payload: {
|
payload: {
|
||||||
bookedHours: parseFloat(data.hours),
|
bookedSeconds: data.seconds,
|
||||||
timedActivity: data.timed_activity,
|
timedActivity: data.timed_activity,
|
||||||
service,
|
service,
|
||||||
},
|
},
|
||||||
@@ -40,7 +40,7 @@ export function tabUpdated(tab, { messenger, settings }) {
|
|||||||
messenger.postMessage(tab, {
|
messenger.postMessage(tab, {
|
||||||
type: "showBubble",
|
type: "showBubble",
|
||||||
payload: {
|
payload: {
|
||||||
bookedHours: 0,
|
bookedSeconds: 0,
|
||||||
service,
|
service,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user