<commit_before>import * as firebase from "firebase";
import stateEngine from "./state-engine";
import Component from "./component";
import Login from "./login";
import Content from "./content";
import Loading from "./loading";
import App from "./app";
import appGridService from "./app-grid-service";

export default class AppStation extends Component {

    private login: Login;

    private content: Content;

    private loading: Loading;

    private firstHashLoad: boolean;

    constructor(config: any, apps: Array<App>) {
        super(document.body, "app-station");
        this.firstHashLoad = true;
        firebase.initializeApp(config);
        firebase.auth().onAuthStateChanged((user: any) => {
            if (user) {
                stateEngine.set("user", user);
                stateEngine.set("available-apps", apps);
                appGridService.loadGrid();
            } else {
                stateEngine.set("user", null);
            }
        });
    }

    protected afterRendered() {
        this.login = new Login(this.getContainer(), `${this.getId()}-login`);
        this.content = new Content(this.getContainer(), `${this.getId()}-content`);
        this.loading = new Loading(this.getContainer(), `${this.getId()}-loading`);
    }

    protected onStateChange(): (state: Object, property: string, value: any) => void {
        return (state: Object, property: string, value: any): void => {
            if (property == "installed-apps" && this.firstHashLoad) {
                this.firstHashLoad = false;
                const hashChanged = () => {
                    const hash = new String(location.hash);
                    if (hash.trim().length != 0) {
                        const beginIndex: number = 1;
                        const indexOfSlash = hash.indexOf("\\");
                        const endIndex: number = indexOfSlash == -1 ? hash.length : indexOfSlash;
                        const appId = hash.substring(beginIndex, endIndex);
                        console.log(appId);
                        const installedApps = stateEngine.get("installed-apps") as Array<App>;
                        if (installedApps != null) {
                            installedApps.forEach(app => {
                                if (app.getId() == appId) {
                                    stateEngine.set("fullscreen-app", app);
                                }
                            })
                            return;
                        }
                    }
                    stateEngine.set("fullscreen-app", null);
                }
                onhashchange = hashChanged;
                hashChanged();
            }
        };
    }

}<commit_msg>Fix bug on calling fullscreen state for non-fullscreen apps<commit_after>import * as firebase from "firebase";
import stateEngine from "./state-engine";
import Component from "./component";
import Login from "./login";
import Content from "./content";
import Loading from "./loading";
import App from "./app";
import appGridService from "./app-grid-service";

export default class AppStation extends Component {

    private login: Login;

    private content: Content;

    private loading: Loading;

    private firstHashLoad: boolean;

    constructor(config: any, apps: Array<App>) {
        super(document.body, "app-station");
        this.firstHashLoad = true;
        firebase.initializeApp(config);
        firebase.auth().onAuthStateChanged((user: any) => {
            if (user) {
                stateEngine.set("user", user);
                stateEngine.set("available-apps", apps);
                appGridService.loadGrid();
            } else {
                stateEngine.set("user", null);
            }
        });
    }

    protected afterRendered() {
        this.login = new Login(this.getContainer(), `${this.getId()}-login`);
        this.content = new Content(this.getContainer(), `${this.getId()}-content`);
        this.loading = new Loading(this.getContainer(), `${this.getId()}-loading`);
    }

    protected onStateChange(): (state: Object, property: string, value: any) => void {
        return (state: Object, property: string, value: any): void => {
            if (property == "installed-apps" && this.firstHashLoad) {
                this.firstHashLoad = false;
                const hashChanged = () => {
                    const hash = new String(location.hash);
                    if (hash.trim().length != 0) {
                        const beginIndex: number = 1;
                        const indexOfSlash = hash.indexOf("\\");
                        const endIndex: number = indexOfSlash == -1 ? hash.length : indexOfSlash;
                        const appId = hash.substring(beginIndex, endIndex);
                        console.log(appId);
                        const installedApps = stateEngine.get("installed-apps") as Array<App>;
                        if (installedApps != null) {
                            installedApps.forEach(app => {
                                if (app.getId() == appId && app.isFullScreenApp()) {
                                    stateEngine.set("fullscreen-app", app);
                                }
                            })
                            return;
                        }
                    }
                    stateEngine.set("fullscreen-app", null);
                }
                onhashchange = hashChanged;
                hashChanged();
            }
        };
    }

}
{'fraction_non_alphanumeric': 0.12144281312307413, 'fraction_numerical': 0.001087547580206634, 'mean_word_length': 1.582124473561067, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5171915', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1314, 'n_words': 323}