From e133931bdb29a2adb823b03cce9f2be9631c507b Mon Sep 17 00:00:00 2001 From: Mark Grimes Date: Tue, 23 Jul 2024 11:07:45 -0400 Subject: [PATCH] fix: switch to use-long-press which supports cancelOnMovement --- dist/manifest.json | 2 +- dist/versions.json | 3 ++- manifest.json | 2 +- package.json | 6 +++--- pnpm-lock.yaml | 27 ++++++++++++--------------- src/ui/todoview.tsx | 10 ++++++++-- versions.json | 3 ++- 7 files changed, 29 insertions(+), 24 deletions(-) diff --git a/dist/manifest.json b/dist/manifest.json index 1a0ad8a..4d7ea68 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,7 +1,7 @@ { "id": "todotxt", "name": "TodoTxt", - "version": "2.1.6", + "version": "2.1.7", "minAppVersion": "0.15.0", "description": "Manage Todo.txt files.", "author": "Mark Grimes", diff --git a/dist/versions.json b/dist/versions.json index d3d8965..ec4d053 100644 --- a/dist/versions.json +++ b/dist/versions.json @@ -29,5 +29,6 @@ "2.1.1": "0.15.0", "2.1.2": "0.15.0", "2.1.5": "0.15.0", - "2.1.6": "0.15.0" + "2.1.6": "0.15.0", + "2.1.7": "0.15.0" } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 1a0ad8a..4d7ea68 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "todotxt", "name": "TodoTxt", - "version": "2.1.6", + "version": "2.1.7", "minAppVersion": "0.15.0", "description": "Manage Todo.txt files.", "author": "Mark Grimes", diff --git a/package.json b/package.json index 785b0b0..12214b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-sample-plugin", - "version": "2.1.6", + "version": "2.1.7", "description": "This is a sample plugin for Obsidian (https://obsidian.md)", "main": "dist/main.js", "scripts": { @@ -47,10 +47,10 @@ "zx": "^7.2.2" }, "dependencies": { - "@uidotdev/usehooks": "^2.4.1", "luxon": "^3.4.2", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "use-long-press": "^3.2.0" }, "packageManager": "pnpm@9.6.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index db95663..dd85ae4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: dependencies: - '@uidotdev/usehooks': - specifier: ^2.4.1 - version: 2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) luxon: specifier: ^3.4.2 version: 3.4.4 @@ -20,6 +17,9 @@ importers: react-dom: specifier: ^18.2.0 version: 18.3.1(react@18.3.1) + use-long-press: + specifier: ^3.2.0 + version: 3.2.0(react@18.3.1) devDependencies: '@jest/globals': specifier: ^29.6.4 @@ -554,13 +554,6 @@ packages: resolution: {integrity: sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==} engines: {node: ^16.0.0 || >=18.0.0} - '@uidotdev/usehooks@2.4.1': - resolution: {integrity: sha512-1I+RwWyS+kdv3Mv0Vmc+p0dPYH0DTRAo04HLyXReYBL9AeseDWUJyi4THuksBJcu9F0Pih69Ak150VDnqbVnXg==} - engines: {node: '>=16'} - peerDependencies: - react: '>=18.0.0' - react-dom: '>=18.0.0' - '@ungap/structured-clone@1.2.0': resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} @@ -2056,6 +2049,11 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + use-long-press@3.2.0: + resolution: {integrity: sha512-uq5o2qFR1VRjHn8Of7Fl344/AGvgk7C5Mcb4aSb1ZRVp6PkgdXJJLdRrlSTJQVkkQcDuqFbFc3mDX4COg7mRTA==} + peerDependencies: + react: '>=16.8.0' + util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -2781,11 +2779,6 @@ snapshots: '@typescript-eslint/types': 6.21.0 eslint-visitor-keys: 3.4.3 - '@uidotdev/usehooks@2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': - dependencies: - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - '@ungap/structured-clone@1.2.0': {} acorn-jsx@5.3.2(acorn@8.12.1): @@ -4358,6 +4351,10 @@ snapshots: dependencies: punycode: 2.3.1 + use-long-press@3.2.0(react@18.3.1): + dependencies: + react: 18.3.1 + util-deprecate@1.0.2: {} v8-to-istanbul@9.3.0: diff --git a/src/ui/todoview.tsx b/src/ui/todoview.tsx index be227f5..49427d4 100644 --- a/src/ui/todoview.tsx +++ b/src/ui/todoview.tsx @@ -11,7 +11,7 @@ import { TodoProject, TodoTag, } from '../lib/todo'; -import { useLongPress } from '@uidotdev/usehooks'; +import { useLongPress } from 'use-long-press'; import cn from '../lib/classNames'; type TodoViewProps = { @@ -25,8 +25,14 @@ type TodoViewProps = { }; export const TodoView = (props: TodoViewProps) => { const { todo } = props; - const longPressProps = useLongPress(() => props.onEditClicked(todo), { + const longPressCB = React.useCallback( + () => props.onEditClicked(todo), + [props], + ); + + const longPressProps = useLongPress(longPressCB, { threshold: 500, + cancelOnMovement: true, }); return ( diff --git a/versions.json b/versions.json index d3d8965..ec4d053 100644 --- a/versions.json +++ b/versions.json @@ -29,5 +29,6 @@ "2.1.1": "0.15.0", "2.1.2": "0.15.0", "2.1.5": "0.15.0", - "2.1.6": "0.15.0" + "2.1.6": "0.15.0", + "2.1.7": "0.15.0" } \ No newline at end of file