optional chaining

This commit is contained in:
Henry Jameson 2026-08-04 18:04:20 +03:00
commit 5ea3d462b9
34 changed files with 68 additions and 77 deletions

View file

@ -13,8 +13,7 @@ export const maybeShowChatNotification = (chat) => {
}
if (
chat.lastMessage.attachment &&
chat.lastMessage.attachment.type === 'image'
chat.lastMessage.attachment?.type === 'image'
) {
opts.image = chat.lastMessage.attachment.preview_url
}

View file

@ -191,7 +191,7 @@ export const parseUser = (data) => {
// Convert punycode to unicode for UI
output.screen_name_ui = output.screen_name
if (output.screen_name && output.screen_name.includes('@')) {
if (output.screen_name?.includes('@')) {
const parts = output.screen_name.split('@')
const unicodeDomain = punycode.toUnicode(parts[1])
if (unicodeDomain !== parts[1]) {

View file

@ -176,11 +176,8 @@ export const prepareNotificationObject = (notification, i18n) => {
// Shows first attached non-nsfw image, if any. Should add configuration for this somehow...
if (
status &&
status.attachments &&
status.attachments.length > 0 &&
!status.nsfw &&
status.attachments[0].mimetype.startsWith('image/')
status?.attachments?.[0]?.mimetype.startsWith('image/')
) {
notifObj.image = status.attachments[0].url
}

View file

@ -245,7 +245,7 @@ export const OPACITIES = Object.entries(SLOT_INHERITANCE).reduce((acc, [k]) => {
[opacity]: {
defaultValue: DEFAULT_OPACITY[opacity] || 1,
affectedSlots: [
...((acc[opacity] && acc[opacity].affectedSlots) || []),
...((acc[opacity]?.affectedSlots) || []),
k,
],
},
@ -413,7 +413,7 @@ export const getColors = (sourceColors, sourceOpacity) =>
outputColor.a = Number(
opacityOverriden
? sourceOpacity[opacitySlot]
: (OPACITIES[opacitySlot] || {}).defaultValue,
: OPACITIES[opacitySlot]?.defaultValue,
)
}
}