BUG-1894: Postponing history loading as long as possible, this reduces the Imgur activity dramatically (as it's not loaded during start) and should at least prevent a 429 early on... hopefully. It would be better to cache everything locally on the user's PC, but this is unrealistic with .NET 2.0 technology (not impossible, but so time consuming that it would be better to wait for the next Greenshot version with 4.5).

This commit is contained in:
Robin 2016-11-16 09:09:28 +01:00
commit ede5bfef97
8 changed files with 85 additions and 52 deletions

View file

@ -29,22 +29,37 @@ using Greenshot.IniFile;
namespace GreenshotImgurPlugin {
/// <summary>
/// Description of ImgurHistory.
/// Imgur history form
/// </summary>
public sealed partial class ImgurHistory : ImgurForm {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ImgurHistory));
private readonly GreenshotColumnSorter _columnSorter;
private static readonly object Lock = new object();
private static readonly ImgurConfiguration Config = IniConfig.GetIniSection<ImgurConfiguration>();
private static ImgurHistory _instance;
public static void ShowHistory() {
// Make sure the history is loaded, will be done only once
ImgurUtils.LoadHistory();
if (_instance == null) {
_instance = new ImgurHistory();
lock (Lock)
{
if (ImgurUtils.IsHistoryLoadingNeeded())
{
// Run upload in the background
new PleaseWaitForm().ShowAndWait("Imgur " + Language.GetString("imgur", LangKey.history), Language.GetString("imgur", LangKey.communication_wait),
ImgurUtils.LoadHistory
);
}
// Make sure the history is loaded, will be done only once
if (_instance == null)
{
_instance = new ImgurHistory();
}
if (!_instance.Visible)
{
_instance.Show();
}
_instance.Redraw();
}
_instance.Show();
_instance.Redraw();
}
private ImgurHistory() {