1
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
string Description,
|
||||
string Homepage,
|
||||
string DirName,
|
||||
bool IsInUse
|
||||
bool IsInUse,
|
||||
DateTime LastWriteTime
|
||||
);
|
||||
|
||||
public class GetThemesQueryHandler(IOptionsMonitor<BlogSettings> options, IMapper mapper, IWebHostEnvironment env) : IRequestHandler<GetThemesQuery, List<GetThemesQueryResponse>>
|
||||
@@ -32,11 +33,14 @@
|
||||
var jsonPath = Path.Combine(directory, "config.json");
|
||||
if(!File.Exists(jsonPath)) continue;
|
||||
|
||||
var lastWriteTime = File.GetCreationTime(jsonPath);
|
||||
|
||||
var json = File.ReadAllText(jsonPath);
|
||||
|
||||
var theme = JsonConvert.DeserializeObject<ThemeModel>(json);
|
||||
|
||||
theme.DirName = dir.Name;
|
||||
theme.LastWriteTime = lastWriteTime;
|
||||
if (theme.DirName == _settings.Theme)
|
||||
{
|
||||
theme.IsInUse = true;
|
||||
@@ -45,7 +49,7 @@
|
||||
themes.Add(_mapper.Map<GetThemesQueryResponse>(theme));
|
||||
}
|
||||
|
||||
themes = themes.OrderByDescending(x=>x.IsInUse).ToList();
|
||||
themes = themes.OrderByDescending(x=>x.IsInUse).ThenBy(x=>x.LastWriteTime).ToList();
|
||||
|
||||
return themes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user