mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Changed internal closedChannel list to store channels names instead of channel objects
This is for efficiency purposes; it's more efficient to just store the names than store the whole object.
This commit is contained in:
@ -33,8 +33,8 @@ namespace osu.Game.Online.Chat
|
|||||||
private readonly BindableList<Channel> availableChannels = new BindableList<Channel>();
|
private readonly BindableList<Channel> availableChannels = new BindableList<Channel>();
|
||||||
private readonly BindableList<Channel> joinedChannels = new BindableList<Channel>();
|
private readonly BindableList<Channel> joinedChannels = new BindableList<Channel>();
|
||||||
|
|
||||||
// Keeps a list of closed channels. More recently closed channels appear at higher indeces
|
// Keeps a list of closed channel identifiers
|
||||||
private readonly BindableList<Channel> closedChannels = new BindableList<Channel>();
|
private readonly BindableList<string> closedChannels = new BindableList<string>();
|
||||||
|
|
||||||
// For efficiency purposes, this constant bounds the number of closed channels we store.
|
// For efficiency purposes, this constant bounds the number of closed channels we store.
|
||||||
// This number is somewhat arbitrary; future developers are free to modify it.
|
// This number is somewhat arbitrary; future developers are free to modify it.
|
||||||
@ -424,7 +424,7 @@ namespace osu.Game.Online.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// insert at the end of the closedChannels list
|
// insert at the end of the closedChannels list
|
||||||
closedChannels.Insert(closedChannels.Count, channel);
|
closedChannels.Insert(closedChannels.Count, channel.Name);
|
||||||
|
|
||||||
if (channel.Joined.Value)
|
if (channel.Joined.Value)
|
||||||
{
|
{
|
||||||
@ -445,13 +445,24 @@ namespace osu.Game.Online.Chat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel lastClosedChannel = closedChannels.Last();
|
string lastClosedChannelName = closedChannels.Last();
|
||||||
|
closedChannels.RemoveAt(closedChannels.Count - 1);
|
||||||
|
|
||||||
closedChannels.Remove(lastClosedChannel);
|
// types did not work with existing enumerable interfaces funcitons like Contains
|
||||||
|
for (int i = 0; i < joinedChannels.Count; i++)
|
||||||
|
{
|
||||||
|
// If the user already joined the channel, try the next
|
||||||
|
// channel in the list
|
||||||
|
if (joinedChannels[i].Name == lastClosedChannelName)
|
||||||
|
{
|
||||||
|
JoinLastClosedChannel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the user already joined the channel, try the next
|
Channel lastClosedChannel = AvailableChannels.FirstOrDefault(c => c.Name == lastClosedChannelName);
|
||||||
// channel in the list
|
|
||||||
if (joinedChannels.IndexOf(lastClosedChannel) >= 0)
|
if (lastClosedChannel == null)
|
||||||
{
|
{
|
||||||
JoinLastClosedChannel();
|
JoinLastClosedChannel();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user