fix per comment

This commit is contained in:
Jeremy Wu 2021-01-27 06:17:24 +11:00
parent 889c853e33
commit ccc677fd8f
3 changed files with 21 additions and 25 deletions

View file

@ -63,27 +63,17 @@ namespace Flow.Launcher.Plugin.Explorer
SubTitle = $"Add the current {fileOrFolder} to Quick Access",
Action = (context) =>
{
try
{
Settings.QuickAccessLinks.Add(new AccessLink { Path = record.FullPath, Type = record.Type });
Settings.QuickAccessLinks.Add(new AccessLink { Path = record.FullPath, Type = record.Type });
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess"),
string.Format(
Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess_detail"),
fileOrFolder),
Constants.ExplorerIconImageFullPath);
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess"),
string.Format(
Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess_detail"),
fileOrFolder),
Constants.ExplorerIconImageFullPath);
ViewModel.Save();
ViewModel.Save();
return true;
}
catch (Exception e)
{
var message = "Fail to add to Quick Access";
LogException(message, e);
Context.API.ShowMsg(message);
return false;
}
return true;
},
IcoPath = Constants.QuickAccessImagePath
});

View file

@ -36,7 +36,10 @@ namespace Flow.Launcher.Plugin.Explorer
// as at v1.7.0 this is to maintain backwards compatibility, need to be removed afterwards.
if (Settings.QuickFolderAccessLinks.Any())
{
Settings.QuickAccessLinks = Settings.QuickFolderAccessLinks;
Settings.QuickFolderAccessLinks = null;
}
contextMenu = new ContextMenu(Context, Settings, viewModel);
searchManager = new SearchManager(Settings, Context);

View file

@ -21,34 +21,37 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
string search = query.Search.ToLower();
var queriedAccessLinks =
accessLinks.Where(x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
accessLinks
.Where(x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase))
.OrderBy(x => x.Type)
.ThenBy(x => x.Nickname);
return queriedAccessLinks
.Where(x => x.Type == ResultType.Folder)
.Select(item =>
resultManager.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
.OrderBy(x => x.Title)
.Concat(
queriedAccessLinks
.Where(x => x.Type == ResultType.File)
.Select(item =>
resultManager.CreateFileResult(item.Path, query))
.OrderBy(x => x.Title))
resultManager.CreateFileResult(item.Path, query)))
.ToList();
}
internal List<Result> AccessLinkListAll(Query query, List<AccessLink> accessLinks)
=> accessLinks
.OrderBy(x => x.Type)
.ThenBy(x => x.Nickname)
.Where(x => x.Type == ResultType.Folder)
.Select(item =>
resultManager.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
.OrderBy(x => x.Title)
.Concat(
accessLinks
.OrderBy(x => x.Type)
.ThenBy(x => x.Nickname)
.Where(x => x.Type == ResultType.File)
.Select(item =>
resultManager.CreateFileResult(item.Path, query))
.OrderBy(x => x.Title))
resultManager.CreateFileResult(item.Path, query)))
.ToList();
}
}