-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add /watch chat command
#38152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add /watch chat command
#38152
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Screens; | ||
| using osu.Game.Online.API; | ||
| using osu.Game.Online.API.Requests; | ||
| using osu.Game.Screens; | ||
| using osu.Game.Screens.Play; | ||
|
|
||
| namespace osu.Game.Online.Chat | ||
| { | ||
| public partial class WatchCommand : Component | ||
| { | ||
| [Resolved] | ||
| private IChannelPostTarget channelManager { get; set; } = null!; | ||
Check warningCode scanning / InspectCode Auto-property accessor is never used: Private accessibility Warning
Auto-property accessor 'channelManager.get' is never used
|
||
|
|
||
| [Resolved] | ||
| private IAPIProvider api { get; set; } = null!; | ||
|
|
||
| [Resolved] | ||
| private IPerformFromScreenRunner performer { get; set; } = null!; | ||
|
|
||
| private readonly Channel? target; | ||
| private readonly string username; | ||
|
|
||
| public WatchCommand(Channel target, string username) | ||
| { | ||
| this.target = target; | ||
| this.username = username; | ||
| } | ||
|
|
||
| protected override void LoadComplete() | ||
| { | ||
| base.LoadComplete(); | ||
|
|
||
| var request = new GetUserRequest(username); | ||
| request.Success += user => | ||
| { | ||
| performer.PerformFromScreen(s => s.Push(new SoloSpectatorScreen(user))); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On stable, the command also fails if the user is not online. Technically this could be achieved via IDisposable? token = null;
if (!IsWatchingUserPresence)
token = BeginWatchingUserPresence();
var status = GetPresence(userId)?.Status;
token?.Dispose();
if (status != Online) Fail();I'm just not sure that it should be because this will work fine without it, by showing the spectator splash screen with the user card on it showing that the user is offline. @peppy your opinion on how to proceed here please. |
||
| Expire(); | ||
| }; | ||
| request.Failure += e => | ||
| { | ||
| target?.AddNewMessages(new ErrorMessage( | ||
| e.InnerException?.Message == @"NotFound" | ||
| ? $"User '{username}' was not found." | ||
| : $"Could not fetch user '{username}'.")); | ||
| Expire(); | ||
| }; | ||
|
|
||
| api.Queue(request); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.