Skip to content

Commit

Permalink
バージョンを1.2.2から1.2.3に更新し、新規タスクの追加とIDの更新を行う
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun-Murakami committed May 14, 2024
1 parent 29a60c1 commit 469153d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.tasktrees.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 7
versionName "1.2.2"
versionCode 8
versionName "1.2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tasktree-s",
"private": true,
"version": "1.2.2",
"version": "1.2.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
12 changes: 8 additions & 4 deletions src/components/SortableTree/SortableTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,11 @@ export function SortableTree({ collapsible, indicator = false, indentationWidth
setItems(newItems);
}
} else {
// 新規タスクの場合、新規タスクを削除
// 新規タスクの場合、新規タスクを先頭に移動し、IDを最大ID+1に更新
if (active.id === activeNewTaskId || active.id === activeQuickMemoId) {
setItems(items.filter((item) => item.id !== active.id));
const newId = (findMaxId(items) + 1).toString();
const updatedItems = items.map((item) => (item.id === active.id ? { ...item, id: newId, value: '' } : item));
setItems([updatedItems.find((item) => item.id === newId)!, ...items.filter((item) => item.id !== active.id)]);
const newActiveId = (parseInt(active.id.toString()) - 1).toString();
if (active.id === activeNewTaskId) {
setActiveNewTaskId(newActiveId);
Expand All @@ -387,9 +389,11 @@ export function SortableTree({ collapsible, indicator = false, indentationWidth

function handleDragCancel() {
resetState();
// 新規タスクの場合、新規タスクを削除
// 新規タスクの場合、新規タスクを先頭に移動し、IDを最大ID+1に更新
if (activeId === activeNewTaskId || activeId === activeQuickMemoId) {
setItems(items.filter((item) => item.id !== activeId));
const newId = (findMaxId(items) + 1).toString();
const updatedItems = items.map((item) => (item.id === activeId ? { ...item, id: newId, value: '' } : item));
setItems([updatedItems.find((item) => item.id === newId)!, ...items.filter((item) => item.id !== activeId)]);
const newActiveId = (parseInt(activeId.toString()) - 1).toString();
if (activeId === activeNewTaskId) {
setActiveNewTaskId(newActiveId);
Expand Down

0 comments on commit 469153d

Please sign in to comment.