diff --git a/.vscode/settings.json b/.vscode/settings.json index 544210d..2bfea9d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -34,5 +34,5 @@ "*.{css,sass,scss}.d.ts": true }, - "cSpell.words": ["Popconfirm"] + "cSpell.words": ["Popconfirm", "Sider"] } diff --git a/assets/icon.icns b/assets/icon.icns index c2213ce..0ab9eff 100644 Binary files a/assets/icon.icns and b/assets/icon.icns differ diff --git a/assets/icon.ico b/assets/icon.ico index 66503e1..25c5c68 100644 Binary files a/assets/icon.ico and b/assets/icon.ico differ diff --git a/assets/icons/1024x1024.png b/assets/icons/1024x1024.png old mode 100755 new mode 100644 index 5940b65..44029e9 Binary files a/assets/icons/1024x1024.png and b/assets/icons/1024x1024.png differ diff --git a/assets/icons/128x128.png b/assets/icons/128x128.png old mode 100755 new mode 100644 index 14e578d..03dc8bf Binary files a/assets/icons/128x128.png and b/assets/icons/128x128.png differ diff --git a/assets/icons/16x16.png b/assets/icons/16x16.png old mode 100755 new mode 100644 index 260a46c..d7147cd Binary files a/assets/icons/16x16.png and b/assets/icons/16x16.png differ diff --git a/assets/icons/24x24.png b/assets/icons/24x24.png old mode 100755 new mode 100644 index 5617241..1aa4402 Binary files a/assets/icons/24x24.png and b/assets/icons/24x24.png differ diff --git a/assets/icons/256x256.png b/assets/icons/256x256.png old mode 100755 new mode 100644 index 755a6e5..c6bf700 Binary files a/assets/icons/256x256.png and b/assets/icons/256x256.png differ diff --git a/assets/icons/32x32.png b/assets/icons/32x32.png old mode 100755 new mode 100644 index 63423df..834b5a8 Binary files a/assets/icons/32x32.png and b/assets/icons/32x32.png differ diff --git a/assets/icons/48x48.png b/assets/icons/48x48.png old mode 100755 new mode 100644 index 74d87a0..a8c736a Binary files a/assets/icons/48x48.png and b/assets/icons/48x48.png differ diff --git a/assets/icons/512x512.png b/assets/icons/512x512.png old mode 100755 new mode 100644 index 313cd49..a52347e Binary files a/assets/icons/512x512.png and b/assets/icons/512x512.png differ diff --git a/assets/icons/64x64.png b/assets/icons/64x64.png old mode 100755 new mode 100644 index 6de0ec0..1511213 Binary files a/assets/icons/64x64.png and b/assets/icons/64x64.png differ diff --git a/assets/icons/96x96.png b/assets/icons/96x96.png old mode 100755 new mode 100644 index 8255ab5..418360a Binary files a/assets/icons/96x96.png and b/assets/icons/96x96.png differ diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx index 6d5f29b..66c9f11 100644 --- a/src/components/ProgressBar.tsx +++ b/src/components/ProgressBar.tsx @@ -53,27 +53,30 @@ function ProgressBar() { timeItems, ]); - const { estimatedWorkingTimeEnd, progress } = TaskTimeService.getDayProgress( + const { + estimatedWorkingTimeEnd, + progress, + realProgress, + } = TaskTimeService.getDayProgress( timeRangeItems, workingTimeStart, workingHoursMs ); - const progressRound = Math.round(progress); const marks: Record = { 0: toTimeFormat(workingTimeStart), 100: toTimeFormat(estimatedWorkingTimeEnd), }; - if (progressRound > 10 && progressRound < 90) { - marks[progressRound] = `${progressRound}%`; + if (progress > 10 && progress < 90) { + marks[progress] = `${realProgress}%`; } const tipFormatter = useMemo(() => { - if (progressRound <= 10 || progressRound >= 90) { - return (value?: number) => `${value}%`; + if (progress <= 10 || progress >= 90) { + return () => `${realProgress}%`; } return null; - }, [progressRound]); + }, [progress, realProgress]); return ( ( export function last(arr: T[]): T | undefined { return arr[arr.length - 1]; } + +export function first(arr: T[]): T | undefined { + return arr[0]; +} diff --git a/src/package.json b/src/package.json index f646679..2502f6f 100644 --- a/src/package.json +++ b/src/package.json @@ -1,7 +1,7 @@ { "name": "time-tracker", "productName": "TimeTracker", - "version": "1.0.7", + "version": "1.0.8", "description": "Start and stop time, jump between tasks, and add details on how time was spent.", "main": "./main.prod.js", "author": { diff --git a/src/screens/projects/ProjectsScreen.tsx b/src/screens/projects/ProjectsScreen.tsx index 26afe9f..7e39651 100644 --- a/src/screens/projects/ProjectsScreen.tsx +++ b/src/screens/projects/ProjectsScreen.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { Button, Layout, Space } from 'antd'; import { observer } from 'mobx-react'; import { Key } from 'rc-tree/lib/interface'; @@ -17,6 +17,7 @@ import TaskNode from './components/TaskNode/TaskNode'; import DrawerTask from './components/DrawerTask/DrawerTask'; import ProjectNode from './components/ProjectNode/ProjectNode'; import EditProjectModal from './components/ProjectModals/EditProjectModal'; +import { first } from '../../helpers/ArrayHelper'; const { Sider } = Layout; @@ -75,8 +76,18 @@ const ProjectList = TreeList( } ); -export default observer(function Projects() { - const classes = useStyles(); +function handleSelectProject(items: Key[]) { + if (items.length > 0) { + projectStore.setActiveProject(first(items) as string); + } +} + +function clearEditableProject() { + projectStore.setEditableProject(undefined); +} + +function Projects() { + const style = useStyles(); const [showProjectModal, setShowProjectModal] = useState(false); const [drawerVisible, setDrawerVisible] = useState(false); const [selectedTask, setSelectedTask] = useState(); @@ -85,24 +96,26 @@ export default observer(function Projects() { setShowProjectModal(true); } - function handleSelectProject(items: Key[]) { - if (items.length > 0) { - projectStore.setActiveProject(items[0] as string); - } - } - - function handleSelectTask(items: Key[]) { + const handleSelectTask = useCallback((items: Key[]) => { if (items.length > 0) { setDrawerVisible(true); - const task = tasksStore.getTaskByKey(items[0] as string); + const task = tasksStore.getTaskByKey(first(items) as string); setSelectedTask(task); } - } + }, []); + + const handleCloseDrawer = useCallback(() => { + setDrawerVisible(false); + }, []); + + const handleHideProjectModal = useCallback(() => { + setShowProjectModal(false); + }, []); return ( - - + +