mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
fix(profiles): skip reloading current profile on URL import
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<summary><strong> 🐞 修复问题 </strong></summary>
|
||||
|
||||
- 修复「代理集合」「规则集合」订阅响应较慢时更新误报失败、且不显示真实失败原因的问题
|
||||
- 修复通过 URL 导入订阅时,即使导入的订阅并非当前使用的订阅,也会重新加载当前配置的问题
|
||||
|
||||
**🖥️ Windows**
|
||||
|
||||
|
||||
+12
-6
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user