Merge remote-tracking branch 'upstream/master' into fix-remaining-identifier-names

This commit is contained in:
Joseph Madamba
2022-01-12 15:05:07 -08:00
163 changed files with 2545 additions and 844 deletions

View File

@ -7,8 +7,10 @@ using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Logging;
using osu.Game.Database;
using osu.Game.Input;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
@ -67,11 +69,34 @@ namespace osu.Game.Online.Chat
public readonly BindableBool HighPollRate = new BindableBool();
private readonly IBindable<bool> isIdle = new BindableBool();
public ChannelManager()
{
CurrentChannel.ValueChanged += currentChannelChanged;
}
HighPollRate.BindValueChanged(enabled => TimeBetweenPolls.Value = enabled.NewValue ? 1000 : 6000, true);
[BackgroundDependencyLoader(permitNulls: true)]
private void load(IdleTracker idleTracker)
{
HighPollRate.BindValueChanged(updatePollRate);
isIdle.BindValueChanged(updatePollRate, true);
if (idleTracker != null)
isIdle.BindTo(idleTracker.IsIdle);
}
private void updatePollRate(ValueChangedEvent<bool> valueChangedEvent)
{
// Polling will eventually be replaced with websocket, but let's avoid doing these background operations as much as possible for now.
// The only loss will be delayed PM/message highlight notifications.
if (HighPollRate.Value)
TimeBetweenPolls.Value = 1000;
else if (!isIdle.Value)
TimeBetweenPolls.Value = 60000;
else
TimeBetweenPolls.Value = 600000;
}
/// <summary>
@ -509,11 +534,12 @@ namespace osu.Game.Online.Chat
else if (lastClosedChannel.Type == ChannelType.PM)
{
// Try to get user in order to open PM chat
users.GetUserAsync((int)lastClosedChannel.Id).ContinueWith(u =>
users.GetUserAsync((int)lastClosedChannel.Id).ContinueWith(task =>
{
if (u.Result == null) return;
var user = task.GetResultSafely();
Schedule(() => CurrentChannel.Value = JoinChannel(new Channel(u.Result)));
if (user != null)
Schedule(() => CurrentChannel.Value = JoinChannel(new Channel(user)));
});
}

View File

@ -57,6 +57,7 @@ namespace osu.Game.Online.Chat
/// </summary>
public static string WebsiteRootUrl
{
get => websiteRootUrl;
set => websiteRootUrl = value
.Trim('/') // trim potential trailing slash/
.Split('/').Last(); // only keep domain name, ignoring protocol.
@ -134,7 +135,7 @@ namespace osu.Game.Online.Chat
case "http":
case "https":
// length > 3 since all these links need another argument to work
if (args.Length > 3 && args[1].EndsWith(websiteRootUrl, StringComparison.OrdinalIgnoreCase))
if (args.Length > 3 && args[1].EndsWith(WebsiteRootUrl, StringComparison.OrdinalIgnoreCase))
{
string mainArg = args[3];
@ -262,7 +263,7 @@ namespace osu.Game.Online.Chat
handleMatches(old_link_regex, "{1}", "{2}", result, startIndex, escapeChars: new[] { '(', ')' });
// handle wiki links
handleMatches(wiki_regex, "{1}", "https://osu.ppy.sh/wiki/{1}", result, startIndex);
handleMatches(wiki_regex, "{1}", $"https://{WebsiteRootUrl}/wiki/{{1}}", result, startIndex);
// handle bare links
handleAdvanced(advanced_link_regex, result, startIndex);

View File

@ -12,17 +12,17 @@ namespace osu.Game.Online.Solo
{
public class SubmitSoloScoreRequest : APIRequest<MultiplayerScore>
{
public readonly SubmittableScore Score;
private readonly long scoreId;
private readonly int beatmapId;
private readonly SubmittableScore score;
public SubmitSoloScoreRequest(int beatmapId, long scoreId, ScoreInfo scoreInfo)
{
this.beatmapId = beatmapId;
this.scoreId = scoreId;
score = new SubmittableScore(scoreInfo);
Score = new SubmittableScore(scoreInfo);
}
protected override WebRequest CreateWebRequest()
@ -33,7 +33,7 @@ namespace osu.Game.Online.Solo
req.Method = HttpMethod.Put;
req.Timeout = 30000;
req.AddRaw(JsonConvert.SerializeObject(score, new JsonSerializerSettings
req.AddRaw(JsonConvert.SerializeObject(Score, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
}));