コード例 #1
0
ファイル: ChatOverlay.cs プロジェクト: logchan/osu
        private void addChannel(Channel channel)
        {
            if (channel == null)
            {
                return;
            }

            var existing = careChannels.Find(c => c.Id == channel.Id);

            if (existing != null)
            {
                // if we already have this channel loaded, we don't want to make a second one.
                channel = existing;
            }
            else
            {
                careChannels.Add(channel);
                channelTabs.AddItem(channel);
            }

            // let's fetch a small number of messages to bring us up-to-date with the backlog.
            fetchInitialMessages(channel);

            if (CurrentChannel == null)
            {
                CurrentChannel = channel;
            }
        }
コード例 #2
0
        private void addChannel(Channel channel)
        {
            if (channel == null)
            {
                return;
            }

            // ReSharper disable once AccessToModifiedClosure
            var existing = careChannels.Find(c => c.Id == channel.Id);

            if (existing != null)
            {
                // if we already have this channel loaded, we don't want to make a second one.
                channel = existing;
            }
            else
            {
                careChannels.Add(channel);
                channelTabs.AddItem(channel);

                if (channel.Type == ChannelType.Public && !channel.Joined)
                {
                    var req = new JoinChannelRequest(channel, api.LocalUser);
                    req.Success += () => addChannel(channel);
                    req.Failure += ex => removeChannel(channel);
                    api.Queue(req);
                    return;
                }
            }

            // let's fetch a small number of messages to bring us up-to-date with the backlog.
            fetchInitialMessages(channel);

            if (CurrentChannel == null)
            {
                CurrentChannel = channel;
            }

            channel.Joined.Value = true;
        }