<commit_before><!--
  - @copyright Copyright (c) 2019 <NAME> <<EMAIL>>
  -
  - @author <NAME> <<EMAIL>>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - This program is free software: you can redistribute it and/or modify
  - it under the terms of the GNU Affero General Public License as
  - published by the Free Software Foundation, either version 3 of the
  - License, or (at your option) any later version.
  -
  - This program is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  - GNU Affero General Public License for more details.
  -
  - You should have received a copy of the GNU Affero General Public License
  - along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<docs>
This component is intended to be used both in `NewMessageForm` and `Message`
components.
</docs>

<template>
	<div class="quote">
		<div class="quote__main">
			<div class="quote__main__author">
				<h6>{{ actorDisplayName }}</h6>
			</div>
			<div class="quote__main__text">
				<p>{{ message }}</p>
			</div>
		</div>
		<div v-if="isNewMessageFormQuote" class="quote__main__right">
			<Actions class="quote__main__right__actions">
				<ActionButton
					icon="icon-close"
					:close-after-click="true"
					@click.stop="handleAbortReply" />
			</Actions>
		</div>
	</div>
</template>

<script>
import Actions from 'nextcloud-vue/dist/Components/Actions'
import ActionButton from 'nextcloud-vue/dist/Components/ActionButton'

export default {
	name: 'Quote',
	components: {
		Actions,
		ActionButton,
	},
	props: {
		/**
		 * The sender of the message to be replied to.
		 */
		actorDisplayName: {
			type: String,
			required: true,
		},
		/**
		 * The text of the message to be replied to.
		 */
		message: {
			type: String,
			required: true,
		},
		/**
		 * The message id of the message to be replied to.
		 */
		id: {
			type: Number,
			required: true,
		},
		/**
		 * The conversation token of the message to be replied to.
		 */
		token: {
			type: String,
			required: true,
		},
		/**
		 * If the quote component is used in the `NewMessageForm` component we display
		 * the remove button.
		 */
		isNewMessageFormQuote: {
			type: Boolean,
			default: false,
		},
	},
	methods: {
		/**
		 * Stops the quote-reply operation by removing the MessageToBeReplied from
		 * the quoteReplyStore.
		 */
		handleAbortReply() {
			this.$store.dispatch('removeMessageToBeReplied', this.token)
		},
	},<commit_msg>Use plain replacements in quotes for now<commit_after><!--
  - @copyright Copyright (c) 2019 <NAME> <<EMAIL>>
  -
  - @author <NAME> <<EMAIL>>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - This program is free software: you can redistribute it and/or modify
  - it under the terms of the GNU Affero General Public License as
  - published by the Free Software Foundation, either version 3 of the
  - License, or (at your option) any later version.
  -
  - This program is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  - GNU Affero General Public License for more details.
  -
  - You should have received a copy of the GNU Affero General Public License
  - along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<docs>
This component is intended to be used both in `NewMessageForm` and `Message`
components.
</docs>

<template>
	<div class="quote">
		<div class="quote__main">
			<div class="quote__main__author">
				<h6>{{ actorDisplayName }}</h6>
			</div>
			<div class="quote__main__text">
				<p>{{ simpleQuotedMessage }}</p>
			</div>
		</div>
		<div v-if="isNewMessageFormQuote" class="quote__main__right">
			<Actions class="quote__main__right__actions">
				<ActionButton
					icon="icon-close"
					:close-after-click="true"
					@click.stop="handleAbortReply" />
			</Actions>
		</div>
	</div>
</template>

<script>
import Actions from 'nextcloud-vue/dist/Components/Actions'
import ActionButton from 'nextcloud-vue/dist/Components/ActionButton'

export default {
	name: 'Quote',
	components: {
		Actions,
		ActionButton,
	},
	props: {
		/**
		 * The sender of the message to be replied to.
		 */
		actorDisplayName: {
			type: String,
			required: true,
		},
		/**
		 * The text of the message to be replied to.
		 */
		message: {
			type: String,
			required: true,
		},
		/**
		 * The text of the message to be replied to.
		 */
		messageParameters: {
			type: [Array, Object],
			required: true,
		},
		/**
		 * The message id of the message to be replied to.
		 */
		id: {
			type: Number,
			required: true,
		},
		/**
		 * The conversation token of the message to be replied to.
		 */
		token: {
			type: String,
			required: true,
		},
		/**
		 * If the quote component is used in the `NewMessageForm` component we display
		 * the remove button.
		 */
		isNewMessageFormQuote: {
			type: Boolean,
			default: false,
		},
	},
	computed: {
		/**
		 * This is a simplified version of the last chat message.
		 * Parameters are parsed without markup (just replaced with the name),
		 * e.g. no avatars on mentions.
		 * @returns {string} A simple message to show below the conversation name
		 */
		simpleQuotedMessage() {
			if (!Object.keys(this.messageParameters).length) {
				return this.message
			}

			const params = this.messageParameters
			let subtitle = this.message

			// We don't really use rich objects in the subtitle, instead we fall back to the name of the item
			Object.keys(params).forEach((parameterKey) => {
				subtitle = subtitle.replace('{' + parameterKey + '}', params[parameterKey].name)
			})

			return subtitle
		},
	},
	methods: {
		/**
		 * Stops the quote-reply operation by removing the MessageToBeReplied from
		 * the quoteReplyStore.
		 */
		handleAbortReply() {
			this.$store.dispatch('removeMessageToBeReplied', this.token)
		},
	},
{'fraction_non_alphanumeric': 0.11646785950960901, 'fraction_numerical': 0.0026507620941020544, 'mean_word_length': 3.0625841184387617, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1890064', 'n_tokens_mistral': 2114, 'n_tokens_neox': 1823, 'n_words': 649}