node build fixed

This commit is contained in:
ra_ma
2025-09-20 14:08:38 +01:00
parent c6ebbe069d
commit 3d298fa434
1516 changed files with 535727 additions and 2 deletions

View File

@@ -0,0 +1,79 @@
package cron
import (
"seanime/internal/core"
"time"
)
type JobCtx struct {
App *core.App
}
func RunJobs(app *core.App) {
// Run the jobs only if the server is online
ctx := &JobCtx{
App: app,
}
refreshAnilistTicker := time.NewTicker(10 * time.Minute)
refreshLocalDataTicker := time.NewTicker(30 * time.Minute)
refetchReleaseTicker := time.NewTicker(1 * time.Hour)
refetchAnnouncementsTicker := time.NewTicker(10 * time.Minute)
go func() {
for {
select {
case <-refreshAnilistTicker.C:
if *app.IsOffline() {
continue
}
RefreshAnilistDataJob(ctx)
if app.LocalManager != nil &&
!app.GetUser().IsSimulated &&
app.Settings != nil &&
app.Settings.Library != nil &&
app.Settings.Library.AutoSyncToLocalAccount {
_ = app.LocalManager.SynchronizeAnilistToSimulatedCollection()
}
}
}
}()
go func() {
for {
select {
case <-refreshLocalDataTicker.C:
if *app.IsOffline() {
continue
}
SyncLocalDataJob(ctx)
}
}
}()
go func() {
for {
select {
case <-refetchReleaseTicker.C:
if *app.IsOffline() {
continue
}
app.Updater.ShouldRefetchReleases()
}
}
}()
go func() {
for {
select {
case <-refetchAnnouncementsTicker.C:
if *app.IsOffline() {
continue
}
app.Updater.FetchAnnouncements()
}
}
}()
}

View File

@@ -0,0 +1,50 @@
package cron
import (
"seanime/internal/events"
)
func RefreshAnilistDataJob(c *JobCtx) {
defer func() {
if r := recover(); r != nil {
}
}()
if c.App.Settings == nil || c.App.Settings.Library == nil {
return
}
// Refresh the Anilist Collection
animeCollection, _ := c.App.RefreshAnimeCollection()
if c.App.Settings.GetLibrary().EnableManga {
mangaCollection, _ := c.App.RefreshMangaCollection()
c.App.WSEventManager.SendEvent(events.RefreshedAnilistMangaCollection, mangaCollection)
}
c.App.WSEventManager.SendEvent(events.RefreshedAnilistAnimeCollection, animeCollection)
}
func SyncLocalDataJob(c *JobCtx) {
defer func() {
if r := recover(); r != nil {
}
}()
if c.App.Settings == nil || c.App.Settings.Library == nil {
return
}
// Only synchronize local data if the user is not simulated
if c.App.Settings.Library.AutoSyncOfflineLocalData && !c.App.GetUser().IsSimulated {
c.App.LocalManager.SynchronizeLocal()
}
// Only synchronize local data if the user is not simulated
if c.App.Settings.Library.AutoSaveCurrentMediaOffline && !c.App.GetUser().IsSimulated {
added, _ := c.App.LocalManager.AutoTrackCurrentMedia()
if added && c.App.Settings.Library.AutoSyncOfflineLocalData {
go c.App.LocalManager.SynchronizeLocal()
}
}
}