<commit_before>// Copyright (c) 2007-2018 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osuTK;

namespace osu.Game.Screens.Multi.Match.Components
{
    public class ReadyButton : HeaderButton
    {
        public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();

        [Resolved]
        private BeatmapManager beatmaps { get; set; }

        public ReadyButton()
        {
            RelativeSizeAxes = Axes.Y;
            Size = new Vector2(200, 1);

            Text = "Start";
        }

        [BackgroundDependencyLoader]
        private void load()
        {
            beatmaps.ItemAdded += beatmapAdded;

            Beatmap.BindValueChanged(updateEnabledState, true);
        }

        private void updateEnabledState(BeatmapInfo beatmap)
        {
            if (beatmap?.OnlineBeatmapID == null)
            {
                Enabled.Value = false;
                return;
            }

            Enabled.Value = beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID) != null;
        }

        private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent)
        {
            if (model.Beatmaps.Any(b => b.OnlineBeatmapID == Beatmap.Value.OnlineBeatmapID))
                Schedule(() => Enabled.Value = true);
        }

        protected override void Dispose(bool isDisposing)
        {
            base.Dispose(isDisposing);

            beatmaps.ItemAdded -= beatmapAdded;
        }
    }
}<commit_msg>Fix potential nullref<commit_after>// Copyright (c) 2007-2018 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osuTK;

namespace osu.Game.Screens.Multi.Match.Components
{
    public class ReadyButton : HeaderButton
    {
        public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();

        [Resolved]
        private BeatmapManager beatmaps { get; set; }

        public ReadyButton()
        {
            RelativeSizeAxes = Axes.Y;
            Size = new Vector2(200, 1);

            Text = "Start";
        }

        [BackgroundDependencyLoader]
        private void load()
        {
            beatmaps.ItemAdded += beatmapAdded;

            Beatmap.BindValueChanged(updateEnabledState, true);
        }

        private void updateEnabledState(BeatmapInfo beatmap)
        {
            if (beatmap?.OnlineBeatmapID == null)
            {
                Enabled.Value = false;
                return;
            }

            Enabled.Value = beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID) != null;
        }

        private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent)
        {
            if (model.Beatmaps.Any(b => b.OnlineBeatmapID == Beatmap.Value.OnlineBeatmapID))
                Schedule(() => Enabled.Value = true);
        }

        protected override void Dispose(bool isDisposing)
        {
            base.Dispose(isDisposing);

            if (beatmaps != null)
                beatmaps.ItemAdded -= beatmapAdded;
        }
    }
}
{'fraction_non_alphanumeric': 0.09664351851851852, 'fraction_numerical': 0.007523148148148148, 'mean_word_length': 2.072888888888889, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '975901', 'n_tokens_mistral': 1048, 'n_tokens_neox': 951, 'n_words': 205}