Skip to content

Commit

Permalink
Fix bugs related to theme download and hiding tray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Aug 27, 2022
1 parent d5670af commit e44d0e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/AppContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ private void OnArgumentsReceived(string[] args)
{
if (JsonConfig.settings.hideTrayIcon)
{
ToggleTrayIcon();
notifyIcon.ContextMenuStrip.BeginInvoke(ToggleTrayIcon);
}

ThemeManager.importPaths.AddRange(args);

if (args.Length > 0 && !ThemeManager.importMode)
{
notifyIcon.ContextMenuStrip.BeginInvoke(new Action(() => ThemeManager.SelectTheme()));
notifyIcon.ContextMenuStrip.BeginInvoke(ThemeManager.SelectTheme);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/DownloadDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public DownloadDialog()
inactiveTimer = new System.Timers.Timer();
inactiveTimer.AutoReset = false;
inactiveTimer.Interval = 10000;
inactiveTimer.Elapsed += (sender, e) => OnDownloadFileCompleted(null);
inactiveTimer.Elapsed += (sender, e) => this.Invoke(new Action(() => OnDownloadFileCompleted(null)));
progressReport = new Progress<ICopyProgress>(OnDownloadProgressChanged);
}

Expand Down Expand Up @@ -110,7 +110,7 @@ private bool EnsureZipNotHtml()

private void OnDownloadProgressChanged(ICopyProgress e)
{
if (e.TransferTime.TotalMilliseconds < (downloadTime + 200))
if (tokenSource.IsCancellationRequested || e.TransferTime.TotalMilliseconds < (downloadTime + 200))
{
return;
}
Expand Down Expand Up @@ -150,6 +150,7 @@ private async void OnDownloadFileCompleted(HttpResponseMessage response)
}
else
{
tokenSource.Cancel();
themeUriIndex++;

if (themeUriIndex >= themeUris.Count)
Expand Down
2 changes: 1 addition & 1 deletion src/IpcManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void ListenForArgs(Action<string[]> listener)
namedPipeServer.WaitForConnection();
}

listener(reader.ReadToEnd().Split(Environment.NewLine));
listener(reader.ReadToEnd().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries));
namedPipeServer.Disconnect();
}

Expand Down
3 changes: 2 additions & 1 deletion src/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public static bool IsTheme4Segment(ThemeConfig theme)
public static bool IsThemeDownloaded(ThemeConfig theme)
{
string themePath = Path.Combine("themes", theme.themeId);
return (Directory.Exists(themePath) && (Directory.GetFiles(themePath, theme.imageFilename).Length > 0));
return (File.Exists(Path.Combine(themePath, "theme.json")) &&
(Directory.GetFiles(themePath, theme.imageFilename).Length > 0));
}

public static void DisableTheme(string themeId, bool permanent)
Expand Down
2 changes: 1 addition & 1 deletion src/WallpaperEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void SetWallpaper(DisplayEvent e)
{
return;
}

AppContext.Log("Setting wallpaper to {0}", imagePath);
UwpDesktop.GetHelper().SetWallpaper(imagePath, e.displayIndex);
e.lastImagePath = imagePath;
Expand Down

0 comments on commit e44d0e5

Please sign in to comment.