@@ -47,8 +47,21 @@ public async ValueTask UpdateLoadOrders(LoadoutId loadoutId, Optional<Collection
4747 await sortOrderVariety . ReconcileSortOrder ( sortOrderId , token : token ) ;
4848 }
4949 }
50+
51+ protected async ValueTask CreateSortOrders ( LoadoutId loadoutId , Optional < CollectionGroupId > collectionGroupId = default , CancellationToken token = default )
52+ {
53+ var parentEntity = collectionGroupId . HasValue
54+ ? OneOf < LoadoutId , CollectionGroupId > . FromT1 ( collectionGroupId . Value )
55+ : OneOf < LoadoutId , CollectionGroupId > . FromT0 ( loadoutId ) ;
56+
57+ foreach ( var sortOrderVariety in _sortOrderVarieties . Values )
58+ {
59+ // Create the sort order for each variety
60+ _ = await sortOrderVariety . GetOrCreateSortOrderFor ( loadoutId , parentEntity , token ) ;
61+ }
62+ }
5063
51- public async ValueTask DeleteSortOrders ( LoadoutId loadoutId , Optional < CollectionGroupId > collectionGroupId = default , CancellationToken token = default )
64+ protected async ValueTask DeleteSortOrders ( LoadoutId loadoutId , Optional < CollectionGroupId > collectionGroupId = default , CancellationToken token = default )
5265 {
5366 var parentEntity = collectionGroupId . HasValue
5467 ? OneOf < LoadoutId , CollectionGroupId > . FromT1 ( collectionGroupId . Value )
@@ -107,7 +120,7 @@ protected void SubscribeToChanges(GameId gameId)
107120 case ChangeReason . Add :
108121 // Create the sort order for this loadout
109122 // Might not be needed if the other subscription to loadout items handles it
110- // await state.UpdateLoadOrders (loadoutId, token: token);
123+ await state . CreateSortOrders ( loadoutId , token : token ) ;
111124 break ;
112125 case ChangeReason . Update :
113126 // If loadout changes, we handle that in a separate subscription
@@ -141,7 +154,7 @@ protected void SubscribeToChanges(GameId gameId)
141154 case ChangeReason . Add :
142155 // Create the sort order for this collection group
143156 // Might not be needed if the other subscription to loadout items handles it
144- // await state.UpdateLoadOrders (loadoutId, parentEntity, token: token);
157+ await state . CreateSortOrders ( loadoutId , parentEntity , token : token ) ;
145158 break ;
146159 case ChangeReason . Update :
147160 // If collection group changes, we handle that in a separate subscription
0 commit comments