Fix Font NullReferenceException
This commit is contained in:
@@ -9,7 +9,7 @@ namespace FileTime.GuiApp.Services;
|
||||
public class FontService : IFontService
|
||||
{
|
||||
private readonly IOptionsMonitor<FontConfiguration> _fontConfiguration;
|
||||
|
||||
|
||||
private readonly BehaviorSubject<string?> _mainFont = new(null);
|
||||
public IObservable<string?> MainFont => _mainFont.DistinctUntilChanged();
|
||||
|
||||
@@ -17,7 +17,7 @@ public class FontService : IFontService
|
||||
{
|
||||
_fontConfiguration = fontConfiguration;
|
||||
fontConfiguration.OnChange(UpdateFonts);
|
||||
|
||||
|
||||
UpdateFonts(fontConfiguration.CurrentValue, null);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ public class FontService : IFontService
|
||||
public string? GetMainFont()
|
||||
{
|
||||
var installedFonts = FontManager.Current.GetInstalledFontFamilyNames().ToList();
|
||||
return _fontConfiguration.CurrentValue.Main.FirstOrDefault(f => installedFonts.Contains(f));
|
||||
return _fontConfiguration.CurrentValue.Main.Find(installedFonts.Contains);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
using System.Reflection;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reflection;
|
||||
using Avalonia.Input;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.UserCommand;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Services;
|
||||
using FileTime.Core.Timeline;
|
||||
using FileTime.GuiApp.Services;
|
||||
using FileTime.Providers.Local;
|
||||
using InitableService;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MvvmGen;
|
||||
|
||||
@@ -31,7 +27,7 @@ namespace FileTime.GuiApp.ViewModels;
|
||||
public partial class MainWindowViewModel : IMainWindowViewModelBase
|
||||
{
|
||||
public bool Loading => false;
|
||||
public IObservable<string?> MainFont => _fontService.MainFont;
|
||||
public IObservable<string?> MainFont => _fontService.MainFont.Select(x => x ?? "");
|
||||
public IGuiAppState AppState => _appState;
|
||||
public string Title { get; private set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user