添加创建同名列表时的二次确认

This commit is contained in:
lyswhut 2024-01-29 17:06:43 +08:00
parent 4393e5333d
commit 855c983fc4
5 changed files with 18 additions and 7 deletions

View File

@ -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

View File

@ -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 }])
}

View File

@ -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",

View File

@ -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": "该列表已经有这首歌啦",

View File

@ -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<ListNameEditType, {}>((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)
}