<commit_before>import * as Marionette from 'backbone.marionette';
import channels from '../../channels';

import VideoLayout from './views/VideoLayout';
import VideoModel from './models/Video';

import './styles/videos.scss';

const VideosController = Marionette.Object.extend({
    init(region) {
        this._region = region;

        /** @type {VideoLayout} */
        this._videoLayout = null;
    },

    initVideo(videoId) {
        if (this._region.$el.find('.layout-video').length === 0) {
            const model = new VideoModel();

            this._videoLayout = new VideoLayout({ model });

            this._region.show(this._videoLayout);

            // Update breadcrumb
            this.listenTo(model, 'change:title', (videoModel, title) => {
                channels.breadcrumb.push({ title, type: 'video' });
            });
        }

        this._videoLayout.model.set('id', videoId);
    }
});

export default new VideosController();
<commit_msg>Fixed bug when initializing video-player<commit_after>import * as Marionette from 'backbone.marionette';
import * as $ from 'jquery';
import channels from '../../channels';

import VideoLayout from './views/VideoLayout';
import VideoModel from './models/Video';

import './styles/videos.scss';

const VideosController = Marionette.Object.extend({
    /** @type {VideoLayout} */
    _videoLayout: null,

    init(region) {
        this._region = region;
    },

    initVideo(videoId) {
        /** @type {VideoModel} */
        let videoModel;

        // TODO: this is a workaround, find a better way to solve this
        // Is true when the video-route is initially called. when clicked on an item in a playlist, the value is false
        if (this._region.$el.find('.layout-video').length === 0) {
            videoModel = new VideoModel();

            this._videoLayout = new VideoLayout({ videoModel });

            // const interval = setInterval(() => {
            //     console.log(interval, $('.region-videoplayer').height());
            // }, 10);

            this._region.show(this._videoLayout);

            // Update breadcrumb
            this.listenTo(
                videoModel,
                'change:title',
                (noop, title) => channels.breadcrumb.push({ title, type: 'video' })
            );
        } else {
            videoModel = this._videoLayout.model;
        }

        videoModel.set('id', videoId);
    }
});

export default new VideosController();

{'fraction_non_alphanumeric': 0.13823767178658045, 'fraction_numerical': 0.0016168148746968471, 'mean_word_length': 2.2142857142857144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, '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': '3375282', 'n_tokens_mistral': 692, 'n_tokens_neox': 654, 'n_words': 169}