diff --git a/src/css/popup.scss b/src/css/popup.scss index ddc36bc..af7038a 100644 --- a/src/css/popup.scss +++ b/src/css/popup.scss @@ -13,8 +13,6 @@ html { #moco-bx-root { min-width: 516px; - min-height: 420px; - transition: height 2s ease-out; h1 { font-size: 24px; diff --git a/src/js/components/App.js b/src/js/components/App.js index 3a25b32..c02bfd6 100644 --- a/src/js/components/App.js +++ b/src/js/components/App.js @@ -110,7 +110,7 @@ class App extends Component { componentDidMount() { window.addEventListener("keydown", this.handleKeyDown) - parent.postMessage(window.document.body.scrollHeight, "*") + parent.postMessage({ __mocoBX: { iFrameHeight: window.document.body.scrollHeight } }, "*") chrome.runtime.onMessage.addListener(this.handleSetFormErrors) } diff --git a/src/js/components/Form.js b/src/js/components/Form.js index 1f64c91..7a19df1 100644 --- a/src/js/components/Form.js +++ b/src/js/components/Form.js @@ -1,7 +1,6 @@ import React, { Component } from "react" import PropTypes from "prop-types" import Select from "components/Select" -import TimeInputParser from "utils/TimeInputParser" import { formatDate } from "utils" import cn from "classnames" import stopWatch from "images/icons/stopwatch-light.svg" @@ -39,15 +38,18 @@ class Form extends Component { isValid() { const { changeset } = this.props - return ["assignment_id", "task_id"].map(prop => changeset[prop]).every(Boolean) + return ( + ["assignment_id", "task_id"].map(prop => changeset[prop]).every(Boolean) && + (changeset.date === formatDate(new Date()) || changeset.seconds > 0) + ) } get isTimerStartable() { const { - changeset: { hours, date }, + changeset: { seconds, date }, } = this.props - const duration = new TimeInputParser(hours).parseSeconds() - return date === formatDate(new Date()) && duration === 0 + + return date === formatDate(new Date()) && seconds === 0 } buttonStyle() { diff --git a/src/js/components/Popup.js b/src/js/components/Popup.js index f95c0a5..03f9ab9 100644 --- a/src/js/components/Popup.js +++ b/src/js/components/Popup.js @@ -13,8 +13,8 @@ const Popup = forwardRef((props, ref) => { } const handleMessage = event => { - if (iFrameRef.current) { - iFrameRef.current.style.height = `${event.data}px` + if (iFrameRef.current && event.data?.__mocoBX?.iFrameHeight > 300) { + iFrameRef.current.style.height = `${event.data.__mocoBX.iFrameHeight}px` } } @@ -50,11 +50,11 @@ const Popup = forwardRef((props, ref) => { return (