<commit_before>import { Component, ChangeDetectorRef } from '@angular/core';

import { NavController } from 'ionic-angular';
import { UserService } from "../../providers/session/UserService";
import { Events } from 'ionic-angular';
import { ModalController } from 'ionic-angular';
import { LoginPage } from '../login/login';
import {User} from "../../model/user";
import { Moment} from 'moment';
import { Storage } from '@ionic/storage';
import {WallEntry} from "../../model/wallentry";
import {EventService} from "../../providers/event/EventService";


@Component({
    selector: 'page-wall',
    templateUrl: 'wall.html',
    providers: [UserService, EventService]
})
export class WallPage {

    wallEntries:Array<WallEntry>;
    persistedWallEntries:Array<any>;
    error:string;
    i:number;

    constructor(public navCtrl:NavController,
                public events:Events,
                public eventService:EventService,
                public cd:ChangeDetectorRef,
                public modalCtrl:ModalController,
                public userService:UserService,
                private storage:Storage) {


        this.i = 5;
        this.wallEntries = [];
        this.storage.get('goviewall').then((wall) => {
            debugger;
            var items = JSON.parse(wall);
            for (let a in items) {
                var event = items[a];
                this.persistedWallEntries.push(event);
                this.wallEntries.push(new WallEntry(
                    event.id,
                    event.name,
                    event.avatarUrl,
                    event.timestamp,
                    event.title,
                    event.info,
                    event.attendees,
                    event.date,
                    event.poster,
                    event.rater,
                    event.raterImg,
                    event.theater,
                    event.comment,
                    event.rating));
                cd.detectChanges();
            }
        });
        this.events.subscribe('event:wall:new', (event) => {
            debugger;
            this.persistedWallEntries.push(event);
            this.wallEntries.push(new WallEntry(
                event.id,
                event.name,
                event.avatarUrl,
                event.timestamp,
                event.title,
                event.info,
                event.attendees,
                event.date,
                event.poster,
                event.rater,
                event.raterImg,
                event.theater,
                event.comment,
                event.rating));
            var value = JSON.stringify(this.persistedWallEntries);
            this.storage.set('goviewall', value);
            cd.detectChanges();
        });
    }

    ionViewDidLoad() {
        debugger;
        this.events.subscribe('user:login', (user) => {
            console.log(user);
        });

        this.events.subscribe('user:logout', () => {
            this.promptLogin();
        });
        if (this.userService.currentUser() === null) {
            this.promptLogin();
        }
    }

    ionViewDidEnter() {
        debugger;
        this.eventService.subscribeToWall(this.events, this.userService.currentUser());
        console.log('subscribing to wall')
    }


    ionViewWillLeave() {
        this.events.unsubscribe('event:wall:new');
    }

    private promptLogin() {
        if (this.userService.currentUser() === null) {
            let modal = this.modalCtrl.create(LoginPage);
            modal.present();
        }
    };


}<commit_msg>attempt at loading wall entries<commit_after>import { Component, ChangeDetectorRef } from '@angular/core';

import { NavController } from 'ionic-angular';
import { UserService } from "../../providers/session/UserService";
import { Events } from 'ionic-angular';
import { ModalController } from 'ionic-angular';
import { LoginPage } from '../login/login';
import {User} from "../../model/user";
import { Moment} from 'moment';
import { Storage } from '@ionic/storage';
import {WallEntry} from "../../model/wallentry";
import {EventService} from "../../providers/event/EventService";


@Component({
    selector: 'page-wall',
    templateUrl: 'wall.html',
    providers: [UserService, EventService]
})
export class WallPage {

    wallEntries:Array<WallEntry>;
    persistedWallEntries:Array<any>;
    error:string;
    i:number;

    constructor(public navCtrl:NavController,
                public event:Events,
                public eventService:EventService,
                public cd:ChangeDetectorRef,
                public modalCtrl:ModalController,
                public userService:UserService,
                private storage:Storage) {


        this.i = 5;
        this.wallEntries = [];
        debugger;
        this.storage.get('goviewall').then((wall) => {
            debugger;
            var items = JSON.parse(wall);
            for (let a in items) {
                var event = items[a];
                this.persistedWallEntries.push(event);
                this.wallEntries.push(new WallEntry(
                    event.id,
                    event.name,
                    event.avatarUrl,
                    event.timestamp,
                    event.title,
                    event.info,
                    event.attendees,
                    event.date,
                    event.poster,
                    event.rater,
                    event.raterImg,
                    event.theater,
                    event.comment,
                    event.rating));
                cd.detectChanges();
            }
        });
        this.event.subscribe('event:wall:new', (event) => {
            debugger;
            this.persistedWallEntries.push(event);
            this.wallEntries.push(new WallEntry(
                event.id,
                event.name,
                event.avatarUrl,
                event.timestamp,
                event.title,
                event.info,
                event.attendees,
                event.date,
                event.poster,
                event.rater,
                event.raterImg,
                event.theater,
                event.comment,
                event.rating));
            var value = JSON.stringify(this.persistedWallEntries);
            this.storage.set('goviewall', value);
            cd.detectChanges();
        });
    }

    ionViewDidLoad() {
        debugger;
        this.event.subscribe('user:login', (user) => {
            console.log(user);
        });

        this.event.subscribe('user:logout', () => {
            this.promptLogin();
        });
        if (this.userService.currentUser() === null) {
            this.promptLogin();
        }
    }

    ionViewDidEnter() {
        debugger;
        this.eventService.subscribeToWall(this.event, this.userService.currentUser());
        console.log('subscribing to wall')
    }


    ionViewWillLeave() {
        debugger;
        this.event.unsubscribe('event:wall:new');
    }

    private promptLogin() {
        if (this.userService.currentUser() === null) {
            let modal = this.modalCtrl.create(LoginPage);
            modal.present();
        }
    };


}
{'fraction_non_alphanumeric': 0.11715943630837247, 'fraction_numerical': 0.00027631942525559546, 'mean_word_length': 1.5462539570875835, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '5082636', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1823, 'n_words': 332}