From 81e7873bd0f40702fc73f876246bd3aa03d23dd4 Mon Sep 17 00:00:00 2001 From: Jeet Mandaliya <45892659+sereneinserenade@users.noreply.github.com> Date: Tue, 10 May 2022 01:09:32 +0530 Subject: [PATCH] version 1.0.8 --- package.json | 2 +- src/pages/Newtab/components/Sidebar.tsx | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 371d3fc..acdf8a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "placenoter", - "version": "1.0.7", + "version": "1.0.8", "description": "New tab replaced by note taking app.", "license": "MIT", "repository": { diff --git a/src/pages/Newtab/components/Sidebar.tsx b/src/pages/Newtab/components/Sidebar.tsx index 668a88b..ce79def 100644 --- a/src/pages/Newtab/components/Sidebar.tsx +++ b/src/pages/Newtab/components/Sidebar.tsx @@ -1,5 +1,5 @@ -import React, { useCallback, useState } from 'react'; -import { Button, Container, Input, Link, Row, Text, Tooltip } from '@nextui-org/react'; +import React, { useCallback, useEffect, useState } from 'react'; +import { Button, Input, Link, Row, Text, Tooltip } from '@nextui-org/react'; import { useRecoilState, useRecoilValue } from 'recoil'; import { format } from 'date-fns' import { v4 as uuidv4 } from 'uuid' @@ -10,12 +10,13 @@ import { Note } from '../types'; import './css/Sidebar.scss' import { FiTrash2 } from 'react-icons/fi'; import { RiArrowLeftSLine, RiDeleteBin2Line, RiRecycleLine } from 'react-icons/ri'; +import { useLocalStorage } from 'react-use'; // import { toast } from 'react-toastify'; const { storage } = chrome const Sidebar = () => { - const sidebarActive = useRecoilValue(sidebarActiveState) + const [sidebarActive, setSidebarActive] = useRecoilState(sidebarActiveState) const [activeNote, setActiveNote] = useRecoilState(activeNoteState) @@ -27,6 +28,20 @@ const Sidebar = () => { const [isBinActive, setIsBinActive] = useState(false) + const [isSidebarOpen, setIsSidebarOpen, remove] = useLocalStorage('sidebar-active', 'false'); + + useEffect(() => { + setTimeout(() => { + if (isSidebarOpen === 'true') setSidebarActive(true) + else if (isSidebarOpen === 'false') setSidebarActive(false) + }, 100); + }, []) + + useEffect(() => { + if (sidebarActive) setIsSidebarOpen('true') + else setIsSidebarOpen('false') + }, [sidebarActive]) + const returnFormattedDateString = (timestamp: Date) => { return format(new Date(timestamp), 'PPpp') }