From b9b795bf0eecb11ac7a6e83caf239335da977ca7 Mon Sep 17 00:00:00 2001 From: boojack Date: Mon, 21 Aug 2023 02:35:53 +0800 Subject: [PATCH] chore: add react use (#2157) * chore: add react use * chore: update --- web/package.json | 8 +- web/pnpm-lock.yaml | 260 ++++++++++++----------- web/src/components/MemoList.tsx | 13 +- web/src/components/ResourceSearchBar.tsx | 2 +- web/src/components/SearchBar.tsx | 2 +- web/src/components/TagList.tsx | 2 +- web/src/components/kit/Dropdown.tsx | 2 +- web/src/components/kit/Selector.tsx | 2 +- web/src/hooks/index.ts | 3 - web/src/hooks/useDebounce.ts | 12 -- web/src/hooks/useTimeoutFn.ts | 40 ---- web/src/hooks/useToggle.ts | 21 -- web/src/pages/DailyReview.tsx | 2 +- web/src/store/module/filter.ts | 8 - web/src/store/reducer/filter.ts | 1 - web/src/types/filter.d.ts | 54 ----- 16 files changed, 149 insertions(+), 283 deletions(-) delete mode 100644 web/src/hooks/useDebounce.ts delete mode 100644 web/src/hooks/useTimeoutFn.ts delete mode 100644 web/src/hooks/useToggle.ts delete mode 100644 web/src/types/filter.d.ts diff --git a/web/package.json b/web/package.json index f74a08d2..14bcf240 100644 --- a/web/package.json +++ b/web/package.json @@ -10,7 +10,7 @@ "dependencies": { "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", - "@mui/joy": "5.0.0-beta.0", + "@mui/joy": "5.0.0-beta.2", "@reduxjs/toolkit": "^1.8.1", "axios": "^0.27.2", "classnames": "^2.3.2", @@ -46,7 +46,7 @@ "@types/uuid": "^9.0.2", "@typescript-eslint/eslint-plugin": "^5.6.0", "@typescript-eslint/parser": "^5.6.0", - "@vitejs/plugin-react-swc": "^3.3.0", + "@vitejs/plugin-react-swc": "^3.3.2", "autoprefixer": "^10.4.2", "eslint": "^8.46.0", "eslint-config-prettier": "^8.6.0", @@ -56,7 +56,7 @@ "postcss": "^8.4.21", "prettier": "2.6.2", "terser": "^5.16.1", - "typescript": "^5.0.4", - "vite": "^4.2.1" + "typescript": "^5.1.6", + "vite": "^4.4.9" } } diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index bee7828b..c0ec3db9 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^11.11.0 version: 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.18)(react@18.2.0) '@mui/joy': - specifier: 5.0.0-beta.0 - version: 5.0.0-beta.0(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0) + specifier: 5.0.0-beta.2 + version: 5.0.0-beta.2(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0) '@reduxjs/toolkit': specifier: ^1.8.1 version: 1.8.1(react-redux@8.0.1)(react@18.2.0) @@ -111,13 +111,13 @@ devDependencies: version: 9.0.2 '@typescript-eslint/eslint-plugin': specifier: ^5.6.0 - version: 5.6.0(@typescript-eslint/parser@5.6.0)(eslint@8.46.0)(typescript@5.0.4) + version: 5.6.0(@typescript-eslint/parser@5.6.0)(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/parser': specifier: ^5.6.0 - version: 5.6.0(eslint@8.46.0)(typescript@5.0.4) + version: 5.6.0(eslint@8.46.0)(typescript@5.1.6) '@vitejs/plugin-react-swc': - specifier: ^3.3.0 - version: 3.3.0(vite@4.2.1) + specifier: ^3.3.2 + version: 3.3.2(vite@4.4.9) autoprefixer: specifier: ^10.4.2 version: 10.4.2(postcss@8.4.21) @@ -146,11 +146,11 @@ devDependencies: specifier: ^5.16.1 version: 5.16.1 typescript: - specifier: ^5.0.4 - version: 5.0.4 + specifier: ^5.1.6 + version: 5.1.6 vite: - specifier: ^4.2.1 - version: 4.2.1(@types/node@18.0.3)(less@4.1.1)(terser@5.16.1) + specifier: ^4.4.9 + version: 4.4.9(@types/node@18.0.3)(less@4.1.1)(terser@5.16.1) packages: @@ -510,8 +510,8 @@ packages: resolution: {integrity: sha512-EsBwpc7hBUJWAsNPBmJy4hxWx12v6bshQsldrVmjxJoc3isbxhOrF2IcCpaXxfvq03NwkI7sbsOLXbYuqF/8Ww==} dev: false - /@esbuild/android-arm64@0.17.19: - resolution: {integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==} + /@esbuild/android-arm64@0.18.20: + resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} engines: {node: '>=12'} cpu: [arm64] os: [android] @@ -519,8 +519,8 @@ packages: dev: true optional: true - /@esbuild/android-arm@0.17.19: - resolution: {integrity: sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==} + /@esbuild/android-arm@0.18.20: + resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} engines: {node: '>=12'} cpu: [arm] os: [android] @@ -528,8 +528,8 @@ packages: dev: true optional: true - /@esbuild/android-x64@0.17.19: - resolution: {integrity: sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==} + /@esbuild/android-x64@0.18.20: + resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} engines: {node: '>=12'} cpu: [x64] os: [android] @@ -537,8 +537,8 @@ packages: dev: true optional: true - /@esbuild/darwin-arm64@0.17.19: - resolution: {integrity: sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==} + /@esbuild/darwin-arm64@0.18.20: + resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] @@ -546,8 +546,8 @@ packages: dev: true optional: true - /@esbuild/darwin-x64@0.17.19: - resolution: {integrity: sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==} + /@esbuild/darwin-x64@0.18.20: + resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} engines: {node: '>=12'} cpu: [x64] os: [darwin] @@ -555,8 +555,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-arm64@0.17.19: - resolution: {integrity: sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==} + /@esbuild/freebsd-arm64@0.18.20: + resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] @@ -564,8 +564,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-x64@0.17.19: - resolution: {integrity: sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==} + /@esbuild/freebsd-x64@0.18.20: + resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] @@ -573,8 +573,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm64@0.17.19: - resolution: {integrity: sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==} + /@esbuild/linux-arm64@0.18.20: + resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} engines: {node: '>=12'} cpu: [arm64] os: [linux] @@ -582,8 +582,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm@0.17.19: - resolution: {integrity: sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==} + /@esbuild/linux-arm@0.18.20: + resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} engines: {node: '>=12'} cpu: [arm] os: [linux] @@ -591,8 +591,8 @@ packages: dev: true optional: true - /@esbuild/linux-ia32@0.17.19: - resolution: {integrity: sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==} + /@esbuild/linux-ia32@0.18.20: + resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} engines: {node: '>=12'} cpu: [ia32] os: [linux] @@ -600,8 +600,8 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.17.19: - resolution: {integrity: sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==} + /@esbuild/linux-loong64@0.18.20: + resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} engines: {node: '>=12'} cpu: [loong64] os: [linux] @@ -609,8 +609,8 @@ packages: dev: true optional: true - /@esbuild/linux-mips64el@0.17.19: - resolution: {integrity: sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==} + /@esbuild/linux-mips64el@0.18.20: + resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] @@ -618,8 +618,8 @@ packages: dev: true optional: true - /@esbuild/linux-ppc64@0.17.19: - resolution: {integrity: sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==} + /@esbuild/linux-ppc64@0.18.20: + resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] @@ -627,8 +627,8 @@ packages: dev: true optional: true - /@esbuild/linux-riscv64@0.17.19: - resolution: {integrity: sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==} + /@esbuild/linux-riscv64@0.18.20: + resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] @@ -636,8 +636,8 @@ packages: dev: true optional: true - /@esbuild/linux-s390x@0.17.19: - resolution: {integrity: sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==} + /@esbuild/linux-s390x@0.18.20: + resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} engines: {node: '>=12'} cpu: [s390x] os: [linux] @@ -645,8 +645,8 @@ packages: dev: true optional: true - /@esbuild/linux-x64@0.17.19: - resolution: {integrity: sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==} + /@esbuild/linux-x64@0.18.20: + resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} engines: {node: '>=12'} cpu: [x64] os: [linux] @@ -654,8 +654,8 @@ packages: dev: true optional: true - /@esbuild/netbsd-x64@0.17.19: - resolution: {integrity: sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==} + /@esbuild/netbsd-x64@0.18.20: + resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] @@ -663,8 +663,8 @@ packages: dev: true optional: true - /@esbuild/openbsd-x64@0.17.19: - resolution: {integrity: sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==} + /@esbuild/openbsd-x64@0.18.20: + resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] @@ -672,8 +672,8 @@ packages: dev: true optional: true - /@esbuild/sunos-x64@0.17.19: - resolution: {integrity: sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==} + /@esbuild/sunos-x64@0.18.20: + resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} engines: {node: '>=12'} cpu: [x64] os: [sunos] @@ -681,8 +681,8 @@ packages: dev: true optional: true - /@esbuild/win32-arm64@0.17.19: - resolution: {integrity: sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==} + /@esbuild/win32-arm64@0.18.20: + resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} engines: {node: '>=12'} cpu: [arm64] os: [win32] @@ -690,8 +690,8 @@ packages: dev: true optional: true - /@esbuild/win32-ia32@0.17.19: - resolution: {integrity: sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==} + /@esbuild/win32-ia32@0.18.20: + resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} engines: {node: '>=12'} cpu: [ia32] os: [win32] @@ -699,8 +699,8 @@ packages: dev: true optional: true - /@esbuild/win32-x64@0.17.19: - resolution: {integrity: sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==} + /@esbuild/win32-x64@0.18.20: + resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -806,8 +806,8 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: true - /@mui/base@5.0.0-beta.9(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-gm6gnPnc/lS5Z3neH0iuOrK7IbS02+oh6KsMtXYLhI6bJpHs+PNWFsBmISx7x4FSPVJZvZkb8Bw6pEXpIMFt7Q==} + /@mui/base@5.0.0-beta.11(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-FdKZGPd8qmC3ZNke7CNhzcEgToc02M6WYZc9hcBsNQ17bgAd3s9F//1bDDYgMVBYxDM71V0sv/hBHlOY4I1ZVA==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -820,7 +820,7 @@ packages: '@babel/runtime': 7.22.6 '@emotion/is-prop-valid': 1.2.1 '@mui/types': 7.2.4(@types/react@18.2.18) - '@mui/utils': 5.14.3(react@18.2.0) + '@mui/utils': 5.14.5(react@18.2.0) '@popperjs/core': 2.11.8 '@types/react': 18.2.18 clsx: 2.0.0 @@ -830,12 +830,12 @@ packages: react-is: 18.2.0 dev: false - /@mui/core-downloads-tracker@5.14.3: - resolution: {integrity: sha512-QxvrcDqphZoXRjsAmCaQylmWjC/8/qKWwIde1MJMna5YIst3R9O0qhKRPu36/OE2d8AeTbCVjRcRvNqhhW8jyg==} + /@mui/core-downloads-tracker@5.14.5: + resolution: {integrity: sha512-+wpGH1USwPcKMFPMvXqYPC6fEvhxM3FzxC8lyDiNK/imLyyJ6y2DPb1Oue7OGIKJWBmYBqrWWtfovrxd1aJHTA==} dev: false - /@mui/joy@5.0.0-beta.0(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-WDGlbEMqXPmuwgUPEgJEPeOUJD46WragfPqTjoWEp+//0iE8kcn+YfFVgsoY31uID5UwcFWQRupxui872slANA==} + /@mui/joy@5.0.0-beta.2(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-5NfZcOYufTOSXh0b34YZzF1CHwuHf07cgSNdyn3WUUwg67oyNOPKhaskttX6aSp0j8Rf8OpKzd+7Ni6Em0jPgQ==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -854,11 +854,11 @@ packages: '@babel/runtime': 7.22.6 '@emotion/react': 11.11.1(@types/react@18.2.18)(react@18.2.0) '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.18)(react@18.2.0) - '@mui/base': 5.0.0-beta.9(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0) - '@mui/core-downloads-tracker': 5.14.3 - '@mui/system': 5.14.3(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react@18.2.0) + '@mui/base': 5.0.0-beta.11(@types/react@18.2.18)(react-dom@18.2.0)(react@18.2.0) + '@mui/core-downloads-tracker': 5.14.5 + '@mui/system': 5.14.5(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react@18.2.0) '@mui/types': 7.2.4(@types/react@18.2.18) - '@mui/utils': 5.14.3(react@18.2.0) + '@mui/utils': 5.14.5(react@18.2.0) '@types/react': 18.2.18 clsx: 2.0.0 csstype: 3.1.2 @@ -868,8 +868,8 @@ packages: react-is: 18.2.0 dev: false - /@mui/private-theming@5.13.7(@types/react@18.2.18)(react@18.2.0): - resolution: {integrity: sha512-qbSr+udcij5F9dKhGX7fEdx2drXchq7htLNr2Qg2Ma+WJ6q0ERlEqGSBiPiVDJkptcjeVL4DGmcf1wl5+vD4EA==} + /@mui/private-theming@5.14.5(@types/react@18.2.18)(react@18.2.0): + resolution: {integrity: sha512-cC4C5RrpXpDaaZyH9QwmPhRLgz+f2SYbOty3cPkk4qPSOSfif2ZEcDD9HTENKDDd9deB+xkPKzzZhi8cxIx8Ig==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -879,7 +879,7 @@ packages: optional: true dependencies: '@babel/runtime': 7.22.6 - '@mui/utils': 5.14.3(react@18.2.0) + '@mui/utils': 5.14.5(react@18.2.0) '@types/react': 18.2.18 prop-types: 15.8.1 react: 18.2.0 @@ -907,8 +907,8 @@ packages: react: 18.2.0 dev: false - /@mui/system@5.14.3(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react@18.2.0): - resolution: {integrity: sha512-b+C+j9+75+/iIYSa+1S4eCMc9MDNrj9hzWfExJqS2GffuNocRagjBZFyjtMqsLWLxMxQIX8Cg6j0hAioiw+WfQ==} + /@mui/system@5.14.5(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.18)(react@18.2.0): + resolution: {integrity: sha512-mextXZHDeGcR7E1kx43TRARrVXy+gI4wzpUgNv7MqZs1dvTVXQGVeAT6ydj9d6FUqHBPMNLGV/21vJOrpqsL+w==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -926,10 +926,10 @@ packages: '@babel/runtime': 7.22.6 '@emotion/react': 11.11.1(@types/react@18.2.18)(react@18.2.0) '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.18)(react@18.2.0) - '@mui/private-theming': 5.13.7(@types/react@18.2.18)(react@18.2.0) + '@mui/private-theming': 5.14.5(@types/react@18.2.18)(react@18.2.0) '@mui/styled-engine': 5.13.2(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0) '@mui/types': 7.2.4(@types/react@18.2.18) - '@mui/utils': 5.14.3(react@18.2.0) + '@mui/utils': 5.14.5(react@18.2.0) '@types/react': 18.2.18 clsx: 2.0.0 csstype: 3.1.2 @@ -948,8 +948,8 @@ packages: '@types/react': 18.2.18 dev: false - /@mui/utils@5.14.3(react@18.2.0): - resolution: {integrity: sha512-gZ6Etw+ppO43GYc1HFZSLjwd4DoZoa+RrYTD25wQLfzcSoPjVoC/zZqA2Lkq0zjgwGBQOSxKZI6jfp9uXR+kgw==} + /@mui/utils@5.14.5(react@18.2.0): + resolution: {integrity: sha512-6Hzw63VR9C5xYv+CbjndoRLU6Gntal8rJ5W+GUzkyHrGWIyYPWZPa6AevnyGioySNETATe1H9oXS8f/7qgIHJA==} engines: {node: '>=12.0.0'} peerDependencies: react: ^17.0.0 || ^18.0.0 @@ -1214,7 +1214,7 @@ packages: resolution: {integrity: sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==} dev: true - /@typescript-eslint/eslint-plugin@5.6.0(@typescript-eslint/parser@5.6.0)(eslint@8.46.0)(typescript@5.0.4): + /@typescript-eslint/eslint-plugin@5.6.0(@typescript-eslint/parser@5.6.0)(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-MIbeMy5qfLqtgs1hWd088k1hOuRsN9JrHUPwVVKCD99EOUqScd7SrwoZl4Gso05EAP9w1kvLWUVGJOVpRPkDPA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1225,8 +1225,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/experimental-utils': 5.6.0(eslint@8.46.0)(typescript@5.0.4) - '@typescript-eslint/parser': 5.6.0(eslint@8.46.0)(typescript@5.0.4) + '@typescript-eslint/experimental-utils': 5.6.0(eslint@8.46.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.6.0(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/scope-manager': 5.6.0 debug: 4.3.4 eslint: 8.46.0 @@ -1234,13 +1234,13 @@ packages: ignore: 5.2.4 regexpp: 3.2.0 semver: 7.3.8 - tsutils: 3.21.0(typescript@5.0.4) - typescript: 5.0.4 + tsutils: 3.21.0(typescript@5.1.6) + typescript: 5.1.6 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/experimental-utils@5.6.0(eslint@8.46.0)(typescript@5.0.4): + /@typescript-eslint/experimental-utils@5.6.0(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-VDoRf3Qj7+W3sS/ZBXZh3LBzp0snDLEgvp6qj0vOAIiAPM07bd5ojQ3CTzF/QFl5AKh7Bh1ycgj6lFBJHUt/DA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1249,7 +1249,7 @@ packages: '@types/json-schema': 7.0.12 '@typescript-eslint/scope-manager': 5.6.0 '@typescript-eslint/types': 5.6.0 - '@typescript-eslint/typescript-estree': 5.6.0(typescript@5.0.4) + '@typescript-eslint/typescript-estree': 5.6.0(typescript@5.1.6) eslint: 8.46.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0(eslint@8.46.0) @@ -1258,7 +1258,7 @@ packages: - typescript dev: true - /@typescript-eslint/parser@5.6.0(eslint@8.46.0)(typescript@5.0.4): + /@typescript-eslint/parser@5.6.0(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-YVK49NgdUPQ8SpCZaOpiq1kLkYRPMv9U5gcMrywzI8brtwZjr/tG3sZpuHyODt76W/A0SufNjYt9ZOgrC4tLIQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1270,10 +1270,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.6.0 '@typescript-eslint/types': 5.6.0 - '@typescript-eslint/typescript-estree': 5.6.0(typescript@5.0.4) + '@typescript-eslint/typescript-estree': 5.6.0(typescript@5.1.6) debug: 4.3.4 eslint: 8.46.0 - typescript: 5.0.4 + typescript: 5.1.6 transitivePeerDependencies: - supports-color dev: true @@ -1291,7 +1291,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.6.0(typescript@5.0.4): + /@typescript-eslint/typescript-estree@5.6.0(typescript@5.1.6): resolution: {integrity: sha512-92vK5tQaE81rK7fOmuWMrSQtK1IMonESR+RJR2Tlc7w4o0MeEdjgidY/uO2Gobh7z4Q1hhS94Cr7r021fMVEeA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1306,8 +1306,8 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.3.8 - tsutils: 3.21.0(typescript@5.0.4) - typescript: 5.0.4 + tsutils: 3.21.0(typescript@5.1.6) + typescript: 5.1.6 transitivePeerDependencies: - supports-color dev: true @@ -1320,13 +1320,13 @@ packages: eslint-visitor-keys: 3.4.2 dev: true - /@vitejs/plugin-react-swc@3.3.0(vite@4.2.1): - resolution: {integrity: sha512-Ycg+n2eyCOTpn/wRy+evVo859+hw7qCj9iaX5CMny6x1fx1Uoq0xBG+a98lFtwLNGfGEnpI0F26YigRuxCRkwg==} + /@vitejs/plugin-react-swc@3.3.2(vite@4.4.9): + resolution: {integrity: sha512-VJFWY5sfoZerQRvJrh518h3AcQt6f/yTuWn4/TRB+dqmYU0NX1qz7qM5Wfd+gOQqUzQW4gxKqKN3KpE/P3+zrA==} peerDependencies: vite: ^4 dependencies: '@swc/core': 1.3.74 - vite: 4.2.1(@types/node@18.0.3)(less@4.1.1)(terser@5.16.1) + vite: 4.4.9(@types/node@18.0.3)(less@4.1.1)(terser@5.16.1) transitivePeerDependencies: - '@swc/helpers' dev: true @@ -1875,34 +1875,34 @@ packages: is-symbol: 1.0.4 dev: true - /esbuild@0.17.19: - resolution: {integrity: sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==} + /esbuild@0.18.20: + resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.17.19 - '@esbuild/android-arm64': 0.17.19 - '@esbuild/android-x64': 0.17.19 - '@esbuild/darwin-arm64': 0.17.19 - '@esbuild/darwin-x64': 0.17.19 - '@esbuild/freebsd-arm64': 0.17.19 - '@esbuild/freebsd-x64': 0.17.19 - '@esbuild/linux-arm': 0.17.19 - '@esbuild/linux-arm64': 0.17.19 - '@esbuild/linux-ia32': 0.17.19 - '@esbuild/linux-loong64': 0.17.19 - '@esbuild/linux-mips64el': 0.17.19 - '@esbuild/linux-ppc64': 0.17.19 - '@esbuild/linux-riscv64': 0.17.19 - '@esbuild/linux-s390x': 0.17.19 - '@esbuild/linux-x64': 0.17.19 - '@esbuild/netbsd-x64': 0.17.19 - '@esbuild/openbsd-x64': 0.17.19 - '@esbuild/sunos-x64': 0.17.19 - '@esbuild/win32-arm64': 0.17.19 - '@esbuild/win32-ia32': 0.17.19 - '@esbuild/win32-x64': 0.17.19 + '@esbuild/android-arm': 0.18.20 + '@esbuild/android-arm64': 0.18.20 + '@esbuild/android-x64': 0.18.20 + '@esbuild/darwin-arm64': 0.18.20 + '@esbuild/darwin-x64': 0.18.20 + '@esbuild/freebsd-arm64': 0.18.20 + '@esbuild/freebsd-x64': 0.18.20 + '@esbuild/linux-arm': 0.18.20 + '@esbuild/linux-arm64': 0.18.20 + '@esbuild/linux-ia32': 0.18.20 + '@esbuild/linux-loong64': 0.18.20 + '@esbuild/linux-mips64el': 0.18.20 + '@esbuild/linux-ppc64': 0.18.20 + '@esbuild/linux-riscv64': 0.18.20 + '@esbuild/linux-s390x': 0.18.20 + '@esbuild/linux-x64': 0.18.20 + '@esbuild/netbsd-x64': 0.18.20 + '@esbuild/openbsd-x64': 0.18.20 + '@esbuild/sunos-x64': 0.18.20 + '@esbuild/win32-arm64': 0.18.20 + '@esbuild/win32-ia32': 0.18.20 + '@esbuild/win32-x64': 0.18.20 dev: true /escalade@3.1.1: @@ -3076,6 +3076,15 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.2 + /postcss@8.4.28: + resolution: {integrity: sha512-Z7V5j0cq8oEKyejIKfpD8b4eBy9cwW2JWPk0+fB1HOAMsfHbnAXLLS+PfVWlzMSLQaWttKDt607I0XHmpE67Vw==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.6 + picocolors: 1.0.0 + source-map-js: 1.0.2 + dev: true + /prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -3340,6 +3349,7 @@ packages: is-core-module: 2.13.0 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 + dev: false /resolve@2.0.0-next.4: resolution: {integrity: sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==} @@ -3680,14 +3690,14 @@ packages: resolution: {integrity: sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==} dev: false - /tsutils@3.21.0(typescript@5.0.4): + /tsutils@3.21.0(typescript@5.1.6): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 5.0.4 + typescript: 5.1.6 dev: true /type-check@0.4.0: @@ -3740,9 +3750,9 @@ packages: is-typed-array: 1.1.12 dev: true - /typescript@5.0.4: - resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} - engines: {node: '>=12.20'} + /typescript@5.1.6: + resolution: {integrity: sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==} + engines: {node: '>=14.17'} hasBin: true dev: true @@ -3789,13 +3799,14 @@ packages: hasBin: true dev: false - /vite@4.2.1(@types/node@18.0.3)(less@4.1.1)(terser@5.16.1): - resolution: {integrity: sha512-7MKhqdy0ISo4wnvwtqZkjke6XN4taqQ2TBaTccLIpOKv7Vp2h4Y+NpmWCnGDeSvvn45KxvWgGyb0MkHvY1vgbg==} + /vite@4.4.9(@types/node@18.0.3)(less@4.1.1)(terser@5.16.1): + resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true peerDependencies: '@types/node': '>= 14' less: '*' + lightningcss: ^1.21.0 sass: '*' stylus: '*' sugarss: '*' @@ -3805,6 +3816,8 @@ packages: optional: true less: optional: true + lightningcss: + optional: true sass: optional: true stylus: @@ -3815,10 +3828,9 @@ packages: optional: true dependencies: '@types/node': 18.0.3 - esbuild: 0.17.19 + esbuild: 0.18.20 less: 4.1.1 - postcss: 8.4.21 - resolve: 1.22.4 + postcss: 8.4.28 rollup: 3.27.2 terser: 5.16.1 optionalDependencies: diff --git a/web/src/components/MemoList.tsx b/web/src/components/MemoList.tsx index 940d9d86..61cf9a61 100644 --- a/web/src/components/MemoList.tsx +++ b/web/src/components/MemoList.tsx @@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from "react"; import { toast } from "react-hot-toast"; import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts"; import { getTimeStampByDate } from "@/helpers/datetime"; -import { LINK_REG, PLAIN_LINK_REG, TAG_REG } from "@/labs/marked/parser"; +import { TAG_REG } from "@/labs/marked/parser"; import { useFilterStore, useMemoStore, useUserStore } from "@/store/module"; import { useTranslate } from "@/utils/i18n"; import Empty from "./Empty"; @@ -24,8 +24,8 @@ const MemoList: React.FC = (props: Props) => { const [isComplete, setIsComplete] = useState(false); const currentUsername = userStore.getCurrentUsername(); - const { tag: tagQuery, duration, type: memoType, text: textQuery, visibility } = filter; - const showMemoFilter = Boolean(tagQuery || (duration && duration.from < duration.to) || memoType || textQuery || visibility); + const { tag: tagQuery, duration, text: textQuery, visibility } = filter; + const showMemoFilter = Boolean(tagQuery || (duration && duration.from < duration.to) || textQuery || visibility); const shownMemos = ( showMemoFilter @@ -55,13 +55,6 @@ const MemoList: React.FC = (props: Props) => { ) { shouldShow = false; } - if (memoType) { - if (memoType === "NOT_TAGGED" && memo.content.match(TAG_REG) !== null) { - shouldShow = false; - } else if (memoType === "LINKED" && (memo.content.match(LINK_REG) === null || memo.content.match(PLAIN_LINK_REG) === null)) { - shouldShow = false; - } - } if (textQuery && !memo.content.toLowerCase().includes(textQuery.toLowerCase())) { shouldShow = false; } diff --git a/web/src/components/ResourceSearchBar.tsx b/web/src/components/ResourceSearchBar.tsx index 39e4f834..8a52df98 100644 --- a/web/src/components/ResourceSearchBar.tsx +++ b/web/src/components/ResourceSearchBar.tsx @@ -1,5 +1,5 @@ import { useRef, useState } from "react"; -import useDebounce from "@/hooks/useDebounce"; +import useDebounce from "react-use/lib/useDebounce"; import { useTranslate } from "@/utils/i18n"; import Icon from "./Icon"; diff --git a/web/src/components/SearchBar.tsx b/web/src/components/SearchBar.tsx index e2ba3ff2..c6ed368a 100644 --- a/web/src/components/SearchBar.tsx +++ b/web/src/components/SearchBar.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from "react"; -import useDebounce from "@/hooks/useDebounce"; +import useDebounce from "react-use/lib/useDebounce"; import { useFilterStore } from "@/store/module"; import { useTranslate } from "@/utils/i18n"; import Icon from "./Icon"; diff --git a/web/src/components/TagList.tsx b/web/src/components/TagList.tsx index bbc90f58..d9d7e6d9 100644 --- a/web/src/components/TagList.tsx +++ b/web/src/components/TagList.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import useToggle from "@/hooks/useToggle"; +import useToggle from "react-use/lib/useToggle"; import { useFilterStore, useTagStore } from "@/store/module"; import { useTranslate } from "@/utils/i18n"; import showCreateTagDialog from "./CreateTagDialog"; diff --git a/web/src/components/kit/Dropdown.tsx b/web/src/components/kit/Dropdown.tsx index bc100358..6d96b252 100644 --- a/web/src/components/kit/Dropdown.tsx +++ b/web/src/components/kit/Dropdown.tsx @@ -1,5 +1,5 @@ import { ReactNode, useEffect, useRef } from "react"; -import useToggle from "@/hooks/useToggle"; +import useToggle from "react-use/lib/useToggle"; import Icon from "../Icon"; interface Props { diff --git a/web/src/components/kit/Selector.tsx b/web/src/components/kit/Selector.tsx index e5f5cb22..2b0585c0 100644 --- a/web/src/components/kit/Selector.tsx +++ b/web/src/components/kit/Selector.tsx @@ -1,6 +1,6 @@ import { Tooltip } from "@mui/joy"; import { memo, useEffect, useRef } from "react"; -import useToggle from "@/hooks/useToggle"; +import useToggle from "react-use/lib/useToggle"; import { useTranslate } from "@/utils/i18n"; import Icon from "../Icon"; import "@/less/common/selector.less"; diff --git a/web/src/hooks/index.ts b/web/src/hooks/index.ts index 2ca0fc05..af1972e8 100644 --- a/web/src/hooks/index.ts +++ b/web/src/hooks/index.ts @@ -1,4 +1 @@ -export * from "./useDebounce"; export * from "./useLoading"; -export * from "./useTimeoutFn"; -export * from "./useToggle"; diff --git a/web/src/hooks/useDebounce.ts b/web/src/hooks/useDebounce.ts deleted file mode 100644 index 1d033601..00000000 --- a/web/src/hooks/useDebounce.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { DependencyList, useEffect } from "react"; -import useTimeoutFn from "./useTimeoutFn"; - -export type UseDebounceReturn = [() => boolean | null, () => void]; - -export default function useDebounce(fn: () => any, ms = 0, deps: DependencyList = []): UseDebounceReturn { - const [isReady, cancel, reset] = useTimeoutFn(fn, ms); - - useEffect(reset, deps); - - return [isReady, cancel]; -} diff --git a/web/src/hooks/useTimeoutFn.ts b/web/src/hooks/useTimeoutFn.ts deleted file mode 100644 index a5b44b93..00000000 --- a/web/src/hooks/useTimeoutFn.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { useCallback, useEffect, useRef } from "react"; - -export type UseTimeoutFnReturn = [() => boolean | null, () => void, () => void]; - -export default function useTimeoutFn(fn: () => any, ms = 0): UseTimeoutFnReturn { - const ready = useRef(false); - const timeout = useRef>(); - const callback = useRef(fn); - - const isReady = useCallback(() => ready.current, []); - - const set = useCallback(() => { - ready.current = false; - timeout.current && clearTimeout(timeout.current); - - timeout.current = setTimeout(() => { - ready.current = true; - callback.current(); - }, ms); - }, [ms]); - - const clear = useCallback(() => { - ready.current = null; - timeout.current && clearTimeout(timeout.current); - }, []); - - // update ref when function changes - useEffect(() => { - callback.current = fn; - }, [fn]); - - // set on mount, clear on unmount - useEffect(() => { - set(); - - return clear; - }, [ms]); - - return [isReady, clear, set]; -} diff --git a/web/src/hooks/useToggle.ts b/web/src/hooks/useToggle.ts deleted file mode 100644 index 8a7b9621..00000000 --- a/web/src/hooks/useToggle.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { useCallback, useState } from "react"; - -// Parameter is the boolean, with default "false" value -const useToggle = (initialState = false): [boolean, (nextState?: boolean) => void] => { - // Initialize the state - const [state, setState] = useState(initialState); - - // Define and memorize toggler function in case we pass down the component, - // This function change the boolean value to it's opposite value - const toggle = useCallback((nextState?: boolean) => { - if (nextState !== undefined) { - setState(nextState); - } else { - setState((state) => !state); - } - }, []); - - return [state, toggle]; -}; - -export default useToggle; diff --git a/web/src/pages/DailyReview.tsx b/web/src/pages/DailyReview.tsx index 00df16cb..6a11b903 100644 --- a/web/src/pages/DailyReview.tsx +++ b/web/src/pages/DailyReview.tsx @@ -2,6 +2,7 @@ import classNames from "classnames"; import { last } from "lodash-es"; import { useEffect, useRef, useState } from "react"; import toast from "react-hot-toast"; +import useToggle from "react-use/lib/useToggle"; import DailyMemo from "@/components/DailyMemo"; import Empty from "@/components/Empty"; import Icon from "@/components/Icon"; @@ -10,7 +11,6 @@ import showPreviewImageDialog from "@/components/PreviewImageDialog"; import DatePicker from "@/components/kit/DatePicker"; import { DAILY_TIMESTAMP, DEFAULT_MEMO_LIMIT } from "@/helpers/consts"; import { convertToMillis, getDateStampByDate, getNormalizedDateString, getTimeStampByDate, isFutureDate } from "@/helpers/datetime"; -import useToggle from "@/hooks/useToggle"; import i18n from "@/i18n"; import toImage from "@/labs/html2image"; import { useMemoStore, useUserStore } from "@/store/module"; diff --git a/web/src/store/module/filter.ts b/web/src/store/module/filter.ts index 9a4f208f..4f2c14e1 100644 --- a/web/src/store/module/filter.ts +++ b/web/src/store/module/filter.ts @@ -16,20 +16,12 @@ export const useFilterStore = () => { store.dispatch( setFilter({ tag: undefined, - type: undefined, duration: undefined, text: undefined, visibility: undefined, }) ); }, - setMemoTypeFilter: (type?: MemoSpecType) => { - store.dispatch( - setFilter({ - type: type, - }) - ); - }, setTextFilter: (text?: string) => { store.dispatch( setFilter({ diff --git a/web/src/store/reducer/filter.ts b/web/src/store/reducer/filter.ts index acbe6843..e7291d82 100644 --- a/web/src/store/reducer/filter.ts +++ b/web/src/store/reducer/filter.ts @@ -8,7 +8,6 @@ interface Duration { interface State { tag?: string; duration?: Duration; - type?: MemoSpecType; text?: string; visibility?: Visibility; } diff --git a/web/src/types/filter.d.ts b/web/src/types/filter.d.ts deleted file mode 100644 index b2b73b88..00000000 --- a/web/src/types/filter.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -type MemoFilterRelation = "AND" | "OR"; - -interface BaseFilter { - type: FilterType; - value: { - operator: string; - value: string; - }; - relation: MemoFilterRelation; -} - -interface TagFilter extends BaseFilter { - type: "TAG"; - value: { - operator: "CONTAIN" | "NOT_CONTAIN"; - value: string; - }; -} - -interface TypeFilter extends BaseFilter { - type: "TYPE"; - value: { - operator: "IS" | "IS_NOT"; - value: MemoSpecType; - }; -} - -interface TextFilter extends BaseFilter { - type: "TEXT"; - value: { - operator: "CONTAIN" | "NOT_CONTAIN"; - value: string; - }; -} - -interface DisplayTimeFilter extends BaseFilter { - type: "DISPLAY_TIME"; - value: { - operator: "BEFORE" | "AFTER"; - value: string; - }; -} - -interface VisibilityFilter extends BaseFilter { - type: "VISIBILITY"; - value: { - operator: "IS" | "IS_NOT"; - value: string; - }; -} - -type FilterType = "TEXT" | "TYPE" | "TAG" | "DISPLAY_TIME" | "VISIBILITY"; - -type Filter = BaseFilter | TagFilter | TypeFilter | TextFilter | DisplayTimeFilter | VisibilityFilter;