fix(profiles): skip reloading current profile on URL import

This commit is contained in:
oomeow
2026-09-27 22:48:55 +08:00
parent 5d7dc3aed9
commit a3a04a05d9
2 changed files with 13 additions and 6 deletions
+1
View File
@@ -4,6 +4,7 @@
<summary><strong> 🐞 修复问题 </strong></summary>
- 修复「代理集合」「规则集合」订阅响应较慢时更新误报失败、且不显示真实失败原因的问题
- 修复通过 URL 导入订阅时,即使导入的订阅并非当前使用的订阅,也会重新加载当前配置的问题
**🖥️ Windows**
+12 -6
View File
@@ -221,10 +221,12 @@ const ProfilePage = () => {
}
setLoading(true)
const prevCurrent = profiles.current
const handleImportSuccess = async (noticeKey: string) => {
showNotice.success(noticeKey)
setUrl('')
await performRobustRefresh()
await performRobustRefresh(prevCurrent)
}
try {
await importProfile(url)
@@ -260,7 +262,7 @@ const ProfilePage = () => {
}
// `useProfiles` already retries three times; add only one business-level retry.
const performRobustRefresh = async () => {
const performRobustRefresh = async (prevCurrent?: string) => {
let retryCount = 0
const maxRetries = 1
const baseDelay = 200
@@ -269,13 +271,15 @@ const ProfilePage = () => {
try {
debugLog(`[导入刷新] 第${retryCount + 1}次尝试刷新配置数据`)
await mutateProfiles()
const fresh = await fetchProfilesIntoCache()
await new Promise((resolve) =>
setTimeout(resolve, baseDelay * (retryCount + 1)),
)
await onEnhance(false)
if (fresh?.current !== prevCurrent) {
await onEnhance(false)
}
return
} catch (error) {
console.error(`[导入刷新] 第${retryCount + 1}次刷新失败:`, error)
@@ -288,8 +292,10 @@ const ProfilePage = () => {
console.warn(`[导入刷新] 常规刷新失败,尝试清除缓存重新获取`)
try {
await fetchProfilesIntoCache()
await onEnhance(false)
const fresh = await fetchProfilesIntoCache()
if (fresh?.current !== prevCurrent) {
await onEnhance(false)
}
showNotice.error(
'profiles.page.feedback.notifications.importNeedsRefresh',
3000,