Merge pull request 'More sonarqube cleanup' (#3528) from sonarqube-cleanup2 into develop

Reviewed-on: https://git.pleroma.social/pleroma/pleroma-fe/pulls/3528
This commit is contained in:
HJ 2026-08-04 16:25:25 +00:00
commit f7acfe3f59
58 changed files with 154 additions and 172 deletions

View file

@ -3,7 +3,7 @@ import emojis from '@kazvmoe-infra/unicode-emoji-json/data-by-group.json' with {
type: 'json', type: 'json',
} }
Object.keys(emojis).map((k) => { Object.keys(emojis).forEach((k) => {
emojis[k].forEach((e) => { emojis[k].forEach((e) => {
delete e.unicode_version delete e.unicode_version
delete e.emoji_version delete e.emoji_version

View file

@ -29,9 +29,8 @@ const Announcement = {
currentUser: (state) => state.users.currentUser, currentUser: (state) => state.users.currentUser,
}), }),
canEditAnnouncement() { canEditAnnouncement() {
return ( return this.currentUser?.privileges.has(
this.currentUser && 'announcements_manage_announcements',
this.currentUser.privileges.has('announcements_manage_announcements')
) )
}, },
content() { content() {

View file

@ -33,9 +33,8 @@ const AnnouncementsPage = {
return useAnnouncementsStore().announcements return useAnnouncementsStore().announcements
}, },
canPostAnnouncement() { canPostAnnouncement() {
return ( return this.currentUser?.privileges.has(
this.currentUser && 'announcements_manage_announcements',
this.currentUser.privileges.has('announcements_manage_announcements')
) )
}, },
}, },

View file

@ -165,16 +165,16 @@ const Attachment = {
useMediaViewerStore().setCurrentMedia(this.attachment) useMediaViewerStore().setCurrentMedia(this.attachment)
}, },
onEdit(event) { onEdit(event) {
this.edit && this.edit(this.attachment, event) this.edit?.(this.attachment, event)
}, },
onRemove() { onRemove() {
this.remove && this.remove(this.attachment) this.remove?.(this.attachment)
}, },
onShiftUp() { onShiftUp() {
this.shiftUp && this.shiftUp(this.attachment) this.shiftUp?.(this.attachment)
}, },
onShiftDn() { onShiftDn() {
this.shiftDn && this.shiftDn(this.attachment) this.shiftDn?.(this.attachment)
}, },
stopFlash() { stopFlash() {
this.$refs.flash.closePlayer() this.$refs.flash.closePlayer()

View file

@ -1,9 +1,9 @@
<template> <template>
<div <div
v-if="isMessage" v-if="isMessage"
:id="`chatmessage-${message.id}`"
class="chat-message-wrapper" class="chat-message-wrapper"
:class="[classnames, { 'hovered-message-chain': hoveredMessageChain }]" :class="[classnames, { 'hovered-message-chain': hoveredMessageChain }]"
:id="`chatmessage-${message.id}`"
@mouseover="onHover(true)" @mouseover="onHover(true)"
@mouseleave="onHover(false)" @mouseleave="onHover(false)"
> >
@ -40,7 +40,10 @@
</template> </template>
</i18n-t> </i18n-t>
</StatusPopover> </StatusPopover>
<span v-else class="reply-label"> <span
v-else
class="reply-label"
>
{{ $t('status.broken_reply') }} {{ $t('status.broken_reply') }}
</span> </span>
</template> </template>
@ -83,7 +86,10 @@
:user="author" :user="author"
/> />
</UserPopover> </UserPopover>
<div v-else class="avatar-spacer" /> <div
v-else
class="avatar-spacer"
/>
</div> </div>
<div class="chat-message-inner"> <div class="chat-message-inner">
<div class="message-bubble-wrapper"> <div class="message-bubble-wrapper">
@ -98,7 +104,6 @@
@mouseenter="hovered = true" @mouseenter="hovered = true"
@mouseleave="hovered = false" @mouseleave="hovered = false"
> >
<StatusActionButtons <StatusActionButtons
v-if="isStatus" v-if="isStatus"
class="chat-message-toolbar" class="chat-message-toolbar"
@ -112,9 +117,9 @@
@toggle-replying="$emit('replyRequested', message)" @toggle-replying="$emit('replyRequested', message)"
/> />
<div <div
v-else
class="chat-message-toolbar" class="chat-message-toolbar"
:class="{ '-visible': hovered || menuOpened }" :class="{ '-visible': hovered || menuOpened }"
v-else
> >
<Popover <Popover
trigger="click" trigger="click"
@ -221,7 +226,10 @@
v-if="isStatus && repliedTo" v-if="isStatus && repliedTo"
class="reply-indicator" class="reply-indicator"
> >
<FAIcon class="icon" icon="reply" /> <FAIcon
class="icon"
icon="reply"
/>
</div> </div>
<div class="end-spacer" /> <div class="end-spacer" />
</div> </div>
@ -232,7 +240,10 @@
v-else v-else
class="chat-message-date-separator" class="chat-message-date-separator"
> >
<ChatMessageDate :date="chatItem.date" :show-time="chatItem.isTime" /> <ChatMessageDate
:date="chatItem.date"
:show-time="chatItem.isTime"
/>
</div> </div>
</template> </template>

View file

@ -7,7 +7,7 @@
:previous-item="getPreviousItem(index)" :previous-item="getPreviousItem(index)"
:hovered-message-chain="chatItem.messageChainId === hoveredMessageChainId" :hovered-message-chain="chatItem.messageChainId === hoveredMessageChainId"
:focused="chatItem.id === focusedId" :focused="chatItem.id === focusedId"
:repliedTo="chatItem.id === repliedId" :replied-to="chatItem.id === repliedId"
@hover="onMessageHover" @hover="onMessageHover"
@delete="onMessageDelete" @delete="onMessageDelete"
@reply-requested="onReplyRequested" @reply-requested="onReplyRequested"

View file

@ -24,7 +24,7 @@
v-if="messages[0]?.summary_raw_html" v-if="messages[0]?.summary_raw_html"
:html="messages[0].summary_raw_html" :html="messages[0].summary_raw_html"
:emoji="messages[0].emojis" :emoji="messages[0].emojis"
/> />
<template v-else> <template v-else>
{{ $t('timeline.conversation') }} {{ $t('timeline.conversation') }}
</template> </template>

View file

@ -375,7 +375,7 @@ const conversation = {
return !!(this.expanded || this.isPage) return !!(this.expanded || this.isPage)
}, },
hiddenStyle() { hiddenStyle() {
const height = (this.status && this.status.virtualHeight) || '120px' const height = this.status?.virtualHeight || '120px'
return this.virtualHidden ? { height } : {} return this.virtualHidden ? { height } : {}
}, },
threadDisplayStatus() { threadDisplayStatus() {

View file

@ -14,9 +14,9 @@
v-if="conversation[0]?.summary_raw_html" v-if="conversation[0]?.summary_raw_html"
:html="conversation[0].summary_raw_html" :html="conversation[0].summary_raw_html"
:emoji="conversation[0].emojis" :emoji="conversation[0].emojis"
/> />
<template v-else> <template v-else>
{{ $t('timeline.conversation') }} {{ $t('timeline.conversation') }}
</template> </template>
</h1> </h1>
<button <button

View file

@ -45,8 +45,7 @@ export default {
data: () => ({ data: () => ({
searchBarHidden: true, searchBarHidden: true,
supportsMask: supportsMask:
window.CSS && window.CSS?.supports &&
window.CSS.supports &&
(window.CSS.supports('mask-size', 'contain') || (window.CSS.supports('mask-size', 'contain') ||
window.CSS.supports('-webkit-mask-size', 'contain') || window.CSS.supports('-webkit-mask-size', 'contain') ||
window.CSS.supports('-moz-mask-size', 'contain') || window.CSS.supports('-moz-mask-size', 'contain') ||

View file

@ -42,9 +42,7 @@ const EditStatusModal = {
}, },
isFormVisible(val) { isFormVisible(val) {
if (val) { if (val) {
this.$nextTick( this.$nextTick(() => this.$el?.querySelector('textarea').focus())
() => this.$el && this.$el.querySelector('textarea').focus(),
)
} }
}, },
}, },

View file

@ -79,7 +79,7 @@ export const suggestUsers = ({ dispatch, state }) => {
const userSearch = (query) => dispatch('searchUsers', { query }) const userSearch = (query) => dispatch('searchUsers', { query })
const debounceUserSearch = (query) => { const debounceUserSearch = (query) => {
cancelUserSearch && cancelUserSearch() cancelUserSearch?.()
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
timeout = setTimeout(() => { timeout = setTimeout(() => {
userSearch(query).then(resolve).catch(reject) userSearch(query).then(resolve).catch(reject)

View file

@ -44,7 +44,7 @@ const Flash = {
}) })
}, },
closePlayer() { closePlayer() {
this.ruffleInstance && this.ruffleInstance.remove() this.ruffleInstance?.remove()
this.player = false this.player = false
this.$emit('playerClosed') this.$emit('playerClosed')
}, },

View file

@ -50,7 +50,7 @@ const ImageCropper = {
}, },
readFile() { readFile() {
const fileInput = this.$refs.input const fileInput = this.$refs.input
if (fileInput.files != null && fileInput.files[0] != null) { if (fileInput?.files?.[0]) {
this.file = fileInput.files[0] this.file = fileInput.files[0]
const reader = new window.FileReader() const reader = new window.FileReader()
reader.onload = (e) => { reader.onload = (e) => {

View file

@ -75,13 +75,11 @@ const MentionLink = {
}, },
computed: { computed: {
user() { user() {
return ( return this.url && this.$store?.getters.findUserByUrl(this.url)
this.url && this.$store && this.$store.getters.findUserByUrl(this.url)
)
}, },
isYou() { isYou() {
// FIXME why user !== currentUser??? // FIXME why user !== currentUser???
return this.user && this.user.id === this.currentUser.id return this.user?.id === this.currentUser.id
}, },
userName() { userName() {
return this.user && this.userNameFullUi.split('@')[0] return this.user && this.userNameFullUi.split('@')[0]
@ -94,10 +92,10 @@ const MentionLink = {
) )
}, },
userNameFull() { userNameFull() {
return this.user && this.user.screen_name return this.user?.screen_name
}, },
userNameFullUi() { userNameFullUi() {
return this.user && this.user.screen_name_ui return this.user?.screen_name_ui
}, },
highlightData() { highlightData() {
return this.highlight[this.user?.screen_name] return this.highlight[this.user?.screen_name]

View file

@ -405,7 +405,7 @@ const ModerationTools = {
) )
}, },
isAdmin() { isAdmin() {
this.$store.state.users.currentUser.role === 'admin' return this.$store.state.users.currentUser.role === 'admin'
}, },
}, },
methods: { methods: {

View file

@ -11,7 +11,7 @@ import { useInstanceStore } from 'src/stores/instance.js'
*/ */
const toInstanceReasonObject = (instances, info, key) => { const toInstanceReasonObject = (instances, info, key) => {
return instances.map((instance) => { 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: info[key][instance].reason }
} }
return { instance, reason: '' } return { instance, reason: '' }

View file

@ -15,8 +15,7 @@ export const filterNavigation = (
if (!isFederating && set.has('federating')) return false if (!isFederating && set.has('federating')) return false
if (!currentUser && isPrivate && set.has('!private')) return false if (!currentUser && isPrivate && set.has('!private')) return false
if (!currentUser && !(anon || anonRoute)) return false if (!currentUser && !(anon || anonRoute)) return false
if ((!currentUser || !currentUser.locked) && set.has('lockedUser')) if (!currentUser?.locked && set.has('lockedUser')) return false
return false
if (!hasChats && set.has('chats')) return false if (!hasChats && set.has('chats')) return false
if (!hasAnnouncements && set.has('announcements')) return false if (!hasAnnouncements && set.has('announcements')) return false
if (!supportsBubbleTimeline && set.has('supportsBubbleTimeline')) if (!supportsBubbleTimeline && set.has('supportsBubbleTimeline'))

View file

@ -39,13 +39,13 @@ export default {
return storePoll || {} return storePoll || {}
}, },
options() { options() {
return (this.poll && this.poll.options) || [] return this.poll?.options || []
}, },
expiresAt() { expiresAt() {
return (this.poll && this.poll.expires_at) || null return this.poll?.expires_at || null
}, },
expired() { expired() {
return (this.poll && this.poll.expired) || false return this.poll?.expired || false
}, },
expirationLabel() { expirationLabel() {
if (useMergedConfigStore().mergedConfig.useAbsoluteTimeFormat) { if (useMergedConfigStore().mergedConfig.useAbsoluteTimeFormat) {

View file

@ -129,9 +129,7 @@ const Popover = {
// Popover will be anchored around this element, trigger ref is the container, so // Popover will be anchored around this element, trigger ref is the container, so
// its children are what are inside the slot. Expect only one v-slot:trigger. // its children are what are inside the slot. Expect only one v-slot:trigger.
const anchorEl = const anchorEl =
this.anchorEl || this.anchorEl || this.$refs.trigger?.children[0] || this.$el
(this.$refs.trigger && this.$refs.trigger.children[0]) ||
this.$el
// SVGs don't have offsetWidth/Height, use fallback // SVGs don't have offsetWidth/Height, use fallback
const anchorHeight = anchorEl.offsetHeight || anchorEl.clientHeight const anchorHeight = anchorEl.offsetHeight || anchorEl.clientHeight
const anchorWidth = anchorEl.offsetWidth || anchorEl.clientWidth const anchorWidth = anchorEl.offsetWidth || anchorEl.clientWidth
@ -155,8 +153,7 @@ const Popover = {
// Minor optimization, don't call a slow reflow call if we don't have to // Minor optimization, don't call a slow reflow call if we don't have to
const parentScreenBox = const parentScreenBox =
this.boundTo && (this.boundTo?.x === 'container' || this.boundTo?.y === 'container') &&
(this.boundTo.x === 'container' || this.boundTo.y === 'container') &&
this.containerBoundingClientRect() this.containerBoundingClientRect()
const margin = this.margin || {} const margin = this.margin || {}
@ -164,7 +161,7 @@ const Popover = {
// What are the screen bounds for the popover? Viewport vs container // What are the screen bounds for the popover? Viewport vs container
// when using viewport, using default margin values to dodge the navbar // when using viewport, using default margin values to dodge the navbar
const xBounds = const xBounds =
this.boundTo && this.boundTo.x === 'container' this.boundTo?.x === 'container'
? { ? {
min: parentScreenBox.left + (margin.left || 0), min: parentScreenBox.left + (margin.left || 0),
max: parentScreenBox.right - (margin.right || 0), max: parentScreenBox.right - (margin.right || 0),
@ -175,7 +172,7 @@ const Popover = {
} }
const yBounds = const yBounds =
this.boundTo && this.boundTo.y === 'container' this.boundTo?.y === 'container'
? { ? {
min: parentScreenBox.top + (margin.top || 0), min: parentScreenBox.top + (margin.top || 0),
max: parentScreenBox.bottom - (margin.bottom || 0), max: parentScreenBox.bottom - (margin.bottom || 0),
@ -247,12 +244,12 @@ const Popover = {
if (bottomBoundary + content.offsetHeight > yBounds.max) usingTop = true if (bottomBoundary + content.offsetHeight > yBounds.max) usingTop = true
if (topBoundary - content.offsetHeight < yBounds.min) usingTop = false if (topBoundary - content.offsetHeight < yBounds.min) usingTop = false
const yOffset = (this.offset && this.offset.y) || 0 const yOffset = this.offset?.y || 0
translateY = usingTop translateY = usingTop
? topBoundary - yOffset - content.offsetHeight ? topBoundary - yOffset - content.offsetHeight
: bottomBoundary + yOffset : bottomBoundary + yOffset
const xOffset = (this.offset && this.offset.x) || 0 const xOffset = this.offset?.x || 0
translateX = origin.x + horizOffset + xOffset translateX = origin.x + horizOffset + xOffset
} else { } else {
// Default to whatever user wished with placement prop // Default to whatever user wished with placement prop
@ -268,12 +265,12 @@ const Popover = {
if (rightBoundary + content.offsetWidth > xBounds.max) usingLeft = true if (rightBoundary + content.offsetWidth > xBounds.max) usingLeft = true
if (leftBoundary - content.offsetWidth < xBounds.min) usingLeft = false if (leftBoundary - content.offsetWidth < xBounds.min) usingLeft = false
const xOffset = (this.offset && this.offset.x) || 0 const xOffset = this.offset?.x || 0
translateX = usingLeft translateX = usingLeft
? leftBoundary - xOffset - content.offsetWidth ? leftBoundary - xOffset - content.offsetWidth
: rightBoundary + xOffset : rightBoundary + xOffset
const yOffset = (this.offset && this.offset.y) || 0 const yOffset = this.offset?.y || 0
translateY = origin.y + vertOffset + yOffset translateY = origin.y + vertOffset + yOffset
} }
@ -298,7 +295,7 @@ const Popover = {
}, 0) }, 0)
const wasHidden = this.hidden const wasHidden = this.hidden
this.hidden = false this.hidden = false
this.parentPopover && this.parentPopover.onChildPopoverState(this, true) this.parentPopover?.onChildPopoverState(this, true)
if (this.trigger === 'click' || this.stayOnClick) { if (this.trigger === 'click' || this.stayOnClick) {
document.addEventListener('click', this.onClickOutside) document.addEventListener('click', this.onClickOutside)
} }
@ -316,7 +313,7 @@ const Popover = {
if (this.disabled) return if (this.disabled) return
if (!this.hidden) this.$emit('close') if (!this.hidden) this.$emit('close')
this.hidden = true this.hidden = true
this.parentPopover && this.parentPopover.onChildPopoverState(this, false) this.parentPopover?.onChildPopoverState(this, false)
if (this.trigger === 'click') { if (this.trigger === 'click') {
document.removeEventListener('click', this.onClickOutside) document.removeEventListener('click', this.onClickOutside)
} }
@ -366,7 +363,7 @@ const Popover = {
onClickOutside(e) { onClickOutside(e) {
if (this.disableClickOutside) return if (this.disableClickOutside) return
if (this.hidden) 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.$el.contains(e.target)) return
if (this.childrenShown.size > 0) return if (this.childrenShown.size > 0) return
this.hidePopover() this.hidePopover()

View file

@ -316,7 +316,7 @@ const PostStatusForm = {
}, },
// -Edit // -Edit
isEdit() { isEdit() {
return typeof this.statusId !== 'undefined' && this.statusId.trim() !== '' return this.statusId !== undefined && this.statusId.trim() !== ''
}, },
// -Reply // -Reply
isReply() { isReply() {
@ -619,7 +619,7 @@ const PostStatusForm = {
this.newStatus.quote = null this.newStatus.quote = null
this.newStatus.nsfw = this.defaultNewStatus.nsfw this.newStatus.nsfw = this.defaultNewStatus.nsfw
this.newStatus.mediaDescriptions = {} this.newStatus.mediaDescriptions = {}
this.$refs.mediaUpload && this.$refs.mediaUpload.clearFile() this.$refs.mediaUpload?.clearFile()
if (this.preserveFocus) { if (this.preserveFocus) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.textarea.focus() this.$refs.textarea.focus()
@ -809,7 +809,7 @@ const PostStatusForm = {
} }
}, },
fileDrop(e) { fileDrop(e) {
if (e.dataTransfer && e.dataTransfer.types.includes('Files')) { if (e.dataTransfer?.types.includes('Files')) {
e.preventDefault() // allow dropping text like before e.preventDefault() // allow dropping text like before
this.dropFiles = e.dataTransfer.files this.dropFiles = e.dataTransfer.files
clearTimeout(this.dropStopTimeout) clearTimeout(this.dropStopTimeout)
@ -826,7 +826,7 @@ const PostStatusForm = {
}, },
fileDrag(e) { fileDrag(e) {
e.dataTransfer.dropEffect = this.uploadFileLimitReached ? 'none' : 'copy' e.dataTransfer.dropEffect = this.uploadFileLimitReached ? 'none' : 'copy'
if (e.dataTransfer && e.dataTransfer.types.includes('Files')) { if (e.dataTransfer?.types.includes('Files')) {
clearTimeout(this.dropStopTimeout) clearTimeout(this.dropStopTimeout)
this.showDropIcon = 'show' this.showDropIcon = 'show'
} }

View file

@ -1,8 +1,8 @@
<template> <template>
<div <div
v-if="initialized"
ref="form" ref="form"
class="post-status-form" class="post-status-form"
v-if="initialized"
> >
<form <form
autocomplete="off" autocomplete="off"
@ -176,12 +176,12 @@
<input <input
v-if="mentionsLine" v-if="mentionsLine"
:value="mentionsLineReadOnly ? mentionsString : newStatus.mentionsLine" :value="mentionsLineReadOnly ? mentionsString : newStatus.mentionsLine"
@change="onMentionsLineUpdate"
type="text" type="text"
:placeholder="$t('post_status.mentions_line')" :placeholder="$t('post_status.mentions_line')"
:disabled="mentionsLineReadOnly || (posting && !optimisticPosting)" :disabled="mentionsLineReadOnly || (posting && !optimisticPosting)"
size="1" size="1"
class="input mentions-input form-post-mentions unstyled" class="input mentions-input form-post-mentions unstyled"
@change="onMentionsLineUpdate"
> >
<EmojiInput <EmojiInput
ref="emoji-input" ref="emoji-input"
@ -271,14 +271,14 @@
<PollForm <PollForm
v-if="pollsAvailable" v-if="pollsAvailable"
ref="pollForm" ref="pollForm"
:visible="pollFormVisible"
v-model="newStatus.poll" v-model="newStatus.poll"
:visible="pollFormVisible"
/> />
<QuoteForm <QuoteForm
v-if="quotingAvailable" v-if="quotingAvailable"
:id="newStatus.quote?.id"
ref="quoteForm" ref="quoteForm"
:visible="quoteFormVisible" :visible="quoteFormVisible"
:id="newStatus.quote?.id"
:url="newStatus.quote?.url" :url="newStatus.quote?.url"
@update:url="url => newStatus.quote.url = url" @update:url="url => newStatus.quote.url = url"
@update:id="id => newStatus.quote.id = id" @update:id="id => newStatus.quote.id = id"

View file

@ -40,9 +40,7 @@ const PostStatusModal = {
}, },
isFormVisible(val) { isFormVisible(val) {
if (val) { if (val) {
this.$nextTick( this.$nextTick(() => this.$el?.querySelector('textarea').focus())
() => this.$el && this.$el.querySelector('textarea').focus(),
)
} }
}, },
}, },

View file

@ -102,7 +102,7 @@ export default {
type: 'statuses', type: 'statuses',
}) })
.then((data) => { .then((data) => {
if (data?.statuses && data.statuses.length === 1) { if (data?.statuses?.length === 1) {
this.$emit('update:id', data.statuses[0].id) this.$emit('update:id', data.statuses[0].id)
} else { } else {
this.handleError(true) this.handleError(true)

View file

@ -154,7 +154,7 @@ const registration = {
}) })
}, },
replaceNewlines(str) { replaceNewlines(str) {
return str.replace(/\s*\n\s*/g, ' \n') return str.replaceAll(/\s*\n\s*/g, ' \n')
}, },
}, },
} }

View file

@ -181,7 +181,7 @@ export default {
} }
// Processor to use with html_tree_converter // Processor to use with html_tree_converter
const processItem = (item, index, array, what) => { const processItem = (item, index, array) => {
// Handle text nodes - just add emoji // Handle text nodes - just add emoji
if (typeof item === 'string') { if (typeof item === 'string') {
const emptyText = item.trim() === '' const emptyText = item.trim() === ''
@ -251,18 +251,14 @@ export default {
return ['', [mentionsLinePadding, renderImage(opener)], ''] return ['', [mentionsLinePadding, renderImage(opener)], '']
} else if (Tag === 'a' && this.handleLinks) { } else if (Tag === 'a' && this.handleLinks) {
// replace mentions with MentionLink // replace mentions with MentionLink
if (fullAttrs.class && fullAttrs.class.includes('mention')) { if (fullAttrs.class?.includes('mention')) {
// Handling mentions here // Handling mentions here
return renderMention(attrs, children) return renderMention(attrs, children)
} else { } else {
currentMentions = null currentMentions = null
} }
} else if (Tag === 'span') { } else if (Tag === 'span') {
if ( if (this.handleLinks && fullAttrs.class?.includes('h-card')) {
this.handleLinks &&
fullAttrs.class &&
fullAttrs.class.includes('h-card')
) {
return ['', children.map(processItem), ''] return ['', children.map(processItem), '']
} }
} }
@ -281,7 +277,7 @@ export default {
// Processor for back direction (for finding "last" stuff, just easier this way) // Processor for back direction (for finding "last" stuff, just easier this way)
let encounteredTextReverse = false let encounteredTextReverse = false
const processItemReverse = (item, index, array, what) => { const processItemReverse = (item, index, array) => {
// Handle text nodes - just add emoji // Handle text nodes - just add emoji
if (typeof item === 'string') { if (typeof item === 'string') {
const emptyText = item.trim() === '' const emptyText = item.trim() === ''
@ -300,7 +296,7 @@ export default {
const attrs = getAttrs(opener, () => true) const attrs = getAttrs(opener, () => true)
// should only be this // should only be this
if ( if (
(fullAttrs.class && fullAttrs.class.includes('hashtag')) || // Pleroma style fullAttrs.class?.includes('hashtag') || // Pleroma style
fullAttrs.rel === 'tag' // Mastodon style fullAttrs.rel === 'tag' // Mastodon style
) { ) {
return renderHashtag(attrs, children, encounteredTextReverse) return renderHashtag(attrs, children, encounteredTextReverse)
@ -479,7 +475,7 @@ export default {
> >
{this.collapse {this.collapse
? pass2.map((x) => { ? pass2.map((x) => {
if (typeof x === 'string') return x.replace(/\n/g, ' ') if (typeof x === 'string') return x.replaceAll('\n', ' ')
if (!Array.isArray(x)) return x if (!Array.isArray(x)) return x
return x.map((y) => (y.type === 'br' ? ' ' : y)) return x.map((y) => (y.type === 'br' ? ' ' : y))
}) })
@ -547,8 +543,8 @@ export const preProcessPerLine = (html, greentext) => {
(string.includes('&gt;') || string.includes('&lt;')) (string.includes('&gt;') || string.includes('&lt;'))
) { ) {
const cleanedString = string const cleanedString = string
.replace(/<[^>]+?>/gi, '') // remove all tags .replaceAll(/<[^>]+?>/gi, '') // remove all tags
.replace(/@\w+/gi, '') // remove mentions (even failed ones) .replaceAll(/@\w+/gi, '') // remove mentions (even failed ones)
.trim() .trim()
if (cleanedString.startsWith('&gt;')) { if (cleanedString.startsWith('&gt;')) {
return `<span class='greentext'>${string}</span>` return `<span class='greentext'>${string}</span>`

View file

@ -122,7 +122,7 @@ const Search = {
return 'statuses' return 'statuses'
}, },
lastHistoryRecord(hashtag) { lastHistoryRecord(hashtag) {
return hashtag.history && hashtag.history[0] return hashtag.history?.[0]
}, },
}, },
} }

View file

@ -300,7 +300,7 @@ const EmojiTab = {
sortPackFiles(nameOfPack) { sortPackFiles(nameOfPack) {
// Sort by key // Sort by key
const sorted = Object.keys(this.knownPacks[nameOfPack].files) const sorted = Object.keys(this.knownPacks[nameOfPack].files)
.sort() .sort((a, b) => a.localeCompare(b))
.reduce((acc, key) => { .reduce((acc, key) => {
if (key.length === 0) return acc if (key.length === 0) return acc
acc[key] = this.knownPacks[nameOfPack].files[key] acc[key] = this.knownPacks[nameOfPack].files[key]

View file

@ -179,7 +179,7 @@ export default {
[ [
'admin_dash', 'admin_dash',
'temp_overrides', 'temp_overrides',
...this.canonPath.map((p) => p.replace(/\./g, '_DOT_')), ...this.canonPath.map((p) => p.replaceAll('.', '_DOT_')),
'label', 'label',
].join('.'), ].join('.'),
) )
@ -198,7 +198,7 @@ export default {
[ [
'admin_dash', 'admin_dash',
'temp_overrides', 'temp_overrides',
...this.canonPath.map((p) => p.replace(/\./g, '_DOT_')), ...this.canonPath.map((p) => p.replaceAll('.', '_DOT_')),
'description', 'description',
].join('.'), ].join('.'),
) )

View file

@ -257,7 +257,7 @@ const AppearanceTab = {
const result = { const result = {
name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`, name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`,
key: `style.${variant.toLowerCase().replace(/ /g, '_')}`, key: `style.${variant.toLowerCase().replaceAll(' ', '_')}`,
bg, bg,
fg, fg,
text, text,

View file

@ -319,7 +319,7 @@ export default {
return useInterfaceStore().themeDataUsed return useInterfaceStore().themeDataUsed
}, },
shadowsAvailable() { shadowsAvailable() {
return Object.keys(DEFAULT_SHADOWS).sort() return Object.keys(DEFAULT_SHADOWS).sort((a, b) => a.localeCompare(b))
}, },
currentShadowOverriden: { currentShadowOverriden: {
get() { get() {
@ -346,7 +346,7 @@ export default {
}, },
}, },
currentShadowFallback() { currentShadowFallback() {
return (this.previewTheme.shadows || {})[this.shadowSelected] return this.previewTheme.shadows?.[this.shadowSelected]
}, },
currentShadow: { currentShadow: {
get() { get() {
@ -425,8 +425,8 @@ export default {
this.dismissWarning() this.dismissWarning()
const version = const version =
origin === 'localStorage' && !theme.colors ? 'l1' : fileVersion origin === 'localStorage' && !theme.colors ? 'l1' : fileVersion
const snapshotEngineVersion = (theme || {}).themeEngineVersion const snapshotEngineVersion = theme?.themeEngineVersion
const themeEngineVersion = (source || {}).themeEngineVersion || 2 const themeEngineVersion = source?.themeEngineVersion || 2
const versionsMatch = themeEngineVersion === CURRENT_VERSION const versionsMatch = themeEngineVersion === CURRENT_VERSION
const sourceSnapshotMismatch = const sourceSnapshotMismatch =
theme !== undefined && theme !== undefined &&

View file

@ -61,7 +61,7 @@ const SideDrawer = {
this.toggleDrawer, this.toggleDrawer,
) )
if (this.currentUser && this.currentUser.locked) { if (this.currentUser?.locked) {
this.$store.dispatch('startFetchingFollowRequests') this.$store.dispatch('startFetchingFollowRequests')
} }
}, },

View file

@ -128,8 +128,7 @@ const Status = {
computed: { computed: {
showReasonMutedThread() { showReasonMutedThread() {
return ( return (
(this.status.thread_muted || (this.status.thread_muted || this.status.reblog?.thread_muted) &&
(this.status.reblog && this.status.reblog.thread_muted)) &&
!this.inConversation !this.inConversation
) )
}, },

View file

@ -20,9 +20,9 @@
:get-component="getComponent" :get-component="getComponent"
:close="() => { /* no-op */ }" :close="() => { /* no-op */ }"
:do-action="doAction" :do-action="doAction"
@emoji-picker-shown="onEmojiPickerShown"
:default-button-style="useDefaultButtons" :default-button-style="useDefaultButtons"
:hide-label="hideLabels" :hide-label="hideLabels"
@emoji-picker-shown="onEmojiPickerShown"
/> />
<button <button
v-if="showPin && currentUser" v-if="showPin && currentUser"

View file

@ -147,16 +147,15 @@ const StatusBody = {
return this.status.attachments.map((file) => file.type) return this.status.attachments.map((file) => file.type)
}, },
collapsedStatus() { collapsedStatus() {
return this.status.raw_html.replace(/(\n|<br\s?\/?>)/g, ' ') return this.status.raw_html.replaceAll('(\n|<br\s?\/?>)', ' ')
}, },
...mapState(useMergedConfigStore, ['mergedConfig']), ...mapState(useMergedConfigStore, ['mergedConfig']),
}, },
mounted() { mounted() {
this.status.attentions && this.status.attentions?.forEach((attn) => {
this.status.attentions.forEach((attn) => { const { id } = attn
const { id } = attn this.$store.dispatch('fetchUserIfMissing', id)
this.$store.dispatch('fetchUserIfMissing', id) })
})
}, },
methods: { methods: {
onParseReady(event) { onParseReady(event) {
@ -168,7 +167,7 @@ const StatusBody = {
.filter((mention) => !mention.notifying) .filter((mention) => !mention.notifying)
.forEach((mention) => { .forEach((mention) => {
const { content, url } = mention const { content, url } = mention
const cleanedString = content.replace(/<[^>]+?>/gi, '') // remove all tags const cleanedString = content.replaceAll(/<[^>]+?>/gi, '') // remove all tags
if (!cleanedString.startsWith('@')) return if (!cleanedString.startsWith('@')) return
const handle = cleanedString.slice(1) const handle = cleanedString.slice(1)
const host = url.replace(/^https?:\/\//, '').replace(/\/.+?$/, '') const host = url.replace(/^https?:\/\//, '').replace(/\/.+?$/, '')

View file

@ -51,7 +51,7 @@ const StillImage = {
} }
const image = this.$refs.src const image = this.$refs.src
if (!image) return if (!image) return
this.imageLoadHandler && this.imageLoadHandler(image) this.imageLoadHandler?.(image)
const canvas = this.$refs.canvas const canvas = this.$refs.canvas
if (!canvas) return if (!canvas) return
const width = image.naturalWidth const width = image.naturalWidth
@ -61,7 +61,7 @@ const StillImage = {
canvas.getContext('2d').drawImage(image, 0, 0, width, height) canvas.getContext('2d').drawImage(image, 0, 0, width, height)
}, },
onError() { onError() {
this.imageLoadError && this.imageLoadError() this.imageLoadError?.()
}, },
}, },
watch: { watch: {

View file

@ -111,7 +111,11 @@ export default {
type="button" type="button"
role="tab" role="tab"
> >
<img src={props.image} title={props['image-tooltip']} /> <img
src={props.image}
alt={props['image-tooltip']}
title={props['image-tooltip']}
/>
{props.label ? '' : props.label} {props.label ? '' : props.label}
</button> </button>
</div> </div>

View file

@ -196,7 +196,7 @@ export default {
}, },
computed: { computed: {
escapedNewBio() { escapedNewBio() {
return ldEscape(this.newBio).replace(/\n/g, '<br>') return ldEscape(this.newBio).replaceAll('\n', '<br>')
}, },
somethingToSave() { somethingToSave() {
if (this.newName !== this.user.name_unescaped) return true if (this.newName !== this.user.name_unescaped) return true

View file

@ -185,7 +185,7 @@ export const piniaPersistPlugin =
} }
const fallbackValue = await storage.getItem(vuexKey) const fallbackValue = await storage.getItem(vuexKey)
if (fallbackValue && fallbackValue[id]) { if (fallbackValue?.[id]) {
console.info(`Migrating ${id} store data from vuex to pinia`) console.info(`Migrating ${id} store data from vuex to pinia`)
const res = fallbackValue[id] const res = fallbackValue[id]
await storage.setItem(key, res) await storage.setItem(key, res)

View file

@ -336,7 +336,7 @@ const api = {
} }
}, },
disconnectFromSocket({ commit, state }) { disconnectFromSocket({ commit, state }) {
state.socket && state.socket.disconnect() state.socket?.disconnect()
commit('setSocket', null) commit('setSocket', null)
}, },
}, },

View file

@ -134,7 +134,7 @@ const sortById = (a, b) => {
const sortTimeline = (timeline) => { const sortTimeline = (timeline) => {
timeline.visibleStatuses = timeline.visibleStatuses.sort(sortById) timeline.visibleStatuses = timeline.visibleStatuses.sort(sortById)
timeline.statuses = timeline.statuses.sort(sortById) timeline.statuses = timeline.statuses.sort(sortById)
timeline.minVisibleId = (last(timeline.visibleStatuses) || {}).id timeline.minVisibleId = last(timeline.visibleStatuses)?.id
return timeline return timeline
} }

View file

@ -12,10 +12,7 @@ export const maybeShowChatNotification = (chat) => {
body: chat.lastMessage.content, body: chat.lastMessage.content,
} }
if ( if (chat.lastMessage.attachment?.type === 'image') {
chat.lastMessage.attachment &&
chat.lastMessage.attachment.type === 'image'
) {
opts.image = chat.lastMessage.attachment.preview_url opts.image = chat.lastMessage.attachment.preview_url
} }

View file

@ -62,8 +62,8 @@ export const parseUser = (data) => {
}) })
output.fields_text = data.fields.map((field) => { output.fields_text = data.fields.map((field) => {
return { return {
name: unescape(field.name.replace(/<[^>]*>/g, '')), name: unescape(field.name.replaceAll(/<[^>]*>/g, '')),
value: unescape(field.value.replace(/<[^>]*>/g, '')), value: unescape(field.value.replaceAll(/<[^>]*>/g, '')),
} }
}) })
@ -191,7 +191,7 @@ export const parseUser = (data) => {
// Convert punycode to unicode for UI // Convert punycode to unicode for UI
output.screen_name_ui = output.screen_name 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 parts = output.screen_name.split('@')
const unicodeDomain = punycode.toUnicode(parts[1]) const unicodeDomain = punycode.toUnicode(parts[1])
if (unicodeDomain !== parts[1]) { if (unicodeDomain !== parts[1]) {

View file

@ -3,7 +3,7 @@ import { capitalize } from 'lodash'
function humanizeErrors(errors) { function humanizeErrors(errors) {
return Object.entries(errors).reduce((errs, [k, val]) => { return Object.entries(errors).reduce((errs, [k, val]) => {
const message = val.reduce((acc, message) => { const message = val.reduce((acc, message) => {
const key = capitalize(k.replace(/_/g, ' ')) const key = capitalize(k.replaceAll('_', ' '))
return acc + [key, message].join(' ') + '. ' return acc + [key, message].join(' ') + '. '
}, '') }, '')
return [...errs, message] return [...errs, message]

View file

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

View file

@ -66,7 +66,8 @@ const fetchAndUpdate = ({ store, credentials, older = false, sinceId }) => {
const unreadNotifsIds = notifications const unreadNotifsIds = notifications
.filter((n) => !n.seen) .filter((n) => !n.seen)
.map((n) => n.id) .map((n) => n.id)
if (readNotifsIds.length > 0 && readNotifsIds.length > 0) {
if (readNotifsIds.length > 0 && unreadNotifsIds.length > 0) {
const minId = Math.min(...unreadNotifsIds) // Oldest known unread notification const minId = Math.min(...unreadNotifsIds) // Oldest known unread notification
if (minId !== Infinity) { if (minId !== Infinity) {
args.sinceId = null // Don't use since_id since it sorta conflicts with min_id args.sinceId = null // Don't use since_id since it sorta conflicts with min_id

View file

@ -29,7 +29,7 @@ export const createStyleSheet = (id, priority = 1000) => {
addRule(rule) { addRule(rule) {
let newRule = rule let newRule = rule
if (!CSS.supports?.('backdrop-filter', 'blur()')) { if (!CSS.supports?.('backdrop-filter', 'blur()')) {
newRule = newRule.replace(/backdrop-filter:[^;]+;/g, '') // Remove backdrop-filter newRule = newRule.replaceAll(/backdrop-filter:[^;]+;/g, '') // Remove backdrop-filter
} }
if (newRule.startsWith('::-webkit')) { if (newRule.startsWith('::-webkit')) {
@ -44,7 +44,7 @@ export const createStyleSheet = (id, priority = 1000) => {
} }
this.rules.push( this.rules.push(
newRule.replace(/var\(--shadowFilter\)[^;]*;/g, ''), // Remove shadowFilter references newRule.replaceAll(/var\(--shadowFilter\)[^;]*;/g, ''), // Remove shadowFilter references
) )
}, },
} }

View file

@ -1,7 +1,9 @@
/* global process */ /* global process */
function urlBase64ToUint8Array(base64String) { function urlBase64ToUint8Array(base64String) {
const padding = '='.repeat((4 - (base64String.length % 4)) % 4) const padding = '='.repeat((4 - (base64String.length % 4)) % 4)
const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/') const base64 = (base64String + padding)
.replaceAll('-', '+')
.replace(/_/g, '/')
const rawData = window.atob(base64) const rawData = window.atob(base64)
return Uint8Array.from([...rawData].map((char) => char.codePointAt(0))) return Uint8Array.from([...rawData].map((char) => char.codePointAt(0)))

View file

@ -110,13 +110,6 @@ export const genericRuleToSelector =
let arraySelector = Array.isArray(selector) ? selector : [selector] let arraySelector = Array.isArray(selector) ? selector : [selector]
if (ignoreOutOfTreeSelector || liteMode) if (ignoreOutOfTreeSelector || liteMode)
arraySelector = [arraySelector[0]] arraySelector = [arraySelector[0]]
arraySelector
.sort((a) => {
if (a.startsWith(':')) return 1
if (/^[a-z]/.exec(a)) return -1
else return 0
})
.join('')
return arraySelector return arraySelector
}) })

View file

@ -244,10 +244,7 @@ export const OPACITIES = Object.entries(SLOT_INHERITANCE).reduce((acc, [k]) => {
...acc, ...acc,
[opacity]: { [opacity]: {
defaultValue: DEFAULT_OPACITY[opacity] || 1, defaultValue: DEFAULT_OPACITY[opacity] || 1,
affectedSlots: [ affectedSlots: [...(acc[opacity]?.affectedSlots || []), k],
...((acc[opacity] && acc[opacity].affectedSlots) || []),
k,
],
}, },
} }
} else { } else {
@ -413,7 +410,7 @@ export const getColors = (sourceColors, sourceOpacity) =>
outputColor.a = Number( outputColor.a = Number(
opacityOverriden opacityOverriden
? sourceOpacity[opacitySlot] ? sourceOpacity[opacitySlot]
: (OPACITIES[opacitySlot] || {}).defaultValue, : OPACITIES[opacitySlot]?.defaultValue,
) )
} }
} }
@ -460,7 +457,7 @@ export const generatePreset = (input) => {
return composePreset( return composePreset(
colors, colors,
generateRadii(input), generateRadii(input),
generateShadows(input, colors.theme.colors, colors.mod), generateShadows(input, colors.theme.colors),
generateFonts(input), generateFonts(input),
) )
} }

View file

@ -47,7 +47,7 @@ const highlightStyle = (prefs) => {
const highlightClass = (user) => { const highlightClass = (user) => {
return ( return (
'USER____' + user.screen_name?.replace(/\./g, '_').replace(/@/g, '_AT_') 'USER____' + user.screen_name?.replaceAll('.', '_').replace(/@/g, '_AT_')
) )
} }

View file

@ -69,8 +69,7 @@ export const useChatsStore = defineStore('chats', {
if (chat) { if (chat) {
const isNewMessage = const isNewMessage =
(chat.lastMessage && chat.lastMessage.id) !== chat.lastMessage?.id !== updatedChat.lastMessage?.id
(updatedChat.lastMessage && updatedChat.lastMessage.id)
chat.lastMessage = updatedChat.lastMessage chat.lastMessage = updatedChat.lastMessage
chat.unread = updatedChat.unread chat.unread = updatedChat.unread
chat.updated_at = updatedChat.updated_at chat.updated_at = updatedChat.updated_at

View file

@ -146,7 +146,7 @@ export const useEmojiStore = defineStore('emoji', {
async getStaticEmoji() { async getStaticEmoji() {
try { try {
// See build/emojis_plugin for more details // See build/emojis_plugin for more details
const values = (await import('/src/assets/emoji.json')).default const values = (await import('src/assets/emoji.json')).default
const emoji = Object.keys(values).reduce((res, groupId) => { const emoji = Object.keys(values).reduce((res, groupId) => {
res[groupId] = values[groupId].map((e) => ({ res[groupId] = values[groupId].map((e) => ({
@ -231,7 +231,7 @@ export const useEmojiStore = defineStore('emoji', {
.then((allPacks) => { .then((allPacks) => {
// Sort by key // Sort by key
return Object.keys(allPacks) return Object.keys(allPacks)
.sort() .sort((a, b) => a.localeCompare(b))
.reduce((acc, key) => { .reduce((acc, key) => {
if (key.length === 0) return acc if (key.length === 0) return acc
acc[key] = allPacks[key] acc[key] = allPacks[key]

View file

@ -60,8 +60,7 @@ export const useInterfaceStore = defineStore('interface', {
}, },
browserSupport: { browserSupport: {
cssFilter: cssFilter:
window.CSS && window.CSS?.supports &&
window.CSS.supports &&
(window.CSS.supports('filter', 'drop-shadow(0 0)') || (window.CSS.supports('filter', 'drop-shadow(0 0)') ||
window.CSS.supports('-webkit-filter', 'drop-shadow(0 0)')), window.CSS.supports('-webkit-filter', 'drop-shadow(0 0)')),
localFonts: typeof window.queryLocalFonts === 'function', localFonts: typeof window.queryLocalFonts === 'function',
@ -578,7 +577,8 @@ export const useInterfaceStore = defineStore('interface', {
return { name: x.variant, ...cleanDirectives } return { name: x.variant, ...cleanDirectives }
}) })
.forEach((palette) => { .forEach((palette) => {
const key = 'style.' + palette.name.toLowerCase().replace(/ /g, '_') const key =
'style.' + palette.name.toLowerCase().replaceAll(' ', '_')
if (!firstStylePaletteName) firstStylePaletteName = key if (!firstStylePaletteName) firstStylePaletteName = key
palettesIndex[key] = () => Promise.resolve(palette) palettesIndex[key] = () => Promise.resolve(palette)
}) })

View file

@ -195,10 +195,13 @@ export const _getRecentData = (cache, live, isTest) => {
} }
export const _getAllFlags = (recent, stale) => { export const _getAllFlags = (recent, stale) => {
const recentStorage = toRaw(recent?.flagStorage)
const staleStorage = toRaw(stale?.flagStorage)
return Array.from( return Array.from(
new Set([ new Set([
...Object.keys(toRaw((recent || {}).flagStorage || {})), ...Object.keys(recentStorage || {}),
...Object.keys(toRaw((stale || {}).flagStorage || {})), ...Object.keys(staleStorage || {}),
]), ]),
) )
} }

View file

@ -50,7 +50,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
}) })
it('unescapes everything as needed', () => { it('unescapes everything as needed', () => {
@ -67,7 +67,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
}) })
it('replaces mention with mentionsline', () => { it('replaces mention with mentionsline', () => {
@ -83,7 +83,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql( expect(wrapper.html().replaceAll('\n', '')).to.eql(
compwrap(p(mentionsLine(1), ' how are you doing today?')), compwrap(p(mentionsLine(1), ' how are you doing today?')),
) )
}) })
@ -116,7 +116,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
}) })
it('Does not touch links if link handling is disabled', () => { it('Does not touch links if link handling is disabled', () => {
@ -211,7 +211,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
}) })
it("Doesn't add nonexistent emoji to post", () => { it("Doesn't add nonexistent emoji to post", () => {
@ -228,7 +228,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
}) })
it('Greentext + last mentions', () => { it('Greentext + last mentions', () => {
@ -279,7 +279,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
}) })
it('buggy example/hashtags', () => { it('buggy example/hashtags', () => {
@ -315,7 +315,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
}) })
it('rich contents of a mention are handled properly', () => { it('rich contents of a mention are handled properly', () => {
@ -365,8 +365,8 @@ describe('RichContent', () => {
expect( expect(
wrapper wrapper
.html() .html()
.replace(/\n/g, '') .replaceAll('\n', '')
.replace(/<!--.*?-->/g, ''), .replaceAll(/<!--.*?-->/g, ''),
).to.eql(compwrap(expected)) ).to.eql(compwrap(expected))
}) })
@ -438,8 +438,8 @@ describe('RichContent', () => {
expect( expect(
wrapper wrapper
.html() .html()
.replace(/\n/g, '') .replaceAll('\n', '')
.replace(/<!--.*?-->/g, ''), .replaceAll(/<!--.*?-->/g, ''),
).to.eql(compwrap(expected)) ).to.eql(compwrap(expected))
}) })
@ -484,7 +484,7 @@ describe('RichContent', () => {
}, },
}) })
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
}) })
it.skip('[INFORMATIVE] Performance testing, 10 000 simple posts', () => { it.skip('[INFORMATIVE] Performance testing, 10 000 simple posts', () => {

View file

@ -107,7 +107,7 @@ describe('Statuses module', () => {
showImmediately: true, showImmediately: true,
timeline: 'public', timeline: 'public',
}) })
expect(state.timelines.public.maxId).to.eql('1') expect(state.timelines.public.maxId).to.equal('1')
mutations.addNewStatuses(state, { mutations.addNewStatuses(state, {
statuses: [secondStatus], statuses: [secondStatus],
@ -120,7 +120,7 @@ describe('Statuses module', () => {
secondStatus, secondStatus,
status, status,
]) ])
expect(state.timelines.public.maxId).to.eql('1') expect(state.timelines.public.maxId).to.equal('1')
}) })
it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => { it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => {
@ -340,7 +340,7 @@ describe('Statuses module', () => {
expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true) expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true)
expect( expect(
state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id, state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id,
).to.eql('me') ).to.equal('me')
}) })
it('adds a new reaction', () => { it('adds a new reaction', () => {
@ -362,7 +362,7 @@ describe('Statuses module', () => {
expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true) expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true)
expect( expect(
state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id, state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id,
).to.eql('me') ).to.equal('me')
}) })
it('decreases count in existing reaction', () => { it('decreases count in existing reaction', () => {
@ -429,8 +429,8 @@ describe('Statuses module', () => {
mutations.showNewStatuses(state, { timeline: 'public' }) mutations.showNewStatuses(state, { timeline: 'public' })
expect(state.timelines.public.visibleStatuses.length).to.eql(2) expect(state.timelines.public.visibleStatuses.length).to.eql(2)
expect(state.timelines.public.minVisibleId).to.eql('10') expect(state.timelines.public.minVisibleId).to.equal('10')
expect(state.timelines.public.minId).to.eql('10') expect(state.timelines.public.minId).to.equal('10')
}) })
}) })

View file

@ -54,7 +54,7 @@ const run = () => {
// Sort by key // Sort by key
const sorted = Object.keys(emojisObject) const sorted = Object.keys(emojisObject)
.sort() .sort((a, b) => a.localeCompare(b))
.reduce((acc, key) => { .reduce((acc, key) => {
if (key.length === 0) return acc if (key.length === 0) return acc
acc[key] = emojisObject[key] acc[key] = emojisObject[key]