From 1ccf3a42560822dbd1f5d145cd87da4ed902a5f0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 30 Apr 2023 12:36:48 +0200 Subject: [PATCH] Improve delayed individual collection loading. --- OtterGui | 2 +- Penumbra/Collections/Cache/CollectionCacheManager.cs | 4 ++-- .../Manager/IndividualCollections.Files.cs | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/OtterGui b/OtterGui index 99bd0a88..4ef03980 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 99bd0a889806f0560109686ca3b29a4edfa48f76 +Subproject commit 4ef03980803cdf5a253c041d6ed1ef26d9a9b938 diff --git a/Penumbra/Collections/Cache/CollectionCacheManager.cs b/Penumbra/Collections/Cache/CollectionCacheManager.cs index c1d42258..336d52a9 100644 --- a/Penumbra/Collections/Cache/CollectionCacheManager.cs +++ b/Penumbra/Collections/Cache/CollectionCacheManager.cs @@ -296,8 +296,8 @@ public class CollectionCacheManager : IDisposable .Prepend(_active.Current) .Prepend(_active.Default) .Prepend(_active.Interface) - .Distinct() - .Select(c => CreateCache(c) ? Task.Run(() => CalculateEffectiveFileListInternal(c)) : Task.CompletedTask) + .Where(CreateCache) + .Select(c => Task.Run(() => CalculateEffectiveFileListInternal(c))) .ToArray(); Task.WaitAll(tasks); diff --git a/Penumbra/Collections/Manager/IndividualCollections.Files.cs b/Penumbra/Collections/Manager/IndividualCollections.Files.cs index 94bf9b46..0ab9cbfb 100644 --- a/Penumbra/Collections/Manager/IndividualCollections.Files.cs +++ b/Penumbra/Collections/Manager/IndividualCollections.Files.cs @@ -33,10 +33,13 @@ public partial class IndividualCollections return ReadJObjectInternal(obj, storage); void Func() { - if (ReadJObjectInternal(obj, storage)) - saver.ImmediateSave(parent); - saver.DalamudFramework.RunOnFrameworkThread(() => Loaded.Invoke()); - _actorService.FinishedCreation -= Func; + saver.DalamudFramework.RunOnFrameworkThread(() => + { + if (ReadJObjectInternal(obj, storage)) + saver.ImmediateSave(parent); + Loaded.Invoke(); + _actorService.FinishedCreation -= Func; + }); } _actorService.FinishedCreation += Func; return false;