From 3c8cf27d34f4dfafc7cf619eca45da8a30edac98 Mon Sep 17 00:00:00 2001 From: eal Date: Fri, 25 Aug 2017 11:44:03 +0300 Subject: [PATCH] Add >greentext and { + let rows = [] + const removeMastodon = shtml.replace(/
/g, '
') + .replace(/

/g, '') + .replace(/<\/p>/g, '
') + each(removeMastodon.split('
'), (row) => { + row = row.replace('\n', '').replace('', '').replace('', '') + if (row.match(/^[ ]?>/)) { + rows.push(`${row}
`) + } else if (row.match(/^[ ]?</)) { + rows.push(`${row}
`) + } else { + rows.push(`${row}
`) + } + }) + return rows.join('').replace('

', '
') +} + const isNsfw = (status) => { const nsfwRegex = /#nsfw/i return includes(status.tags, 'nsfw') || !!status.text.match(nsfwRegex) @@ -94,6 +112,12 @@ export const prepareStatus = (status) => { status.nsfw = isNsfw(status) } + // add greentext + if (!status.greentextified) { + status.statusnet_html = greentextify(status.statusnet_html) + status.greentextified = true + } + // Set deleted flag status.deleted = false @@ -137,10 +161,13 @@ const mergeOrAdd = (arr, obj, item) => { const oldItem = obj[item.id] if (oldItem) { + // save the greentext to avoid re-processing + const greentext = oldItem.statusnet_html // We already have this, so only merge the new info. merge(oldItem, item) // Reactivity fix. oldItem.attachments.splice(oldItem.attachments.length) + oldItem.statusnet_html = greentext return {item: oldItem, new: false} } else { // This is a new item, prepare it