@@ -111,10 +111,10 @@ private void RefreshDirectoryResults()
111111 } ) . Result ;
112112 _directoryStatus = _directoryResults . Total == 0 ? "No community syncshells found." : string . Empty ;
113113 }
114- catch ( Exception ex )
114+ catch ( AggregateException ex )
115115 {
116116 _directoryResults = new GroupDirectoryListResponseDto ( [ ] , 0 ) ;
117- _directoryStatus = "Unable to load community syncshells: " + ex . Message ;
117+ _directoryStatus = "Unable to load community syncshells: " + ex . GetBaseException ( ) . Message ;
118118 }
119119 }
120120
@@ -219,7 +219,6 @@ private void SetRegionFilter(string region)
219219 private void DrawDirectoryEntry ( GroupDirectoryEntryDto entry )
220220 {
221221 var alreadyJoined = _pairManager . Groups . Keys . Any ( g => GroupDataComparer . Instance . Equals ( g , entry . Group ) ) ;
222- var canJoin = entry . JoinPolicy == GroupDirectoryJoinPolicy . Open && ! alreadyJoined ;
223222 var title = entry . Group . AliasOrGID ;
224223
225224 using var id = ImRaii . PushId ( "directory-" + entry . Group . GID ) ;
@@ -233,18 +232,7 @@ private void DrawDirectoryEntry(GroupDirectoryEntryDto entry)
233232 ImGui . TextUnformatted ( string . Format ( CultureInfo . CurrentCulture , "{0} members" , entry . MemberCountBucket ) ) ;
234233 }
235234
236- if ( canJoin )
237- {
238- ImGui . SameLine ( ) ;
239- if ( ElezenImgui . ShowIconButton ( FontAwesomeIcon . Plus , "Join listed Syncshell" ) )
240- {
241- var joined = _apiController . GroupDirectoryJoin ( new GroupDto ( entry . Group ) ) . Result ;
242- _directoryStatus = joined
243- ? string . Format ( CultureInfo . CurrentCulture , "Joined {0}." , title )
244- : string . Format ( CultureInfo . CurrentCulture , "Could not join {0}." , title ) ;
245- RefreshDirectoryResults ( ) ;
246- }
247- }
235+ DrawDirectoryJoinAction ( entry , title , alreadyJoined ) ;
248236
249237 var locationText = _dalamudUtilService . GetWorldName ( entry . MainWorldId ) ?? entry . MainRegion ;
250238 if ( ! string . IsNullOrEmpty ( locationText ) )
@@ -286,4 +274,55 @@ private void DrawDirectoryEntry(GroupDirectoryEntryDto entry)
286274
287275 ImGui . Separator ( ) ;
288276 }
277+
278+ private void DrawDirectoryJoinAction ( GroupDirectoryEntryDto entry , string title , bool alreadyJoined )
279+ {
280+ ImGui . SameLine ( ) ;
281+
282+ if ( alreadyJoined )
283+ {
284+ using ( ImRaii . Disabled ( ) )
285+ {
286+ ElezenImgui . ShowIconButton ( FontAwesomeIcon . CheckCircle , "Joined" ) ;
287+ }
288+ ElezenImgui . AttachTooltip ( "You are already in this Syncshell." ) ;
289+ return ;
290+ }
291+
292+ if ( entry . JoinPolicy == GroupDirectoryJoinPolicy . Open )
293+ {
294+ if ( ElezenImgui . ShowIconButton ( FontAwesomeIcon . Plus , "Join listed Syncshell" ) )
295+ {
296+ TryJoinDirectoryEntry ( entry , title ) ;
297+ }
298+ ElezenImgui . AttachTooltip ( "Join this open Syncshell." ) ;
299+ return ;
300+ }
301+
302+ var icon = entry . JoinPolicy == GroupDirectoryJoinPolicy . Request ? FontAwesomeIcon . Envelope : FontAwesomeIcon . Lock ;
303+ var label = entry . JoinPolicy == GroupDirectoryJoinPolicy . Request ? "Request access" : "Invite only" ;
304+ using ( ImRaii . Disabled ( ) )
305+ {
306+ ElezenImgui . ShowIconButton ( icon , label ) ;
307+ }
308+ ElezenImgui . AttachTooltip ( entry . JoinPolicy == GroupDirectoryJoinPolicy . Request
309+ ? "This listing requires an access request."
310+ : "This listing requires an invite or password from the owner." ) ;
311+ }
312+
313+ private void TryJoinDirectoryEntry ( GroupDirectoryEntryDto entry , string title )
314+ {
315+ try
316+ {
317+ var joined = _apiController . GroupDirectoryJoin ( new GroupDto ( entry . Group ) ) . Result ;
318+ _directoryStatus = joined
319+ ? string . Format ( CultureInfo . CurrentCulture , "Joined {0}." , title )
320+ : string . Format ( CultureInfo . CurrentCulture , "Could not join {0}." , title ) ;
321+ RefreshDirectoryResults ( ) ;
322+ }
323+ catch ( AggregateException ex )
324+ {
325+ _directoryStatus = string . Format ( CultureInfo . CurrentCulture , "Could not join {0}: {1}" , title , ex . GetBaseException ( ) . Message ) ;
326+ }
327+ }
289328}
0 commit comments