fix: fix potential null exception (#1765)
This commit is contained in:
parent
4b4cee3662
commit
5c4b44e3dd
|
@ -29,8 +29,16 @@ function tryInitBlurhash () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getActualStatus (statusOrNotification) {
|
||||||
|
return get(statusOrNotification, ['status']) ||
|
||||||
|
get(statusOrNotification, ['notification', 'status'])
|
||||||
|
}
|
||||||
|
|
||||||
async function decodeAllBlurhashes (statusOrNotification) {
|
async function decodeAllBlurhashes (statusOrNotification) {
|
||||||
const status = statusOrNotification.status || statusOrNotification.notification.status
|
const status = getActualStatus(statusOrNotification)
|
||||||
|
if (!status) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const mediaWithBlurhashes = get(status, ['media_attachments'], [])
|
const mediaWithBlurhashes = get(status, ['media_attachments'], [])
|
||||||
.concat(get(status, ['reblog', 'media_attachments'], []))
|
.concat(get(status, ['reblog', 'media_attachments'], []))
|
||||||
.filter(_ => _.blurhash)
|
.filter(_ => _.blurhash)
|
||||||
|
@ -48,7 +56,7 @@ async function decodeAllBlurhashes (statusOrNotification) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function calculatePlainTextContent (statusOrNotification) {
|
async function calculatePlainTextContent (statusOrNotification) {
|
||||||
const status = statusOrNotification.status || statusOrNotification.notification.status
|
const status = getActualStatus(statusOrNotification)
|
||||||
if (!status) {
|
if (!status) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue