<commit_before>import { Component } from '@angular/core'
import { NavController, LoadingController, Events } from 'ionic-angular'
import { SocialSharing } from '@ionic-native/social-sharing'
import { AddPage } from '../add/add'
import { Item } from '../../app/models/item'
import { ToastService } from '../../app/services/toast'
import { DialogService } from '../../app/services/dialog'
import { DatabaseService } from '../../app/services/database'

@Component({
	selector: 'page-cart',
	templateUrl: 'cart.html'
})
export class CartPage
{
	private items: Item[]

	constructor(private navCtrl: NavController,
				private loadingCtrl: LoadingController,
				private events: Events,
				private socialSharing: SocialSharing,
				private toast: ToastService,
				private dialog: DialogService,
				private database: DatabaseService)
	{
	}

	public ionViewDidLoad()
	{
		let loader = this.loadingCtrl.create({
			content: 'Loading...'
		})
		loader.present()

		let callback = () => {
			this.refreshItems()
			loader.dismiss()

			this.database.tipCart(() => {
				this.toast.help('Press the plus icon on the top-right corner to add a product to the cart')
			})
		}

		this.database.start(callback)

		this.events.subscribe('pause', () => {
			this.refreshItems()
		})
	}

	public ionViewWillEnter()
	{
		this.refreshItems()
	}

	public ionViewWillLeave()
	{
		for (let item of this.items)
		{
			if (item.completed)
			{
				this.database.removeItem(item)
			}
		}<commit_msg>Refreshing items when pausing the app<commit_after>import { Component } from '@angular/core'
import { NavController, LoadingController } from 'ionic-angular'
import { SocialSharing } from '@ionic-native/social-sharing'
import { AddPage } from '../add/add'
import { Item } from '../../app/models/item'
import { ToastService } from '../../app/services/toast'
import { DialogService } from '../../app/services/dialog'
import { DatabaseService } from '../../app/services/database'

@Component({
	selector: 'page-cart',
	templateUrl: 'cart.html'
})
export class CartPage
{
	private items: Item[]

	constructor(private navCtrl: NavController,
				private loadingCtrl: LoadingController,
				private socialSharing: SocialSharing,
				private toast: ToastService,
				private dialog: DialogService,
				private database: DatabaseService)
	{
	}

	public ionViewDidLoad()
	{
		let loader = this.loadingCtrl.create({
			content: 'Loading...'
		})
		loader.present()

		let callback = () => {
			this.refreshItems()
			loader.dismiss()

			this.database.tipCart(() => {
				this.toast.help('Press the plus icon on the top-right corner to add a product to the cart')
			})
		}

		this.database.start(callback)

		document.addEventListener('pause', () => {
        	this.refreshItems()
    	});
	}

	public ionViewWillEnter()
	{
		this.refreshItems()
	}

	public ionViewWillLeave()
	{
		for (let item of this.items)
		{
			if (item.completed)
			{
				this.database.removeItem(item)
			}
		}
{'fraction_non_alphanumeric': 0.14058265582655827, 'fraction_numerical': 0.0, 'mean_word_length': 3.515290519877676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3588758', 'n_tokens_mistral': 1020, 'n_tokens_neox': 890, 'n_words': 221}