public static async Task <PostResult> UploadDeckAsync(Deck deck, bool saveFilesAfter = true, bool background = false)
        {
            //await Task.Delay(1000);
            //return true;
            Logger.WriteLine("trying to upload deck " + deck, "HearthStatsManager");
            if (!HearthStatsAPI.IsLoggedIn)
            {
                Logger.WriteLine("error: not logged in", "HearthStatsManager");
                return(PostResult.Failed);
            }

            if (background)
            {
                AddBackgroundActivity();
            }
            var first = deck.GetVersion(1, 0);

            if (!first.IsArenaDeck && first.HasHearthStatsId && !deck.HasHearthStatsId && !deck.HearthStatsIdsAlreadyReset)
            {
                first.HearthStatsId = first.HearthStatsIdForUploading;
                await HearthStatsAPI.DeleteDeckAsync(first);

                await Task.Delay(1000);

                //reset everything
                foreach (var version in deck.VersionsIncludingSelf.Select(deck.GetVersion))
                {
                    version.ResetHearthstatsIds();
                    foreach (var game in version.DeckStats.Games)
                    {
                        game.HearthStatsDeckId        = null;
                        game.HearthStatsDeckVersionId = null;
                        game.HearthStatsId            = null;
                    }
                }
            }
            var result = await HearthStatsAPI.PostDeckAsync(first);

            if (!result.Success && result.Retry)
            {
                await Task.Delay(RetryDelay);

                Logger.WriteLine("try #2 to upload deck " + deck, "HearthStatsManager");
                result = await HearthStatsAPI.PostDeckAsync(first);
            }
            if (result.Success)
            {
                var versions =
                    deck.VersionsIncludingSelf.Where(v => v != new SerializableVersion(1, 0))
                    .Select(deck.GetVersion)
                    .Where(d => d != null && !d.HasHearthStatsDeckVersionId)
                    .ToList();
                if (versions.Any())
                {
                    foreach (var v in versions)
                    {
                        await Task.Delay(VersionDelay);
                        await UploadVersionAsync(v, first.HearthStatsIdForUploading, false);
                    }
                    deck.HearthStatsId              = first.HearthStatsId;
                    first.HearthStatsId             = "";
                    first.HearthStatsIdForUploading = deck.HearthStatsId;
                }
                if (saveFilesAfter)
                {
                    DeckList.Save();
                }
                if (background)
                {
                    RemoveBackgroundActivity();
                }
                Logger.WriteLine("success uploading deck " + deck, "HearthStatsManager");
                return(PostResult.WasSuccess);
            }
            if (background)
            {
                RemoveBackgroundActivity();
            }
            return(PostResult.Failed);
        }