mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 01:20:21 +00:00 
			
		
		
		
	Fixed background update service
This commit is contained in:
		
							parent
							
								
									7b5d2df873
								
							
						
					
					
						commit
						718beb85ac
					
				@ -14,10 +14,11 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
 | 
			
		||||
    private static ISnackbar? SNACKBAR;
 | 
			
		||||
    
 | 
			
		||||
    private readonly SettingsManager settingsManager;
 | 
			
		||||
    private readonly TimeSpan updateInterval;
 | 
			
		||||
    private readonly MessageBus messageBus;
 | 
			
		||||
    private readonly Rust rust;
 | 
			
		||||
    
 | 
			
		||||
    private TimeSpan updateInterval;
 | 
			
		||||
    
 | 
			
		||||
    public UpdateService(MessageBus messageBus, SettingsManager settingsManager, Rust rust)
 | 
			
		||||
    {
 | 
			
		||||
        this.settingsManager = settingsManager;
 | 
			
		||||
@ -26,8 +27,16 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
 | 
			
		||||
 | 
			
		||||
        this.messageBus.RegisterComponent(this);
 | 
			
		||||
        this.ApplyFilters([], [ Event.USER_SEARCH_FOR_UPDATE ]);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
        this.updateInterval = settingsManager.ConfigurationData.UpdateBehavior switch
 | 
			
		||||
    #region Overrides of BackgroundService
 | 
			
		||||
 | 
			
		||||
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 | 
			
		||||
    {
 | 
			
		||||
        while (!stoppingToken.IsCancellationRequested && !IS_INITIALIZED)
 | 
			
		||||
            await Task.Delay(TimeSpan.FromSeconds(3), stoppingToken);
 | 
			
		||||
 | 
			
		||||
        this.updateInterval = this.settingsManager.ConfigurationData.UpdateBehavior switch
 | 
			
		||||
        {
 | 
			
		||||
            UpdateBehavior.NO_CHECK => Timeout.InfiniteTimeSpan,
 | 
			
		||||
            UpdateBehavior.ONCE_STARTUP => Timeout.InfiniteTimeSpan,
 | 
			
		||||
@ -38,21 +47,11 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
 | 
			
		||||
            
 | 
			
		||||
            _ => TimeSpan.FromHours(1)
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
        
 | 
			
		||||
    #region Overrides of BackgroundService
 | 
			
		||||
        if(this.settingsManager.ConfigurationData.UpdateBehavior is UpdateBehavior.NO_CHECK)
 | 
			
		||||
            return;
 | 
			
		||||
        
 | 
			
		||||
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 | 
			
		||||
    {
 | 
			
		||||
        while (!stoppingToken.IsCancellationRequested && !IS_INITIALIZED)
 | 
			
		||||
        {
 | 
			
		||||
            await Task.Delay(TimeSpan.FromSeconds(1), stoppingToken);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await this.settingsManager.LoadSettings();
 | 
			
		||||
        if(this.settingsManager.ConfigurationData.UpdateBehavior != UpdateBehavior.NO_CHECK)
 | 
			
		||||
        await this.CheckForUpdate();
 | 
			
		||||
        
 | 
			
		||||
        while (!stoppingToken.IsCancellationRequested)
 | 
			
		||||
        {
 | 
			
		||||
            await Task.Delay(this.updateInterval, stoppingToken);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user