| 45 | } |
| 46 | |
| 47 | export async function initUserProgressScheduler() { |
| 48 | setTimeout(async () => { |
| 49 | const progressInterval = await api.settings.getAsync('progressInterval'); |
| 50 | const progressSyncLast = await api.storage.get('progressSyncLast'); |
| 51 | if (Date.now() - progressSyncLast < progressInterval * 60 * 1000) { |
| 52 | con.log('Progress on time'); |
| 53 | return; |
| 54 | } |
| 55 | if (await main()) { |
| 56 | api.storage.set('progressSyncLast', Date.now()); |
| 57 | } |
| 58 | }, 30 * 1000); |
| 59 | } |
| 60 | |
| 61 | async function main() { |
| 62 | const alive = new KeepAlive(); |