summaryrefslogtreecommitdiff
path: root/packages/backend/src/core
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-03-22 18:18:10 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-03-27 19:51:43 -0400
commitfbdee815dabd5444c9e6b0b91d2a9b5b21b1ca6e (patch)
tree8fc2e7efc176739dcb6ceb767553a1e2575a3586 /packages/backend/src/core
parentdon't log query parameters from mastodon API (diff)
downloadsharkey-fbdee815dabd5444c9e6b0b91d2a9b5b21b1ca6e.tar.gz
sharkey-fbdee815dabd5444c9e6b0b91d2a9b5b21b1ca6e.tar.bz2
sharkey-fbdee815dabd5444c9e6b0b91d2a9b5b21b1ca6e.zip
remove unused async from toMastoApiHtml / fromMastoApiHtml
Diffstat (limited to 'packages/backend/src/core')
-rw-r--r--packages/backend/src/core/MfmService.ts55
1 files changed, 28 insertions, 27 deletions
diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts
index 6c2f673217..dcec71805e 100644
--- a/packages/backend/src/core/MfmService.ts
+++ b/packages/backend/src/core/MfmService.ts
@@ -179,7 +179,7 @@ export class MfmService {
break;
}
- // this is here only to catch upstream changes!
+ // this is here only to catch upstream changes!
case 'ruby--': {
let ruby: [string, string][] = [];
for (const child of node.childNodes) {
@@ -584,9 +584,10 @@ export class MfmService {
}
// the toMastoApiHtml function was taken from Iceshrimp and written by zotan and modified by marie to work with the current MK version
+ // additionally modified by hazelnoot to remove async
@bindThis
- public async toMastoApiHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMentionedRemoteUsers = [], inline = false, quoteUri: string | null = null) {
+ public toMastoApiHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMentionedRemoteUsers = [], inline = false, quoteUri: string | null = null) {
if (nodes == null) {
return null;
}
@@ -597,50 +598,50 @@ export class MfmService {
const body = doc.createElement('p');
- async function appendChildren(children: mfm.MfmNode[], targetElement: any): Promise<void> {
+ function appendChildren(children: mfm.MfmNode[], targetElement: any): void {
if (children) {
- for (const child of await Promise.all(children.map(async (x) => await (handlers as any)[x.type](x)))) targetElement.appendChild(child);
+ for (const child of children.map((x) => (handlers as any)[x.type](x))) targetElement.appendChild(child);
}
}
const handlers: {
[K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => any;
} = {
- async bold(node) {
+ bold(node) {
const el = doc.createElement('span');
el.textContent = '**';
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
el.textContent += '**';
return el;
},
- async small(node) {
+ small(node) {
const el = doc.createElement('small');
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
return el;
},
- async strike(node) {
+ strike(node) {
const el = doc.createElement('span');
el.textContent = '~~';
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
el.textContent += '~~';
return el;
},
- async italic(node) {
+ italic(node) {
const el = doc.createElement('span');
el.textContent = '*';
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
el.textContent += '*';
return el;
},
- async fn(node) {
+ fn(node) {
switch (node.props.name) {
case 'group': { // hack for ruby
const el = doc.createElement('span');
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
return el;
}
case 'ruby': {
@@ -666,7 +667,7 @@ export class MfmService {
if (!rt) {
const el = doc.createElement('span');
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
return el;
}
@@ -679,7 +680,7 @@ export class MfmService {
const rpEndEl = doc.createElement('rp');
rpEndEl.appendChild(doc.createTextNode(')'));
- await appendChildren(node.children.slice(0, node.children.length - 1), rubyEl);
+ appendChildren(node.children.slice(0, node.children.length - 1), rubyEl);
rtEl.appendChild(doc.createTextNode(text.trim()));
rubyEl.appendChild(rpStartEl);
rubyEl.appendChild(rtEl);
@@ -691,7 +692,7 @@ export class MfmService {
default: {
const el = doc.createElement('span');
el.textContent = '*';
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
el.textContent += '*';
return el;
}
@@ -714,9 +715,9 @@ export class MfmService {
return pre;
},
- async center(node) {
+ center(node) {
const el = doc.createElement('div');
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
return el;
},
@@ -755,16 +756,16 @@ export class MfmService {
return el;
},
- async link(node) {
+ link(node) {
const a = doc.createElement('a');
a.setAttribute('rel', 'nofollow noopener noreferrer');
a.setAttribute('target', '_blank');
a.setAttribute('href', node.props.url);
- await appendChildren(node.children, a);
+ appendChildren(node.children, a);
return a;
},
- async mention(node) {
+ mention(node) {
const { username, host, acct } = node.props;
const resolved = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host);
@@ -787,9 +788,9 @@ export class MfmService {
return el;
},
- async quote(node) {
+ quote(node) {
const el = doc.createElement('blockquote');
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
return el;
},
@@ -822,14 +823,14 @@ export class MfmService {
return a;
},
- async plain(node) {
+ plain(node) {
const el = doc.createElement('span');
- await appendChildren(node.children, el);
+ appendChildren(node.children, el);
return el;
},
};
- await appendChildren(nodes, body);
+ appendChildren(nodes, body);
if (quoteUri !== null) {
const a = doc.createElement('a');