Skip to content

Node.js based forum software built for the modern web

refactor: get rid of helper function

Barış Soner Uşaklı1cc77343baf0
diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.js
index 0e2fcce5d8..7160a1ed51 100644
--- a/public/src/client/topic/postTools.js
+++ b/public/src/client/topic/postTools.js
@@ -324,22 +324,17 @@ define('forum/topic/postTools', [
const username = getUserSlug(button);
const toPid = getData(button, 'data-pid');
- function quote(text) {
- hooks.fire('action:composer.addQuote', {
- tid: tid,
- pid: toPid,
- username: username,
- title: ajaxify.data.titleRaw,
- text: text,
- });
- }
-
- if (selectedNode.text && toPid && toPid === selectedNode.pid) {
- return quote(selectedNode.text);
- }
-
- const { content } = await api.get(`/posts/${encodeURIComponent(toPid)}/raw`);
- quote(content);
+ const body = selectedNode.text && toPid && toPid === selectedNode.pid ?
+ selectedNode.text :
+ (await api.get(`/posts/${encodeURIComponent(toPid)}/raw`)).content;
+
+ hooks.fire('action:composer.addQuote', {
+ tid: tid,
+ pid: toPid,
+ username: username,
+ title: ajaxify.data.titleRaw,
+ body: body,
+ });
});
}