Skip to content

Commit 20d1eb0

Browse files
author
pompurin404
committed
fix auto update profile
1 parent 6edb0a6 commit 20d1eb0

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/main/core/profileUpdater.ts

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
1-
import { addProfileItem, getProfileConfig, getProfileItem } from '../config'
1+
import { addProfileItem, getCurrentProfileItem, getProfileConfig, getProfileItem } from '../config'
22

33
const intervalPool: Record<string, NodeJS.Timeout> = {}
44

55
export function initProfileUpdater(): void {
6-
const { items } = getProfileConfig()
7-
8-
for (const item of items) {
6+
const { items, current } = getProfileConfig()
7+
const currentItem = getCurrentProfileItem()
8+
for (const item of items.filter((i) => i.id !== current)) {
99
if (item.type === 'remote' && item.interval) {
10-
addProfileItem(getProfileItem(item.id))
10+
addProfileItem(item)
1111
intervalPool[item.id] = setInterval(
1212
() => {
13-
addProfileItem(getProfileItem(item.id))
13+
addProfileItem(item)
1414
},
1515
item.interval * 60 * 1000
1616
)
1717
}
1818
}
19+
if (currentItem.type === 'remote' && currentItem.interval) {
20+
addProfileItem(currentItem)
21+
intervalPool[currentItem.id] = setInterval(
22+
() => {
23+
addProfileItem(currentItem)
24+
},
25+
currentItem.interval * 60 * 1000 + 10000 // +10s
26+
)
27+
}
1928
}
2029

2130
export function addProfileUpdater(id: string): void {
22-
const { items } = getProfileConfig()
23-
const item = items.find((i) => i.id === id)
31+
const item = getProfileItem(id)
2432

25-
if (item?.type === 'remote' && item.interval) {
33+
if (item.type === 'remote' && item.interval) {
2634
if (intervalPool[id]) {
2735
clearInterval(intervalPool[id])
2836
}
2937
intervalPool[id] = setInterval(
3038
() => {
31-
addProfileItem(getProfileItem(id))
39+
addProfileItem(item)
3240
},
3341
item.interval * 60 * 1000
3442
)

src/main/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if (!gotTheLock) {
6161
startCore().then(() => {
6262
setTimeout(() => {
6363
initProfileUpdater()
64-
}, 30000)
64+
}, 10000)
6565
})
6666
// Default open or close DevTools by F12 in development
6767
// and ignore CommandOrControl + R in production.

0 commit comments

Comments
 (0)