Skip to content

Commit 88a79d3

Browse files
committed
3.0.6
1 parent 8392ec7 commit 88a79d3

9 files changed

Lines changed: 318 additions & 47 deletions

File tree

Snowcloak/Configuration/PairAppearanceCacheService.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ public PairAppearanceCacheService(StateDocumentStore store) : base(store)
1414

1515
public override string FileName => ConfigName;
1616

17-
public bool TryGet(string uid, out PairAppearanceCacheEntry entry)
17+
public bool TryGet(string uid, string ident, out PairAppearanceCacheEntry entry)
1818
{
1919
entry = null!;
20-
if (string.IsNullOrWhiteSpace(uid) || !Current.Entries.TryGetValue(uid, out var cached))
20+
var key = CacheKey(uid, ident);
21+
if (key == null || !Current.Entries.TryGetValue(key, out var cached))
2122
{
2223
return false;
2324
}
@@ -31,21 +32,33 @@ public bool TryGet(string uid, out PairAppearanceCacheEntry entry)
3132
return true;
3233
}
3334

34-
public void Store(string uid, CharacterData data, long dataVersion)
35+
public void Store(string uid, string ident, CharacterData data, long dataVersion)
3536
{
36-
if (string.IsNullOrWhiteSpace(uid))
37+
var key = CacheKey(uid, ident);
38+
if (key == null)
3739
{
3840
return;
3941
}
4042

4143
Update(config =>
4244
{
43-
config.Entries[uid] = new PairAppearanceCacheEntry
45+
config.Entries[key] = new PairAppearanceCacheEntry
4446
{
4547
CharacterData = data.Clone(),
4648
DataVersion = dataVersion,
4749
UpdatedUtc = DateTime.UtcNow,
4850
};
51+
config.Entries.Remove(uid);
4952
});
5053
}
54+
55+
private static string? CacheKey(string uid, string ident)
56+
{
57+
if (string.IsNullOrWhiteSpace(uid) || string.IsNullOrWhiteSpace(ident))
58+
{
59+
return null;
60+
}
61+
62+
return uid + "|" + ident;
63+
}
5164
}

Snowcloak/PlayerData/Pairs/Pair.cs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void ApplyData(OnlineUserCharaDataDto data)
161161
LastReportedTriangles = data.ReportedTriangles;
162162
if (LastReceivedCharacterData != null)
163163
{
164-
_pairAppearanceCache.Store(UserData.UID, LastReceivedCharacterData, LastReceivedDataVersion);
164+
_pairAppearanceCache.Store(UserData.UID, Ident, LastReceivedCharacterData, LastReceivedDataVersion);
165165
}
166166

167167
ClearAutoPaused(AutoPauseReason.Vram);
@@ -251,24 +251,40 @@ public void CreateCachedPlayer(OnlineUserIdentDto? dto = null)
251251
{
252252
_creationSemaphore.Wait();
253253

254-
if (CachedPlayer != null) return;
254+
var currentIdent = _onlineUserIdentDto?.Ident ?? string.Empty;
255+
var incomingIdent = dto?.Ident ?? currentIdent;
256+
var identChanged = dto != null && !string.Equals(currentIdent, incomingIdent, StringComparison.Ordinal);
255257

256-
if (dto == null && _onlineUserIdentDto == null)
258+
if (identChanged)
257259
{
258-
CachedPlayer?.Dispose();
260+
ClearReceivedCharacterState();
261+
var player = CachedPlayer;
259262
CachedPlayer = null;
263+
player?.Dispose();
264+
if (player != null)
265+
_cachedPlayerReadySignal = new(TaskCreationOptions.RunContinuationsAsynchronously);
266+
}
267+
268+
if (CachedPlayer != null)
269+
{
270+
if (dto != null)
271+
_onlineUserIdentDto = dto;
272+
return;
273+
}
274+
275+
if (dto == null && _onlineUserIdentDto == null)
276+
{
260277
return;
261278
}
262279
if (dto != null)
263280
{
264281
_onlineUserIdentDto = dto;
265282
}
266283

267-
CachedPlayer?.Dispose();
268284
CachedPlayer = _cachedPlayerFactory.Create(this);
269285
_cachedPlayerReadySignal.TrySetResult();
270286

271-
if (LastReceivedCharacterData == null && _pairAppearanceCache.TryGet(UserData.UID, out var cachedAppearance))
287+
if (LastReceivedCharacterData == null && _pairAppearanceCache.TryGet(UserData.UID, Ident, out var cachedAppearance))
272288
{
273289
LastReceivedCharacterData = cachedAppearance.CharacterData;
274290
LastReceivedDataVersion = cachedAppearance.DataVersion;
@@ -294,6 +310,20 @@ public void CreateCachedPlayer(OnlineUserIdentDto? dto = null)
294310
}
295311
}
296312

