<commit_before>import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {SirenEntityMixin} from './siren-entity-mixin.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
import './notes/note.js';

class MyVirtualNotebook extends SirenEntityMixin(PolymerElement) {

	static get template() {
		return html`
<h1>My Virtual Notebook</h1>
<template is="dom-repeat" items="[[notes]]">
	<d2l-note href="{{item}}" token="{{token}}"></d2l-note>
</template>
`;
	}

	static get properties() {
		return {
			notes: {
				type: Array,
				value: []
			}
		};
	}

	static get observers() {
		return [
			'_changed(entity)'
		];
	}

	static get is() {
		return 'my-virtual-notebook';
	}

	_changed() {
		this._getUrlForNotes(this.href);
	}

	async _getUrlForNotes(href) {
		const response = await fetch(href)
			.then(res => res.json());
		this.notes = response.entities.map(e => e.href);
	}
}

window.customElements.define(MyVirtualNotebook.is, MyVirtualNotebook);<commit_msg>Use entity from SirenEntityMixin instead of fetch/parsing itself<commit_after>import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {SirenEntityMixin} from './siren-entity-mixin.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
import './notes/note.js';

class MyVirtualNotebook extends SirenEntityMixin(PolymerElement) {

	static get template() {
		return html`
<h1>My Virtual Notebook</h1>
<template is="dom-repeat" items="[[notes]]">
	<d2l-note href="{{item}}" token="{{token}}"></d2l-note>
</template>
`;
	}

	static get properties() {
		return {
			notes: {
				type: Array,
				value: []
			}
		};
	}

	static get observers() {
		return [
			'_changed(entity)'
		];
	}

	static get is() {
		return 'my-virtual-notebook';
	}

	_changed(entity) {
		if( entity && entity.entities ) {
			this.notes = entity.entities.map(subEntity => subEntity.href);
		}
	}
}

window.customElements.define(MyVirtualNotebook.is, MyVirtualNotebook);
{'fraction_non_alphanumeric': 0.16853360488798372, 'fraction_numerical': 0.004073319755600814, 'mean_word_length': 4.296495956873315, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 18, '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': '4595769', 'n_tokens_mistral': 761, 'n_tokens_neox': 686, 'n_words': 132}