Skip to content

Commit

Permalink
fix: switch to use-long-press which supports cancelOnMovement
Browse files Browse the repository at this point in the history
  • Loading branch information
mvgrimes committed Jul 23, 2024
1 parent 6e8532d commit e133931
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion dist/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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"
}
27 changes: 12 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/ui/todoview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 (
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit e133931

Please sign in to comment.