Skip to content

Commit

Permalink
[Store] Search from drag-and-drop links, text
Browse files Browse the repository at this point in the history
  • Loading branch information
KimihikoAkayasaki committed Mar 12, 2023
1 parent da830c1 commit 2b87e95
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions Amethyst/Pages/Plugins.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ await ExecuteSearch(query // The provided text is a link
else
{
// Only a search query
await ExecuteSearch(query);
await ExecuteSearch(query);
}
}

Expand Down Expand Up @@ -281,14 +281,50 @@ private async void SearcherGrid_Drop(object sender, DragEventArgs e)
// - Check if it's actually from GitHub
// - Search for the releases and the manifest
// - Install the plugin and prompt to restart
}

if (e.DataView.Contains(StandardDataFormats.Text))
if (uri.ToString().EndsWith(".zip"))
{
// The provided text is a link to the plugin zip, process as drag-and-drop
// TODO DRAGANDDROP
}
else if (uri.ToString().StartsWith("https://github.com/") ||
uri.ToString().StartsWith("http://github.com/"))
{
SearchTextBox.Text = uri.ToString();
await ExecuteSearch(uri.ToString() // The provided text is a link
.Replace("https://github.com/", string.Empty)
.Replace("http://github.com/", string.Empty));
}
else
{
SearchTextBox.Text = uri.ToString();
await ExecuteSearch(uri.ToString());
}
}
else if (e.DataView.Contains(StandardDataFormats.Text))
{
var uri = await e.DataView.GetTextAsync();
Logger.Info($"Dropped a web link! Data: {uri}");
var text = await e.DataView.GetTextAsync();
Logger.Info($"Dropped a text chunk! Data: {text}");

// (The same as upper)
if (text.EndsWith(".zip") && Uri.TryCreate(text, UriKind.Absolute, out _))
{
// The provided text is a link to the plugin zip, process as drag-and-drop
// TODO DRAGANDDROP
}
else if (text.StartsWith("https://github.com/") ||
text.StartsWith("http://github.com/"))
{
SearchTextBox.Text = text;
await ExecuteSearch(text // The provided text is a link
.Replace("https://github.com/", string.Empty)
.Replace("http://github.com/", string.Empty));
}
else
{
SearchTextBox.Text = text;
await ExecuteSearch(text);
}
}
else if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
Expand Down

0 comments on commit 2b87e95

Please sign in to comment.