From 5ea3d462b9d6c952ab5e77f120df489c049baf25 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 4 Aug 2026 18:04:20 +0300 Subject: [PATCH] optional chaining --- src/components/announcement/announcement.js | 3 +-- .../announcements_page/announcements_page.js | 3 +-- src/components/attachment/attachment.js | 8 +++---- src/components/conversation/conversation.js | 2 +- src/components/desktop_nav/desktop_nav.js | 3 +-- .../edit_status_modal/edit_status_modal.js | 2 +- src/components/emoji_input/suggestor.js | 2 +- src/components/flash/flash.js | 2 +- src/components/image_cropper/image_cropper.js | 2 +- src/components/mention_link/mention_link.js | 8 +++---- .../mrf_transparency_panel.js | 2 +- src/components/navigation/filter.js | 2 +- src/components/poll/poll.js | 6 ++--- src/components/popover/popover.js | 23 +++++++++---------- .../post_status_form/post_status_form.js | 8 +++---- .../post_status_modal/post_status_modal.js | 2 +- src/components/quote/quote_form.js | 2 +- src/components/rich_content/rich_content.jsx | 7 +++--- src/components/search/search.js | 2 +- .../tabs/old_theme_tab/old_theme_tab.js | 6 ++--- src/components/side_drawer/side_drawer.js | 2 +- src/components/status/status.js | 2 +- src/components/status_body/status_body.js | 9 ++++---- src/components/still-image/still-image.js | 4 ++-- src/lib/persisted_state.js | 2 +- src/modules/api.js | 2 +- src/modules/statuses.js | 2 +- src/services/chat_utils/chat_utils.js | 3 +-- .../entity_normalizer.service.js | 2 +- .../notification_utils/notification_utils.js | 5 +--- src/services/theme_data/theme_data.service.js | 4 ++-- src/stores/chats.js | 4 ++-- src/stores/interface.js | 3 +-- src/stores/sync_config.js | 6 +++-- 34 files changed, 68 insertions(+), 77 deletions(-) diff --git a/src/components/announcement/announcement.js b/src/components/announcement/announcement.js index ee427533f..6f6190ebb 100644 --- a/src/components/announcement/announcement.js +++ b/src/components/announcement/announcement.js @@ -30,8 +30,7 @@ const Announcement = { }), canEditAnnouncement() { return ( - this.currentUser && - this.currentUser.privileges.has('announcements_manage_announcements') + this.currentUser?.privileges.has('announcements_manage_announcements') ) }, content() { diff --git a/src/components/announcements_page/announcements_page.js b/src/components/announcements_page/announcements_page.js index 0f7933e5f..a8d498075 100644 --- a/src/components/announcements_page/announcements_page.js +++ b/src/components/announcements_page/announcements_page.js @@ -34,8 +34,7 @@ const AnnouncementsPage = { }, canPostAnnouncement() { return ( - this.currentUser && - this.currentUser.privileges.has('announcements_manage_announcements') + this.currentUser?.privileges.has('announcements_manage_announcements') ) }, }, diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index f7d6ebf10..6556b07a0 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -165,16 +165,16 @@ const Attachment = { useMediaViewerStore().setCurrentMedia(this.attachment) }, onEdit(event) { - this.edit && this.edit(this.attachment, event) + this.edit?.(this.attachment, event) }, onRemove() { - this.remove && this.remove(this.attachment) + this.remove?.(this.attachment) }, onShiftUp() { - this.shiftUp && this.shiftUp(this.attachment) + this.shiftUp?.(this.attachment) }, onShiftDn() { - this.shiftDn && this.shiftDn(this.attachment) + this.shiftDn?.(this.attachment) }, stopFlash() { this.$refs.flash.closePlayer() diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 0bbf01e6a..fcde9477c 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -375,7 +375,7 @@ const conversation = { return !!(this.expanded || this.isPage) }, hiddenStyle() { - const height = (this.status && this.status.virtualHeight) || '120px' + const height = this.status?.virtualHeight || '120px' return this.virtualHidden ? { height } : {} }, threadDisplayStatus() { diff --git a/src/components/desktop_nav/desktop_nav.js b/src/components/desktop_nav/desktop_nav.js index fb23299d2..cc2c5aca9 100644 --- a/src/components/desktop_nav/desktop_nav.js +++ b/src/components/desktop_nav/desktop_nav.js @@ -45,8 +45,7 @@ export default { data: () => ({ searchBarHidden: true, supportsMask: - window.CSS && - window.CSS.supports && + window.CSS?.supports && (window.CSS.supports('mask-size', 'contain') || window.CSS.supports('-webkit-mask-size', 'contain') || window.CSS.supports('-moz-mask-size', 'contain') || diff --git a/src/components/edit_status_modal/edit_status_modal.js b/src/components/edit_status_modal/edit_status_modal.js index c3ba7e4cb..78c5c51aa 100644 --- a/src/components/edit_status_modal/edit_status_modal.js +++ b/src/components/edit_status_modal/edit_status_modal.js @@ -43,7 +43,7 @@ const EditStatusModal = { isFormVisible(val) { if (val) { this.$nextTick( - () => this.$el && this.$el.querySelector('textarea').focus(), + () => this.$el?.querySelector('textarea').focus(), ) } }, diff --git a/src/components/emoji_input/suggestor.js b/src/components/emoji_input/suggestor.js index d5e83ecb2..c31cb6717 100644 --- a/src/components/emoji_input/suggestor.js +++ b/src/components/emoji_input/suggestor.js @@ -79,7 +79,7 @@ export const suggestUsers = ({ dispatch, state }) => { const userSearch = (query) => dispatch('searchUsers', { query }) const debounceUserSearch = (query) => { - cancelUserSearch && cancelUserSearch() + cancelUserSearch?.() return new Promise((resolve, reject) => { timeout = setTimeout(() => { userSearch(query).then(resolve).catch(reject) diff --git a/src/components/flash/flash.js b/src/components/flash/flash.js index 3c25abea1..48d342d2f 100644 --- a/src/components/flash/flash.js +++ b/src/components/flash/flash.js @@ -44,7 +44,7 @@ const Flash = { }) }, closePlayer() { - this.ruffleInstance && this.ruffleInstance.remove() + this.ruffleInstance?.remove() this.player = false this.$emit('playerClosed') }, diff --git a/src/components/image_cropper/image_cropper.js b/src/components/image_cropper/image_cropper.js index c8529c8e6..b85ef6626 100644 --- a/src/components/image_cropper/image_cropper.js +++ b/src/components/image_cropper/image_cropper.js @@ -50,7 +50,7 @@ const ImageCropper = { }, readFile() { const fileInput = this.$refs.input - if (fileInput.files != null && fileInput.files[0] != null) { + if (fileInput?.files?.[0]) { this.file = fileInput.files[0] const reader = new window.FileReader() reader.onload = (e) => { diff --git a/src/components/mention_link/mention_link.js b/src/components/mention_link/mention_link.js index f1861748b..ff4612395 100644 --- a/src/components/mention_link/mention_link.js +++ b/src/components/mention_link/mention_link.js @@ -76,12 +76,12 @@ const MentionLink = { computed: { user() { return ( - this.url && this.$store && this.$store.getters.findUserByUrl(this.url) + this.url && this.$store?.getters.findUserByUrl(this.url) ) }, isYou() { // FIXME why user !== currentUser??? - return this.user && this.user.id === this.currentUser.id + return this.user?.id === this.currentUser.id }, userName() { return this.user && this.userNameFullUi.split('@')[0] @@ -94,10 +94,10 @@ const MentionLink = { ) }, userNameFull() { - return this.user && this.user.screen_name + return this.user?.screen_name }, userNameFullUi() { - return this.user && this.user.screen_name_ui + return this.user?.screen_name_ui }, highlightData() { return this.highlight[this.user?.screen_name] diff --git a/src/components/mrf_transparency_panel/mrf_transparency_panel.js b/src/components/mrf_transparency_panel/mrf_transparency_panel.js index b2048984d..7f2a16186 100644 --- a/src/components/mrf_transparency_panel/mrf_transparency_panel.js +++ b/src/components/mrf_transparency_panel/mrf_transparency_panel.js @@ -11,7 +11,7 @@ import { useInstanceStore } from 'src/stores/instance.js' */ const toInstanceReasonObject = (instances, info, key) => { return instances.map((instance) => { - if (info[key] && info[key][instance] && info[key][instance].reason) { + if (info[key]?.[instance]?.reason) { return { instance, reason: info[key][instance].reason } } return { instance, reason: '' } diff --git a/src/components/navigation/filter.js b/src/components/navigation/filter.js index 0255db6aa..ff91d97d9 100644 --- a/src/components/navigation/filter.js +++ b/src/components/navigation/filter.js @@ -15,7 +15,7 @@ export const filterNavigation = ( if (!isFederating && set.has('federating')) return false if (!currentUser && isPrivate && set.has('!private')) return false if (!currentUser && !(anon || anonRoute)) return false - if ((!currentUser || !currentUser.locked) && set.has('lockedUser')) + if ((!currentUser?.locked) && set.has('lockedUser')) return false if (!hasChats && set.has('chats')) return false if (!hasAnnouncements && set.has('announcements')) return false diff --git a/src/components/poll/poll.js b/src/components/poll/poll.js index b93a6699d..f2d4b0ee5 100644 --- a/src/components/poll/poll.js +++ b/src/components/poll/poll.js @@ -39,13 +39,13 @@ export default { return storePoll || {} }, options() { - return (this.poll && this.poll.options) || [] + return (this.poll?.options) || [] }, expiresAt() { - return (this.poll && this.poll.expires_at) || null + return (this.poll?.expires_at) || null }, expired() { - return (this.poll && this.poll.expired) || false + return (this.poll?.expired) || false }, expirationLabel() { if (useMergedConfigStore().mergedConfig.useAbsoluteTimeFormat) { diff --git a/src/components/popover/popover.js b/src/components/popover/popover.js index 9a06c4e69..857caadcb 100644 --- a/src/components/popover/popover.js +++ b/src/components/popover/popover.js @@ -130,7 +130,7 @@ const Popover = { // its children are what are inside the slot. Expect only one v-slot:trigger. const anchorEl = this.anchorEl || - (this.$refs.trigger && this.$refs.trigger.children[0]) || + (this.$refs.trigger?.children[0]) || this.$el // SVGs don't have offsetWidth/Height, use fallback const anchorHeight = anchorEl.offsetHeight || anchorEl.clientHeight @@ -155,8 +155,7 @@ const Popover = { // Minor optimization, don't call a slow reflow call if we don't have to const parentScreenBox = - this.boundTo && - (this.boundTo.x === 'container' || this.boundTo.y === 'container') && + (this.boundTo?.x === 'container' || this.boundTo?.y === 'container') && this.containerBoundingClientRect() const margin = this.margin || {} @@ -164,7 +163,7 @@ const Popover = { // What are the screen bounds for the popover? Viewport vs container // when using viewport, using default margin values to dodge the navbar const xBounds = - this.boundTo && this.boundTo.x === 'container' + this.boundTo?.x === 'container' ? { min: parentScreenBox.left + (margin.left || 0), max: parentScreenBox.right - (margin.right || 0), @@ -175,7 +174,7 @@ const Popover = { } const yBounds = - this.boundTo && this.boundTo.y === 'container' + this.boundTo?.y === 'container' ? { min: parentScreenBox.top + (margin.top || 0), max: parentScreenBox.bottom - (margin.bottom || 0), @@ -247,12 +246,12 @@ const Popover = { if (bottomBoundary + content.offsetHeight > yBounds.max) usingTop = true if (topBoundary - content.offsetHeight < yBounds.min) usingTop = false - const yOffset = (this.offset && this.offset.y) || 0 + const yOffset = (this.offset?.y) || 0 translateY = usingTop ? topBoundary - yOffset - content.offsetHeight : bottomBoundary + yOffset - const xOffset = (this.offset && this.offset.x) || 0 + const xOffset = (this.offset?.x) || 0 translateX = origin.x + horizOffset + xOffset } else { // Default to whatever user wished with placement prop @@ -268,12 +267,12 @@ const Popover = { if (rightBoundary + content.offsetWidth > xBounds.max) usingLeft = true if (leftBoundary - content.offsetWidth < xBounds.min) usingLeft = false - const xOffset = (this.offset && this.offset.x) || 0 + const xOffset = (this.offset?.x) || 0 translateX = usingLeft ? leftBoundary - xOffset - content.offsetWidth : rightBoundary + xOffset - const yOffset = (this.offset && this.offset.y) || 0 + const yOffset = (this.offset?.y) || 0 translateY = origin.y + vertOffset + yOffset } @@ -298,7 +297,7 @@ const Popover = { }, 0) const wasHidden = this.hidden this.hidden = false - this.parentPopover && this.parentPopover.onChildPopoverState(this, true) + this.parentPopover?.onChildPopoverState(this, true) if (this.trigger === 'click' || this.stayOnClick) { document.addEventListener('click', this.onClickOutside) } @@ -316,7 +315,7 @@ const Popover = { if (this.disabled) return if (!this.hidden) this.$emit('close') this.hidden = true - this.parentPopover && this.parentPopover.onChildPopoverState(this, false) + this.parentPopover?.onChildPopoverState(this, false) if (this.trigger === 'click') { document.removeEventListener('click', this.onClickOutside) } @@ -366,7 +365,7 @@ const Popover = { onClickOutside(e) { if (this.disableClickOutside) return if (this.hidden) return - if (this.$refs.content && this.$refs.content.contains(e.target)) return + if (this.$refs.content?.contains(e.target)) return if (this.$el.contains(e.target)) return if (this.childrenShown.size > 0) return this.hidePopover() diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 02a70e388..dacca5b3c 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -316,7 +316,7 @@ const PostStatusForm = { }, // -Edit isEdit() { - return typeof this.statusId !== 'undefined' && this.statusId.trim() !== '' + return this.statusId !== undefined && this.statusId.trim() !== '' }, // -Reply isReply() { @@ -619,7 +619,7 @@ const PostStatusForm = { this.newStatus.quote = null this.newStatus.nsfw = this.defaultNewStatus.nsfw this.newStatus.mediaDescriptions = {} - this.$refs.mediaUpload && this.$refs.mediaUpload.clearFile() + this.$refs.mediaUpload?.clearFile() if (this.preserveFocus) { this.$nextTick(() => { this.$refs.textarea.focus() @@ -809,7 +809,7 @@ const PostStatusForm = { } }, fileDrop(e) { - if (e.dataTransfer && e.dataTransfer.types.includes('Files')) { + if (e.dataTransfer?.types.includes('Files')) { e.preventDefault() // allow dropping text like before this.dropFiles = e.dataTransfer.files clearTimeout(this.dropStopTimeout) @@ -826,7 +826,7 @@ const PostStatusForm = { }, fileDrag(e) { e.dataTransfer.dropEffect = this.uploadFileLimitReached ? 'none' : 'copy' - if (e.dataTransfer && e.dataTransfer.types.includes('Files')) { + if (e.dataTransfer?.types.includes('Files')) { clearTimeout(this.dropStopTimeout) this.showDropIcon = 'show' } diff --git a/src/components/post_status_modal/post_status_modal.js b/src/components/post_status_modal/post_status_modal.js index 973c2b1a5..7e9f1a4f8 100644 --- a/src/components/post_status_modal/post_status_modal.js +++ b/src/components/post_status_modal/post_status_modal.js @@ -41,7 +41,7 @@ const PostStatusModal = { isFormVisible(val) { if (val) { this.$nextTick( - () => this.$el && this.$el.querySelector('textarea').focus(), + () => this.$el?.querySelector('textarea').focus(), ) } }, diff --git a/src/components/quote/quote_form.js b/src/components/quote/quote_form.js index cd6f9a709..b350fb0e3 100644 --- a/src/components/quote/quote_form.js +++ b/src/components/quote/quote_form.js @@ -102,7 +102,7 @@ export default { type: 'statuses', }) .then((data) => { - if (data?.statuses && data.statuses.length === 1) { + if (data?.statuses?.length === 1) { this.$emit('update:id', data.statuses[0].id) } else { this.handleError(true) diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx index 89a61be89..090253d91 100644 --- a/src/components/rich_content/rich_content.jsx +++ b/src/components/rich_content/rich_content.jsx @@ -251,7 +251,7 @@ export default { return ['', [mentionsLinePadding, renderImage(opener)], ''] } else if (Tag === 'a' && this.handleLinks) { // replace mentions with MentionLink - if (fullAttrs.class && fullAttrs.class.includes('mention')) { + if (fullAttrs.class?.includes('mention')) { // Handling mentions here return renderMention(attrs, children) } else { @@ -260,8 +260,7 @@ export default { } else if (Tag === 'span') { if ( this.handleLinks && - fullAttrs.class && - fullAttrs.class.includes('h-card') + fullAttrs.class?.includes('h-card') ) { return ['', children.map(processItem), ''] } @@ -300,7 +299,7 @@ export default { const attrs = getAttrs(opener, () => true) // should only be this if ( - (fullAttrs.class && fullAttrs.class.includes('hashtag')) || // Pleroma style + (fullAttrs.class?.includes('hashtag')) || // Pleroma style fullAttrs.rel === 'tag' // Mastodon style ) { return renderHashtag(attrs, children, encounteredTextReverse) diff --git a/src/components/search/search.js b/src/components/search/search.js index 0a1f779bb..1a5f8b51d 100644 --- a/src/components/search/search.js +++ b/src/components/search/search.js @@ -122,7 +122,7 @@ const Search = { return 'statuses' }, lastHistoryRecord(hashtag) { - return hashtag.history && hashtag.history[0] + return hashtag.history?.[0] }, }, } diff --git a/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js b/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js index 7a2673621..40df1b98e 100644 --- a/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js +++ b/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js @@ -346,7 +346,7 @@ export default { }, }, currentShadowFallback() { - return (this.previewTheme.shadows || {})[this.shadowSelected] + return this.previewTheme.shadows?.[this.shadowSelected] }, currentShadow: { get() { @@ -425,8 +425,8 @@ export default { this.dismissWarning() const version = origin === 'localStorage' && !theme.colors ? 'l1' : fileVersion - const snapshotEngineVersion = (theme || {}).themeEngineVersion - const themeEngineVersion = (source || {}).themeEngineVersion || 2 + const snapshotEngineVersion = theme?.themeEngineVersion + const themeEngineVersion = source?.themeEngineVersion || 2 const versionsMatch = themeEngineVersion === CURRENT_VERSION const sourceSnapshotMismatch = theme !== undefined && diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index 369177c7a..a1dca8161 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -61,7 +61,7 @@ const SideDrawer = { this.toggleDrawer, ) - if (this.currentUser && this.currentUser.locked) { + if (this.currentUser?.locked) { this.$store.dispatch('startFetchingFollowRequests') } }, diff --git a/src/components/status/status.js b/src/components/status/status.js index 61a553ef6..cd3ae44d0 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -129,7 +129,7 @@ const Status = { showReasonMutedThread() { return ( (this.status.thread_muted || - (this.status.reblog && this.status.reblog.thread_muted)) && + (this.status.reblog?.thread_muted)) && !this.inConversation ) }, diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index 5e94e6fa4..dc74426ca 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -152,11 +152,10 @@ const StatusBody = { ...mapState(useMergedConfigStore, ['mergedConfig']), }, mounted() { - this.status.attentions && - this.status.attentions.forEach((attn) => { - const { id } = attn - this.$store.dispatch('fetchUserIfMissing', id) - }) + this.status.attentions?.forEach((attn) => { + const { id } = attn + this.$store.dispatch('fetchUserIfMissing', id) + }) }, methods: { onParseReady(event) { diff --git a/src/components/still-image/still-image.js b/src/components/still-image/still-image.js index 29a4ed1de..809bd8c7d 100644 --- a/src/components/still-image/still-image.js +++ b/src/components/still-image/still-image.js @@ -51,7 +51,7 @@ const StillImage = { } const image = this.$refs.src if (!image) return - this.imageLoadHandler && this.imageLoadHandler(image) + this.imageLoadHandler?.(image) const canvas = this.$refs.canvas if (!canvas) return const width = image.naturalWidth @@ -61,7 +61,7 @@ const StillImage = { canvas.getContext('2d').drawImage(image, 0, 0, width, height) }, onError() { - this.imageLoadError && this.imageLoadError() + this.imageLoadError?.() }, }, watch: { diff --git a/src/lib/persisted_state.js b/src/lib/persisted_state.js index f6375dfed..aef1cc8dc 100644 --- a/src/lib/persisted_state.js +++ b/src/lib/persisted_state.js @@ -185,7 +185,7 @@ export const piniaPersistPlugin = } const fallbackValue = await storage.getItem(vuexKey) - if (fallbackValue && fallbackValue[id]) { + if (fallbackValue?.[id]) { console.info(`Migrating ${id} store data from vuex to pinia`) const res = fallbackValue[id] await storage.setItem(key, res) diff --git a/src/modules/api.js b/src/modules/api.js index e26336c05..92b849a2b 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -336,7 +336,7 @@ const api = { } }, disconnectFromSocket({ commit, state }) { - state.socket && state.socket.disconnect() + state.socket?.disconnect() commit('setSocket', null) }, }, diff --git a/src/modules/statuses.js b/src/modules/statuses.js index ee5e50a39..e3878e85c 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -134,7 +134,7 @@ const sortById = (a, b) => { const sortTimeline = (timeline) => { timeline.visibleStatuses = timeline.visibleStatuses.sort(sortById) timeline.statuses = timeline.statuses.sort(sortById) - timeline.minVisibleId = (last(timeline.visibleStatuses) || {}).id + timeline.minVisibleId = last(timeline.visibleStatuses)?.id return timeline } diff --git a/src/services/chat_utils/chat_utils.js b/src/services/chat_utils/chat_utils.js index ccf91e85c..05ba80bc3 100644 --- a/src/services/chat_utils/chat_utils.js +++ b/src/services/chat_utils/chat_utils.js @@ -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 } diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 9a5a642fd..9eea7e459 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -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]) { diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js index 6cb3dbc19..2339f1431 100644 --- a/src/services/notification_utils/notification_utils.js +++ b/src/services/notification_utils/notification_utils.js @@ -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 } diff --git a/src/services/theme_data/theme_data.service.js b/src/services/theme_data/theme_data.service.js index 4747c22c3..4f1fe0a76 100644 --- a/src/services/theme_data/theme_data.service.js +++ b/src/services/theme_data/theme_data.service.js @@ -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, ) } } diff --git a/src/stores/chats.js b/src/stores/chats.js index bc5b7f101..c66bc2658 100644 --- a/src/stores/chats.js +++ b/src/stores/chats.js @@ -69,8 +69,8 @@ export const useChatsStore = defineStore('chats', { if (chat) { const isNewMessage = - (chat.lastMessage && chat.lastMessage.id) !== - (updatedChat.lastMessage && updatedChat.lastMessage.id) + (chat.lastMessage?.id) !== + (updatedChat.lastMessage?.id) chat.lastMessage = updatedChat.lastMessage chat.unread = updatedChat.unread chat.updated_at = updatedChat.updated_at diff --git a/src/stores/interface.js b/src/stores/interface.js index dc92d6067..cc56e6a48 100644 --- a/src/stores/interface.js +++ b/src/stores/interface.js @@ -60,8 +60,7 @@ export const useInterfaceStore = defineStore('interface', { }, browserSupport: { cssFilter: - window.CSS && - window.CSS.supports && + window.CSS?.supports && (window.CSS.supports('filter', 'drop-shadow(0 0)') || window.CSS.supports('-webkit-filter', 'drop-shadow(0 0)')), localFonts: typeof window.queryLocalFonts === 'function', diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 87083d850..723cd9397 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -196,9 +196,11 @@ export const _getRecentData = (cache, live, isTest) => { export const _getAllFlags = (recent, stale) => { return Array.from( + recentStorage = toRaw(recent?.flagStorage) + staleStorage = toRaw(stale?.flagStorage) new Set([ - ...Object.keys(toRaw((recent || {}).flagStorage || {})), - ...Object.keys(toRaw((stale || {}).flagStorage || {})), + ...Object.keys(recentStorage || {}), + ...Object.keys(staleStorage || {}), ]), ) }