313+
private void ClearReceivedCharacterState()
314+
{
315+
LastReceivedCharacterData = null;
316+
LastReceivedDataVersion = 0;
317+
LastReportedApproximateVRAMBytes = null;
318+
LastReportedTriangles = null;
319+
LastAppliedApproximateVRAMBytes = -1;
320+
LastAppliedDataTris = -1;
321+
LastPushedDataHash = null;
322+
LastApplicationReceipt = null;
323+
_lastFullDataRequestTick = 0;
324+
ClearAutoPaused();
325+
}
326+
297327
public string? GetNote()
298328
{
299329
return _notesStore.GetNoteForUid(UserData.UID);

Snowcloak/PlayerData/Pairs/PairManager.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,9 @@ public void MarkPairOnline(OnlineUserIdentDto dto, bool sendNotif = true)
234234

235235
Mediator.Publish(new ClearProfileDataMessage(dto.User));
236236

237-
if (pair.HasCachedPlayer)
238-
{
239-
InvalidateProjections();
240-
return;
241-
}
237+
var hadCachedPlayer = pair.HasCachedPlayer;
242238

243-
if (sendNotif && _configurationService.Current.ShowOnlineNotifications
239+
if (!hadCachedPlayer && sendNotif && _configurationService.Current.ShowOnlineNotifications
244240
&& (_configurationService.Current.ShowOnlineNotificationsOnlyForIndividualPairs && pair.UserPair != null
245241
|| !_configurationService.Current.ShowOnlineNotificationsOnlyForIndividualPairs)
246242
&& (_configurationService.Current.ShowOnlineNotificationsOnlyForNamedPairs && !string.IsNullOrEmpty(pair.GetNote())

Snowcloak/Services/Mediator/Messages/Messages.Ui.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public record ProfileOpenStandaloneMessage(UserData UserData, Pair? Pair = null,
2020
public record RemoveWindowMessage(WindowMediatorSubscriberBase Window) : MessageBase;
2121
public record OpenReportPopupMessage(Pair PairToReport, string Ident, ProfileVisibility Visibility, long Revision) : SameThreadMessage;
2222
public record OpenBanUserPopupMessage(Pair PairToBan, GroupFullInfoDto GroupFullInfoDto) : SameThreadMessage;
23-
public record OpenSyncshellAdminPanel(GroupFullInfoDto GroupInfo) : MessageBase;
23+
public record OpenSyncshellAdminPanel(GroupFullInfoDto GroupInfo) : SameThreadMessage;
2424
public record OpenSyncshellEventsWindow(GroupFullInfoDto GroupInfo) : MessageBase;
2525
public record OpenPermissionWindow(Pair Pair) : MessageBase;
2626
public record OpenPairAnalysisWindow(Pair Pair) : MessageBase;

Snowcloak/Snowcloak.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Dalamud.NET.Sdk/15.0.0">
33
<PropertyGroup>
44
<AssemblyName>Snowcloak</AssemblyName>
5-
<Version>3.0.5.0</Version>
5+
<Version>3.0.6.0</Version>
66
<PackageProjectUrl>https://github.com/Eauldane/SnowcloakClient/</PackageProjectUrl>
77
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
88
<Configurations>Release;Debug</Configurations>

Snowcloak/UI/CommunitySyncshellWindow.cs

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Snowcloak/UI/Components/SyncshellMemberManagementPanel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void DrawMembers(GroupFullInfoDto group, bool isOwner, bool isModerator,
5353

5454
ImGui.TableSetupColumn("Alias/UID/Note", ImGuiTableColumnFlags.None, 3);
5555
ImGui.TableSetupColumn("Online/Name", ImGuiTableColumnFlags.None, 2);
56-
ImGui.TableSetupColumn("Roles", ImGuiTableColumnFlags.None, 2);
56+
ImGui.TableSetupColumn("Roles", ImGuiTableColumnFlags.None, 1);
5757
ImGui.TableSetupColumn("Flags", ImGuiTableColumnFlags.None, 1);
5858
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.None, 3);
5959
ImGui.TableHeadersRow();

Snowcloak/UI/SyncshellAdminUI.Sidebar.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private void NormalizeSelectedTab()
1919
_selectedTab = SyncshellAdminTab.Settings;
2020
}
2121

22-
if (_selectedTab == SyncshellAdminTab.Owner && !_isOwner)
22+
if (_selectedTab == SyncshellAdminTab.Owner && !IsOwner)
2323
{
2424
_selectedTab = SyncshellAdminTab.Settings;
2525
}
@@ -57,7 +57,7 @@ private void DrawAdminSidebar()
5757
DrawSidebarTab(SyncshellAdminTab.Permissions, FontAwesomeIcon.Wrench, "Permissions");
5858
DrawSidebarTab(SyncshellAdminTab.Audit, FontAwesomeIcon.History, "Audit History");
5959

60-
if (_isOwner)
60+
if (IsOwner)
6161
{
6262
ModernSidebar.DrawSeparator();
6363
DrawSidebarTab(SyncshellAdminTab.Owner, FontAwesomeIcon.Crown, "Owner Settings");

0 commit comments

Comments
 (0)