<commit_before>/**
 * Mail
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2017
 */

define(function(require) {
	'use strict';

	var $ = require('jquery');
	require('jquery-ui/ui/widgets/draggable');
	var _ = require('underscore');
	var Marionette = require('backbone.marionette');
	var CrashReport = require('crashreport');
	var Radio = require('radio');
	var MessageTemplate = require('templates/message-list-item.html');
	var imageplaceholder = require('views/imageplaceholder');
	var tooltip = require('views/tooltip');

	return Marionette.View.extend({
		template: MessageTemplate,
		ui: {
			iconDelete: '.action.delete',
			star: '.star'
		},
		events: {
			'click .action.delete': 'deleteMessage',
			'click .mail-message-header': 'openMessage',
			'click .star': 'toggleMessageStar'
		},
		modelEvents: {
			change: 'render'
		},

		/**
		 * Get the sender/recipient label as string
		 *
		 * @returns {String}
		 */
		_getMessageLabel: function() {
			var sendRec = [];
			if (this.model.folder.get('specialRole') === 'sent') {
				sendRec = this.model.get('to');
			} else {
				sendRec = this.model.get('from');
			}

			switch (sendRec.length) {
				case 0:
					return '-';
				case 1:
					return sendRec[0].label;
				default:
					return sendRec[0].label + ' ' + t('mail', '& others');
			}
		},

		serializeModel: function() {
			var json = this.model.toJSON();
			json.isUnified = require('state').currentAccount && require('state').currentAccount.get('isUnified');
			json.sender = this.model.get('from')[0];
			json.label = this._getMessageLabel();
			return json;
		},
		onRender: function() {
			// Get rid of that pesky wrapping-div.
			// Assumes 1 child element present in template.
			this.$el = this.$el.children();
			// Unwrap the element to prevent infinitely
			// nesting elements during re-render.
			this.$el.unwrap();
			this.setElement(this.$el);

			var displayName = this.model.get('from')[0].label;
			// Don't show any placeholder if 'from' isn't set
			if (displayName) {
				_.each(this.$el.find('.avatar'), function(a) {
					$(a).height('32px');
					imageplaceholder(a, displayName, displayName);
				});
			}
<commit_msg>Fix opening message in message list<commit_after>/**
 * Mail
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2017
 */

define(function(require) {
	'use strict';

	var $ = require('jquery');
	require('jquery-ui/ui/widgets/draggable');
	var _ = require('underscore');
	var Marionette = require('backbone.marionette');
	var CrashReport = require('crashreport');
	var Radio = require('radio');
	var MessageTemplate = require('templates/message-list-item.html');
	var imageplaceholder = require('views/imageplaceholder');
	var tooltip = require('views/tooltip');

	return Marionette.View.extend({
		template: MessageTemplate,
		ui: {
			self: '.app-content-list-item',
			iconDelete: '.action.delete',
			star: '.star'
		},
		events: {
			'click .action.delete': 'deleteMessage',
			'click @ui.self': 'openMessage',
			'click @ui.star': 'toggleMessageStar'
		},
		modelEvents: {
			change: 'render'
		},

		/**
		 * Get the sender/recipient label as string
		 *
		 * @returns {String}
		 */
		_getMessageLabel: function() {
			var sendRec = [];
			if (this.model.folder.get('specialRole') === 'sent') {
				sendRec = this.model.get('to');
			} else {
				sendRec = this.model.get('from');
			}

			switch (sendRec.length) {
				case 0:
					return '-';
				case 1:
					return sendRec[0].label;
				default:
					return sendRec[0].label + ' ' + t('mail', '& others');
			}
		},

		serializeModel: function() {
			var json = this.model.toJSON();
			json.isUnified = require('state').currentAccount && require('state').currentAccount.get('isUnified');
			json.sender = this.model.get('from')[0];
			json.label = this._getMessageLabel();
			return json;
		},
		onRender: function() {
			var displayName = this.model.get('from')[0].label;
			// Don't show any placeholder if 'from' isn't set
			if (displayName) {
				_.each(this.$el.find('.avatar'), function(a) {
					$(a).height('32px');
					imageplaceholder(a, displayName, displayName);
				});
			}

{'fraction_non_alphanumeric': 0.16923430673718096, 'fraction_numerical': 0.006208323752586802, 'mean_word_length': 3.4433094994892746, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4086779', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1385, 'n_words': 320}