Skip to content

Commit

Permalink
Merge pull request #30848 from Joehuu/dicord-fix-beatmap-button-visib…
Browse files Browse the repository at this point in the history
…ility

Fix discord "view beatmap" button being shown when editing and hide identifiable information is set
  • Loading branch information
peppy authored Nov 28, 2024
2 parents 573aaf6 + 24c0799 commit e0fdcaf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 1 addition & 15 deletions osu.Desktop/DiscordRichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void updatePresence(bool hideIdentifiableInformation)
presence.State = clampLength(activity.Value.GetStatus(hideIdentifiableInformation));
presence.Details = clampLength(activity.Value.GetDetails(hideIdentifiableInformation) ?? string.Empty);

if (getBeatmapID(activity.Value) is int beatmapId && beatmapId > 0)
if (activity.Value.GetBeatmapID(hideIdentifiableInformation) is int beatmapId && beatmapId > 0)
{
presence.Buttons = new[]
{
Expand Down Expand Up @@ -333,20 +333,6 @@ private static bool tryParseRoomSecret(string secretJson, out long roomId, out s
return true;
}

private static int? getBeatmapID(UserActivity activity)
{
switch (activity)
{
case UserActivity.InGame game:
return game.BeatmapID;

case UserActivity.EditingBeatmap edit:
return edit.BeatmapID;
}

return null;
}

protected override void Dispose(bool isDisposing)
{
if (multiplayerClient.IsNotNull())
Expand Down
12 changes: 12 additions & 0 deletions osu.Game/Users/UserActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public abstract class UserActivity

public virtual Color4 GetAppropriateColour(OsuColour colours) => colours.GreenDarker;

/// <summary>
/// Returns the ID of the beatmap involved in this activity, if applicable and/or available.
/// </summary>
/// <param name="hideIdentifiableInformation"></param>
public virtual int? GetBeatmapID(bool hideIdentifiableInformation = false) => null;

[MessagePackObject]
public class ChoosingBeatmap : UserActivity
{
Expand Down Expand Up @@ -76,6 +82,7 @@ protected InGame() { }

public override string GetStatus(bool hideIdentifiableInformation = false) => RulesetPlayingVerb;
public override string GetDetails(bool hideIdentifiableInformation = false) => BeatmapDisplayTitle;
public override int? GetBeatmapID(bool hideIdentifiableInformation = false) => BeatmapID;
}

[MessagePackObject]
Expand Down Expand Up @@ -156,6 +163,11 @@ public override string GetDetails(bool hideIdentifiableInformation = false) => h
// For now let's assume that showing the beatmap a user is editing could reveal unwanted information.
? string.Empty
: BeatmapDisplayTitle;

public override int? GetBeatmapID(bool hideIdentifiableInformation = false) => hideIdentifiableInformation
// For now let's assume that showing the beatmap a user is editing could reveal unwanted information.
? null
: BeatmapID;
}

[MessagePackObject]
Expand Down

0 comments on commit e0fdcaf

Please sign in to comment.