mirror of
https://github.com/ppy/osu.git
synced 2026-05-22 00:30:45 +08:00
Add favourite beatmap set tracking to LocalUserInfo
This commit is contained in:
@@ -238,10 +238,12 @@ namespace osu.Game.Online.API
|
||||
|
||||
public BindableList<APIRelation> Friends { get; } = new BindableList<APIRelation>();
|
||||
public BindableList<APIRelation> Blocks { get; } = new BindableList<APIRelation>();
|
||||
public BindableList<int> FavouriteBeatmapSets { get; } = new BindableList<int>();
|
||||
|
||||
IBindable<APIUser> ILocalUserState.User => User;
|
||||
IBindableList<APIRelation> ILocalUserState.Friends => Friends;
|
||||
IBindableList<APIRelation> ILocalUserState.Blocks => Blocks;
|
||||
IBindableList<int> ILocalUserState.FavouriteBeatmapSets => FavouriteBeatmapSets;
|
||||
|
||||
public void UpdateFriends()
|
||||
{
|
||||
@@ -250,6 +252,10 @@ namespace osu.Game.Online.API
|
||||
public void UpdateBlocks()
|
||||
{
|
||||
}
|
||||
|
||||
public void UpdateFavouriteBeatmapSets()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,10 @@ namespace osu.Game.Online.API
|
||||
IBindable<APIUser> User { get; }
|
||||
IBindableList<APIRelation> Friends { get; }
|
||||
IBindableList<APIRelation> Blocks { get; }
|
||||
IBindableList<int> FavouriteBeatmapSets { get; }
|
||||
|
||||
void UpdateFriends();
|
||||
void UpdateBlocks();
|
||||
void UpdateFavouriteBeatmapSets();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,14 @@ namespace osu.Game.Online.API
|
||||
public IBindable<APIUser> User => localUser;
|
||||
public IBindableList<APIRelation> Friends => friends;
|
||||
public IBindableList<APIRelation> Blocks => blocks;
|
||||
public IBindableList<int> FavouriteBeatmapSets => favouriteBeatmapSets;
|
||||
|
||||
private readonly IAPIProvider api;
|
||||
|
||||
private readonly Bindable<APIUser> localUser = new Bindable<APIUser>(createGuestUser());
|
||||
private readonly BindableList<APIRelation> friends = new BindableList<APIRelation>();
|
||||
private readonly BindableList<APIRelation> blocks = new BindableList<APIRelation>();
|
||||
private readonly BindableList<int> favouriteBeatmapSets = new BindableList<int>();
|
||||
|
||||
private readonly Bindable<UserStatus> configStatus = new Bindable<UserStatus>();
|
||||
private readonly Bindable<bool> configSupporter = new Bindable<bool>();
|
||||
@@ -62,6 +64,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
UpdateFriends();
|
||||
UpdateBlocks();
|
||||
UpdateFavouriteBeatmapSets();
|
||||
}
|
||||
|
||||
public void ClearLocalUser()
|
||||
@@ -76,6 +79,7 @@ namespace osu.Game.Online.API
|
||||
configSupporter.Value = false;
|
||||
friends.Clear();
|
||||
blocks.Clear();
|
||||
favouriteBeatmapSets.Clear();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -125,5 +129,23 @@ namespace osu.Game.Online.API
|
||||
|
||||
api.Queue(blocksReq);
|
||||
}
|
||||
|
||||
public void UpdateFavouriteBeatmapSets()
|
||||
{
|
||||
if (!api.IsLoggedIn)
|
||||
return;
|
||||
|
||||
var favouritesReq = new GetMyFavouriteBeatmapSetsRequest();
|
||||
favouritesReq.Success += res =>
|
||||
{
|
||||
var existingBeatmapSets = favouriteBeatmapSets.ToHashSet();
|
||||
var updatedBeatmapSets = res.BeatmapSetIds.ToHashSet();
|
||||
|
||||
favouriteBeatmapSets.AddRange(updatedBeatmapSets.Except(existingBeatmapSets));
|
||||
favouriteBeatmapSets.RemoveAll(b => !updatedBeatmapSets.Contains(b));
|
||||
};
|
||||
|
||||
api.Queue(favouritesReq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user