<commit_before>app_context.periodic_update_data = {};

function update_origin_from_url() {
    var test_match = [slate_home, "\/board\/", artboard_url_token, "\/([\-0-9]+),([\-0-9]+)"].join("")

    var matches = window.location.href.match(test_match);
    if (matches) {
        var origin_x = parseFloat(matches[1]);
        var origin_y = parseFloat(matches[2]);
        update_display_origin(origin_x, origin_y);
    }
}

function run_periodic_update() {
    $.ajax(slate_home+'/rest/artboard/'+artboard_url_token+"/from/"+app_context.periodic_update_data.last_check_date, {
        success: post_artboard_data
    })
}

function post_artboard_data(data) {
    app_context.periodic_update_data.last_check_date = data.date;

    for (var i = 0; i < data.layers.length; i++) {
        add_layer_from_server(data.layers[i]);
    }

    for (var i = 0; i < data.shapes.length; i++) {
        add_shape_from_server(data.shapes[i]);
    }

    draw_layer_previews();
    redraw_regions();


    window.setTimeout(run_periodic_update, 2000);
}
<commit_msg>Previews do too much work - don't redraw them if there's nothing changed<commit_after>app_context.periodic_update_data = {};

function update_origin_from_url() {
    var test_match = [slate_home, "\/board\/", artboard_url_token, "\/([\-0-9]+),([\-0-9]+)"].join("")

    var matches = window.location.href.match(test_match);
    if (matches) {
        var origin_x = parseFloat(matches[1]);
        var origin_y = parseFloat(matches[2]);
        update_display_origin(origin_x, origin_y);
    }
}

function run_periodic_update() {
    $.ajax(slate_home+'/rest/artboard/'+artboard_url_token+"/from/"+app_context.periodic_update_data.last_check_date, {
        success: post_artboard_data
    })
}

function post_artboard_data(data) {
    app_context.periodic_update_data.last_check_date = data.date;

    for (var i = 0; i < data.layers.length; i++) {
        add_layer_from_server(data.layers[i]);
    }

    for (var i = 0; i < data.shapes.length; i++) {
        add_shape_from_server(data.shapes[i]);
    }

    if (data.shapes.length) {
        draw_layer_previews();
    }
    redraw_regions();


    window.setTimeout(run_periodic_update, 2000);
}

{'fraction_non_alphanumeric': 0.1492063492063492, 'fraction_numerical': 0.010884353741496598, 'mean_word_length': 3.595833333333333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '7120970', 'n_tokens_mistral': 806, 'n_tokens_neox': 767, 'n_words': 115}