mirror of
https://github.com/sim1222/misskey.git
synced 2025-04-29 02:37:22 +09:00
Ensure that the _misskey_content attribute will always exist. Because the API endpoint does not require the existence of the `text` field, that field may be `undefined`. By using `?? null` it can be ensured that the value is at least `null`. Furthermore, the rendered HTML of a note with empty text will also be the empty string. From git blame it seems that this behaviour was added because of a Mastodon bug that might have previously existed. Hoever, this seems to be no longer the case as I can find mastodon posts that have empty content. The code could be made a bit more succinct by using the null coercion operator.
9 lines
277 B
TypeScript
9 lines
277 B
TypeScript
import * as mfm from 'mfm-js';
|
|
import { Note } from '@/models/entities/note.js';
|
|
import { toHtml } from '../../../mfm/to-html.js';
|
|
|
|
export default function(note: Note) {
|
|
if (!note.text) return '';
|
|
return toHtml(mfm.parse(note.text), JSON.parse(note.mentionedRemoteUsers));
|
|
}
|