fix update error

This commit is contained in:
pompurin404 2024-08-13 16:12:56 +08:00
parent 71bb2c5f05
commit bedf3f8173
No known key found for this signature in database
2 changed files with 3 additions and 2 deletions

View File

@ -55,13 +55,12 @@ export async function updateProfileItem(item: IProfileItem): Promise<void> {
}
config.items[index] = item
await setProfileConfig(config)
await addProfileUpdater(item)
}
export async function addProfileItem(item: Partial<IProfileItem>): Promise<void> {
const newItem = await createProfile(item)
const config = await getProfileConfig()
if (await getProfileItem(item.id)) {
if (await getProfileItem(newItem.id)) {
await updateProfileItem(newItem)
} else {
config.items.push(newItem)

View File

@ -35,6 +35,8 @@ const Profiles: React.FC = () => {
setImporting(true)
try {
await addProfileItem({ name: '', type: 'remote', url })
} catch (e) {
alert(e)
} finally {
setImporting(false)
}