88using Quarrel . Client . Models . Channels . Interfaces ;
99using Quarrel . Services . Discord ;
1010using Quarrel . Services . Dispatcher ;
11+ using Quarrel . Services . Localization ;
12+ using System . Linq ;
1113
1214namespace Quarrel . Bindables . Channels
1315{
@@ -16,9 +18,13 @@ namespace Quarrel.Bindables.Channels
1618 /// </summary>
1719 public class BindableGroupChannel : BindablePrivateChannel , IBindableMessageChannel
1820 {
19- internal BindableGroupChannel ( IDiscordService discordService , IDispatcherService dispatcherService , GroupChannel groupChannel ) :
21+ private ILocalizationService _localizationService ;
22+
23+ internal BindableGroupChannel ( IDiscordService discordService , ILocalizationService localizationService , IDispatcherService dispatcherService , GroupChannel groupChannel ) :
2024 base ( discordService , dispatcherService , groupChannel )
2125 {
26+ _localizationService = localizationService ;
27+
2228 Guard . IsNotNull ( groupChannel . Recipients ) ;
2329 Recipients = new BindableUser [ groupChannel . Recipients . Length ] ;
2430 int i = 0 ;
@@ -32,17 +38,24 @@ internal BindableGroupChannel(IDiscordService discordService, IDispatcherService
3238 }
3339
3440 /// <inheritdoc/>
35- public IGroupChannel DirectChannel => ( IGroupChannel ) Channel ;
41+ public IGroupChannel GroupChannel => ( IGroupChannel ) Channel ;
3642
37- // TODO: Formatted names
3843 /// <inheritdoc/>
39- public override string ? Name => Channel . Name ;
44+ public override string ? Name => Channel . Name ?? _localizationService . CommaList ( Recipients . Select ( x => x . User . Username ) . ToArray ( ) ) ;
4045
41- public string IconUrl => $ "https://cdn.discordapp.com/channel-icons/{ Channel . Id } /{ DirectChannel . Icon } .png";
46+ /// <summary>
47+ /// Gets the icon url of the group channel.
48+ /// </summary>
49+ public string ? IconUrl => GroupChannel . Icon is null ? null : $ "https://cdn.discordapp.com/channel-icons/{ Channel . Id } /{ GroupChannel . Icon } .png";
4250
4351 /// <summary>
4452 /// Gets the recipients of the group channel as a <see cref="BindableUser"/> array.
4553 /// </summary>
4654 public BindableUser [ ] Recipients { get ; }
55+
56+ /// <summary>
57+ /// Gets the number of members in the group channel.
58+ /// </summary>
59+ public int MemberCount => Recipients . Length + 1 ;
4760 }
4861}
0 commit comments