mirror of
https://github.com/Stone-Red-Code/Markdowser.git
synced 2026-09-09 23:41:30 +02:00
Fix formatting and some warnings
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
using Markdowser.ViewModels;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Markdowser.Utilities
|
||||
{
|
||||
namespace Markdowser.Utilities;
|
||||
|
||||
public class CacheService
|
||||
{
|
||||
private Dictionary<string, ContentViewModelBase> cache = new Dictionary<string, ContentViewModelBase>();
|
||||
private readonly Dictionary<string, ContentViewModelBase> cache = [];
|
||||
|
||||
public ContentViewModelBase? Get(string url)
|
||||
{
|
||||
if (cache.ContainsKey(url))
|
||||
if (cache.TryGetValue(url, out ContentViewModelBase? value))
|
||||
{
|
||||
return cache[url];
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -24,4 +25,3 @@ using System.Collections.Generic;
|
||||
cache[url] = content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,6 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
public ICommand Browse => ReactiveCommand.Create(() => FetchUrl(true));
|
||||
public ICommand Reload => ReactiveCommand.Create(() => FetchUrl(false));
|
||||
|
||||
|
||||
public ICommand Back => ReactiveCommand.Create(() =>
|
||||
{
|
||||
if (GlobalState.BackHistory.Count > 0)
|
||||
@@ -244,8 +243,8 @@ private void FetchUrl(bool useCache = true)
|
||||
|
||||
try
|
||||
{
|
||||
ContentViewModelBase cachedContent = cacheService.Get(Url);
|
||||
if (cachedContent != null && useCache)
|
||||
ContentViewModelBase? cachedContent = cacheService.Get(Url);
|
||||
if (cachedContent is not null && useCache)
|
||||
{
|
||||
Content = cachedContent;
|
||||
}
|
||||
@@ -316,5 +315,4 @@ private void FetchUrl(bool useCache = true)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,9 +83,8 @@
|
||||
<Grid IsEnabled="{Binding !IsBusy}" ColumnDefinitions="Auto, Auto, Auto, Auto, *, Auto">
|
||||
<Button Grid.Column="0" i:Attached.Icon="fa-solid fa-caret-left" IsEnabled="{Binding BackEnabled}" Command="{Binding Back}" />
|
||||
<Button Grid.Column="1" i:Attached.Icon="fa-solid fa-caret-right" IsEnabled="{Binding ForwardEnabled}" Command="{Binding Forward}" />
|
||||
<Button Grid.Column="2" i:Attached.Icon="fa-solid fa-rotate-right" Command="{Binding Browse}" />
|
||||
<Button Grid.Column="2" i:Attached.Icon="fa-solid fa-rotate-right" Command="{Binding Reload}" />
|
||||
<Button Grid.Column="3" i:Attached.Icon="fa-solid fa-house" Command="{StaticResource HomeCommand}" />
|
||||
<Button Grid.Column="4" i:Attached.Icon="fa-solid fa-sync" Command="{Binding Reload}" />
|
||||
|
||||
<Grid Grid.Column="4">
|
||||
<TextBox IsVisible="{Binding !IsBusy}" Watermark="Search or type a URL" Text="{Binding Url}" BorderThickness="0">
|
||||
|
||||
Reference in New Issue
Block a user