<commit_before>import React from 'react';
import jsPDF from 'jspdf';
import { getDataUri } from '../../lib/barcode';
import PrinterController from '../../controllers/pages/printer';
import PrinterStore from '../../store/printer-store';
import ListenerComponent from '../../lib/listener-component.jsx';

export default class Printer extends ListenerComponent {

    getStores() {
        return [
            PrinterStore
        ];
    }

    getState() {
        return {
            addresses: PrinterStore.getAddresses()
        };
    }

    back() {
        PrinterController.close();
    }

    print() {
        let dataUris = this.state.addresses.map(address => getDataUri(address));
        let doc = new jsPDF('l', 'in', [2 + 3/7, 1 + 1/7]);
        dataUris.forEach((dataUri, i) => {
            doc.addImage(dataUri, 'PNG', 0, 0, 2 + 3/7, 1 + 1/7);
            if (i + 1 < dataUris.length) {
                doc.addPage();
            }
        });
        doc.autoPrint();
        doc.save('barcodes.pdf');
    }

    render() {
        return (
            <div id='printer'>
                {this.state.addresses.map(address => {
                    return (
                        <p key={address}>
                            {address}
                            <button onClick={() => PrinterController.remove(address)}>Remove</button>
                        </p>
                    );
                })}
                <button onClick={() => this.print()} className='no-print print'>Print</button>
                <button onClick={this.back} className='no-print cancel'>Back</button>
                <canvas id='canvas'></canvas>
            </div>
        );
    }
}<commit_msg>Fix duplicate key, maybe<commit_after>import React from 'react';
import jsPDF from 'jspdf';
import { getDataUri } from '../../lib/barcode';
import PrinterController from '../../controllers/pages/printer';
import PrinterStore from '../../store/printer-store';
import ListenerComponent from '../../lib/listener-component.jsx';

export default class Printer extends ListenerComponent {

    getStores() {
        return [
            PrinterStore
        ];
    }

    getState() {
        return {
            addresses: PrinterStore.getAddresses()
        };
    }

    back() {
        PrinterController.close();
    }

    print() {
        let dataUris = this.state.addresses.map(address => getDataUri(address));
        let doc = new jsPDF('l', 'in', [2 + 3/7, 1 + 1/7]);
        dataUris.forEach((dataUri, i) => {
            doc.addImage(dataUri, 'PNG', 0, 0, 2 + 3/7, 1 + 1/7);
            if (i + 1 < dataUris.length) {
                doc.addPage();
            }
        });
        doc.autoPrint();
        doc.save('barcodes.pdf');
    }

    render() {
        return (
            <div id='printer'>
                {this.state.addresses.map((address, i) => {
                    return (
                        <p key={`${i} ${address}`}>
                            {address}
                            <button onClick={() => PrinterController.remove(address)}>Remove</button>
                        </p>
                    );
                })}
                <button onClick={() => this.print()} className='no-print print'>Print</button>
                <button onClick={this.back} className='no-print cancel'>Back</button>
                <canvas id='canvas'></canvas>
            </div>
        );
    }
}
{'fraction_non_alphanumeric': 0.15317414094350612, 'fraction_numerical': 0.008736167734420501, 'mean_word_length': 1.5482195845697329, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 37, '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': '4483637', 'n_tokens_mistral': 988, 'n_tokens_neox': 949, 'n_words': 195}