From 855c983fc4f85b93cd3e2e89ed1f155329bfc265 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 29 Jan 2024 17:06:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E5=88=97=E8=A1=A8=E6=97=B6=E7=9A=84=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 3 ++- src/components/MusicAddModal/CreateUserList.tsx | 8 +++++--- src/lang/en_us.json | 1 + src/lang/zh_cn.json | 1 + .../Home/Views/Mylist/MyList/ListNameEdit.tsx | 12 +++++++++--- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 3889cc8..96d02cb 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -26,6 +26,7 @@ - 歌曲评论内容过长时自动折叠,需手动展开 - 改进本地音乐在线信息的匹配机制 - 移除播放服务唤醒锁,解决APP在空闲时仍然处于唤醒状态的问题 +- 添加创建同名列表时的二次确认 ### 修复 @@ -44,4 +45,4 @@ - 移除所有内置源,由于收到腾讯投诉要求停止提供软件内置的连接到他们平台的在线播放及下载服务,所以从即日(2023年10月18日)起LX本身不再提供上述服务 - 更新许可协议的排版,使其看起来更加清晰明了,更新数据来源原理说明 - 更新 React native 到 v0.73.2 -- 核心播放器从 ExoPlayer 迁移到 media3 v1.2.0 +- 核心播放器从 ExoPlayer 迁移到 media3 v1.2.1 diff --git a/src/components/MusicAddModal/CreateUserList.tsx b/src/components/MusicAddModal/CreateUserList.tsx index 74b1897..a2113fb 100644 --- a/src/components/MusicAddModal/CreateUserList.tsx +++ b/src/components/MusicAddModal/CreateUserList.tsx @@ -1,7 +1,7 @@ import { useState, useRef, useEffect } from 'react' import { View } from 'react-native' import Input, { type InputType } from '@/components/common/Input' -import { createStyle } from '@/utils/tools' +import { confirmDialog, createStyle } from '@/utils/tools' import { useI18n } from '@/lang' import { createUserList } from '@/core/list' import listState from '@/store/list/state' @@ -23,10 +23,12 @@ export default ({ isEdit, onHide }: { } }, [isEdit]) - const handleSubmitEditing = () => { + const handleSubmitEditing = async() => { onHide() const name = text.trim() - if (!name.length) return + if (!name.length || (listState.userList.some(l => l.name == name) && !(await confirmDialog({ + message: global.i18n.t('list_duplicate_tip'), + })))) return void createUserList(listState.userList.length, [{ id: `userlist_${Date.now()}`, name, locationUpdateTime: null }]) } diff --git a/src/lang/en_us.json b/src/lang/en_us.json index f51434e..8b9d064 100644 --- a/src/lang/en_us.json +++ b/src/lang/en_us.json @@ -55,6 +55,7 @@ "list_add_title_last": "to...", "list_create": "Create a new list", "list_create_input_placeholder": "What name do you think of...", + "list_duplicate_tip": "A list with the same name already exists. Do you want to continue creating it?", "list_edit_action_tip_add_failed": "add failed", "list_edit_action_tip_add_success": "Added successfully", "list_edit_action_tip_exist": "This song already exists in this list", diff --git a/src/lang/zh_cn.json b/src/lang/zh_cn.json index 6af0ad6..d46789b 100644 --- a/src/lang/zh_cn.json +++ b/src/lang/zh_cn.json @@ -55,6 +55,7 @@ "list_add_title_last": "到...", "list_create": "新建列表", "list_create_input_placeholder": "你想起啥名...", + "list_duplicate_tip": "已存在同名列表,是否继续创建?", "list_edit_action_tip_add_failed": "添加失败", "list_edit_action_tip_add_success": "添加成功", "list_edit_action_tip_exist": "该列表已经有这首歌啦", diff --git a/src/screens/Home/Views/Mylist/MyList/ListNameEdit.tsx b/src/screens/Home/Views/Mylist/MyList/ListNameEdit.tsx index 06da100..29f5e95 100644 --- a/src/screens/Home/Views/Mylist/MyList/ListNameEdit.tsx +++ b/src/screens/Home/Views/Mylist/MyList/ListNameEdit.tsx @@ -4,8 +4,9 @@ import Text from '@/components/common/Text' import { View } from 'react-native' import Input, { type InputType } from '@/components/common/Input' import { createUserList, updateUserList } from '@/core/list' -import { createStyle } from '@/utils/tools' +import { confirmDialog, createStyle } from '@/utils/tools' import { useTheme } from '@/store/theme/hook' +import listState from '@/store/list/state' interface NameInputType { setName: (text: string) => void @@ -98,8 +99,13 @@ export default forwardRef((props, ref) => { if (position == -1) { void updateUserList([{ ...selectedListInfo.current, name }]) } else { - const now = Date.now() - void createUserList(position, [{ id: `userlist_${now}`, name, locationUpdateTime: now }]) + void (listState.userList.some(l => l.name == name) ? confirmDialog({ + message: global.i18n.t('list_duplicate_tip'), + }) : Promise.resolve(true)).then(confirmed => { + if (!confirmed) return + const now = Date.now() + void createUserList(position, [{ id: `userlist_${now}`, name, locationUpdateTime: now }]) + }) } alertRef.current?.setVisible(false) }