<commit_before>/*global define*/
define([
    'underscore',
    'app',
    'helpers/uri',
    'marionette',
    'models/note'
], function (_, App, URI, Marionette, NoteModel) {
    'use strict';

    var Remove = App.module('AppNote.Remove');

    /**
     * Removes an existing note
     */
    Remove.Controller = Marionette.Controller.extend({

        initialize: function () {
            _.bindAll(this, 'remove', 'doRemove', 'redirect');
        },

        remove: function (args) {
            this.note = new NoteModel({ id : args.id });
            this.note.database.getDB(args.profile);
            $.when(this.note.fetch()).done(this.doRemove);
        },

        doRemove: function () {
            // Destroy if note is already in trash
            if (Number(this.note.get('trash')) === 1) {
                var self = this;
                $.when(this.note.destroySync()).done(function () {
                    self.redirect();
                });
            }
            else {
                $.when(this.note.save({'trash' : 1})).done(this.redirect);
            }
        },

        redirect: function () {
            App.content.reset();
            App.trigger('notes:rerender');

            App.navigate(URI.link('/notes'), false);
            App.trigger('notes:next');
        }

    });

    return Remove.Controller;
});<commit_msg>synchronizing bug: removing notes to trash<commit_after>/*global define*/
define([
    'underscore',
    'app',
    'helpers/uri',
    'marionette',
    'models/note'
], function (_, App, URI, Marionette, NoteModel) {
    'use strict';

    var Remove = App.module('AppNote.Remove');

    /**
     * Removes an existing note
     */
    Remove.Controller = Marionette.Controller.extend({

        initialize: function () {
            _.bindAll(this, 'remove', 'doRemove', 'redirect');
        },

        remove: function (args) {
            this.note = new NoteModel({ id : args.id });
            this.note.database.getDB(args.profile);
            $.when(this.note.fetch()).done(this.doRemove);
        },

        doRemove: function () {
            // Destroy if note is already in trash
            if (Number(this.note.get('trash')) === 1) {
                var self = this;
                $.when(this.note.destroySync()).done(function () {
                    self.redirect();
                });
            }
            else {
                this.note.updateDate();
                $.when(this.note.save({'trash' : 1}))
                 .done(this.redirect);
            }
        },

        redirect: function () {
            App.content.reset();
            App.trigger('notes:rerender');

            App.navigate(URI.link('/notes'), false);
            App.trigger('notes:next');
        }

    });

    return Remove.Controller;
});
{'fraction_non_alphanumeric': 0.15739099610067353, 'fraction_numerical': 0.0014179369018078695, 'mean_word_length': 1.630009319664492, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2395751', 'n_tokens_mistral': 807, 'n_tokens_neox': 771, 'n_words': 145}