@@ -27,6 +27,8 @@ public class AddGroupServerViewModel : MyReactiveObject
2727
2828 public IObservableCollection < ProfileItem > ChildItemsObs { get ; } = new ObservableCollectionExtended < ProfileItem > ( ) ;
2929
30+ public IObservableCollection < ProfileItem > AllProfilePreviewItemsObs { get ; } = new ObservableCollectionExtended < ProfileItem > ( ) ;
31+
3032 //public ReactiveCommand<Unit, Unit> AddCmd { get; }
3133 public ReactiveCommand < Unit , Unit > RemoveCmd { get ; }
3234
@@ -182,6 +184,32 @@ public async Task MoveServer(EMove eMove)
182184 await Task . CompletedTask ;
183185 }
184186
187+ private ProtocolExtraItem GetUpdatedProtocolExtra ( )
188+ {
189+ return SelectedSource . GetProtocolExtra ( ) with
190+ {
191+ ChildItems =
192+ Utils . List2String ( ChildItemsObs . Where ( s => ! s . IndexId . IsNullOrEmpty ( ) ) . Select ( s => s . IndexId ) . ToList ( ) ) ,
193+ MultipleLoad = PolicyGroupType switch
194+ {
195+ var s when s == ResUI . TbLeastPing => EMultipleLoad . LeastPing ,
196+ var s when s == ResUI . TbFallback => EMultipleLoad . Fallback ,
197+ var s when s == ResUI . TbRandom => EMultipleLoad . Random ,
198+ var s when s == ResUI . TbRoundRobin => EMultipleLoad . RoundRobin ,
199+ var s when s == ResUI . TbLeastLoad => EMultipleLoad . LeastLoad ,
200+ _ => EMultipleLoad . LeastPing ,
201+ } ,
202+ SubChildItems = SelectedSubItem ? . Id ,
203+ Filter = Filter ,
204+ } ;
205+ }
206+
207+ public async Task UpdatePreviewList ( )
208+ {
209+ AllProfilePreviewItemsObs . Clear ( ) ;
210+ AllProfilePreviewItemsObs . AddRange ( await GroupProfileManager . GetChildProfileItemsByProtocolExtra ( GetUpdatedProtocolExtra ( ) ) ) ;
211+ }
212+
185213 private async Task SaveServerAsync ( )
186214 {
187215 var remarks = SelectedSource . Remarks ;
@@ -202,24 +230,11 @@ SelectedSource.ConfigType is not (EConfigType.ProxyChain or EConfigType.PolicyGr
202230 return ;
203231 }
204232
205- SelectedSource . SetProtocolExtra ( SelectedSource . GetProtocolExtra ( ) with
206- {
207- ChildItems =
208- Utils . List2String ( ChildItemsObs . Where ( s => ! s . IndexId . IsNullOrEmpty ( ) ) . Select ( s => s . IndexId ) . ToList ( ) ) ,
209- MultipleLoad = PolicyGroupType switch
210- {
211- var s when s == ResUI . TbLeastPing => EMultipleLoad . LeastPing ,
212- var s when s == ResUI . TbFallback => EMultipleLoad . Fallback ,
213- var s when s == ResUI . TbRandom => EMultipleLoad . Random ,
214- var s when s == ResUI . TbRoundRobin => EMultipleLoad . RoundRobin ,
215- var s when s == ResUI . TbLeastLoad => EMultipleLoad . LeastLoad ,
216- _ => EMultipleLoad . LeastPing ,
217- } ,
218- SubChildItems = SelectedSubItem ? . Id ,
219- Filter = Filter ,
220- } ) ;
233+ var protocolExtra = GetUpdatedProtocolExtra ( ) ;
234+
235+ SelectedSource . SetProtocolExtra ( protocolExtra ) ;
221236
222- var hasCycle = await GroupProfileManager . HasCycle ( SelectedSource . IndexId , SelectedSource . GetProtocolExtra ( ) ) ;
237+ var hasCycle = await GroupProfileManager . HasCycle ( SelectedSource . IndexId , protocolExtra ) ;
223238 if ( hasCycle )
224239 {
225240 NoticeManager . Instance . Enqueue ( string . Format ( ResUI . GroupSelfReference , remarks ) ) ;
0 commit comments