mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix randomness of lists presented
The list of mod lists was being sorted two different times. The second time shuffled the list and then sorted using a method that made the list very consistently show the same order of mod lists. I think it was in order of most recently updated...? Now only one sort is performed and the list is properly shuffled each time the program is launched.
This commit is contained in:
parent
b9b349f2c3
commit
d2a41de104
@ -34,10 +34,10 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
|
||||
[JsonProperty("nsfw")]
|
||||
public bool NSFW { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("utility_list")]
|
||||
public bool UtilityList { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("image_contains_title")]
|
||||
public bool ImageContainsTitle { get; set; }
|
||||
|
||||
@ -50,13 +50,13 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
[JsonProperty("download_metadata")]
|
||||
public DownloadMetadata? DownloadMetadata { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[JsonIgnore]
|
||||
public ModListSummary ValidationSummary { get; set; } = new ModListSummary();
|
||||
|
||||
[JsonName("Links")]
|
||||
public class LinksObject
|
||||
{
|
||||
[JsonProperty("image")]
|
||||
[JsonProperty("image")]
|
||||
public string ImageUri { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("readme")]
|
||||
@ -92,7 +92,13 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
// ignored
|
||||
}
|
||||
|
||||
return metadata.OrderBy(m => (m.ValidationSummary?.HasFailures ?? false ? 1 : 0, m.Title)).ToList();
|
||||
var random = new Random();
|
||||
return metadata
|
||||
// Sort randomly initially, just to give each list a fair shake
|
||||
.Shuffle(random)
|
||||
// Put broken lists at bottom
|
||||
.OrderBy(m => (m.ValidationSummary?.HasFailures ?? false ? 1 : 0))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static async Task<List<ModlistMetadata>> LoadUnlistedFromGithub()
|
||||
@ -109,7 +115,7 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask<bool> NeedsDownload(AbsolutePath modlistPath)
|
||||
{
|
||||
if (!modlistPath.Exists) return true;
|
||||
@ -150,7 +156,7 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
public int Passed { get; set; }
|
||||
[JsonProperty("updating")]
|
||||
public int Updating { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("mirrored")]
|
||||
public int Mirrored { get; set; }
|
||||
|
||||
|
@ -95,7 +95,6 @@ namespace Wabbajack
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
var random = new Random();
|
||||
var sourceList = Observable.Return(Unit.Default)
|
||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||
.SelectTask(async _ =>
|
||||
@ -106,8 +105,6 @@ namespace Wabbajack
|
||||
var list = await ModlistMetadata.LoadFromGithub();
|
||||
Error = ErrorResponse.Success;
|
||||
return list
|
||||
// Sort randomly initially, just to give each list a fair shake
|
||||
.Shuffle(random)
|
||||
.AsObservableChangeSet(x => x.DownloadMetadata?.Hash ?? Hash.Empty);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -170,8 +167,6 @@ namespace Wabbajack
|
||||
return GameType == vm.Metadata.Game.GetDescription<Game>().ToString();
|
||||
|
||||
}))
|
||||
// Put broken lists at bottom
|
||||
.Sort(Comparer<ModListMetadataVM>.Create((a, b) => a.IsBroken.CompareTo(b.IsBroken)))
|
||||
.Bind(ModLists)
|
||||
.Subscribe()
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
Loading…
Reference in New Issue
Block a user