Use const instead of let when possible
This commit is contained in:
@@ -101,7 +101,7 @@ Rectangle {
|
||||
|
||||
let foundAlias = null
|
||||
|
||||
for (let [user, writing_alias] of Object.entries(aliases)) {
|
||||
for (const [user, writing_alias] of Object.entries(aliases)) {
|
||||
if (text.startsWith(writing_alias + " ")) {
|
||||
writingUserId = user
|
||||
foundAlias = new RegExp("^" + writing_alias + " ")
|
||||
@@ -119,15 +119,15 @@ Rectangle {
|
||||
writingUserId = Qt.binding(() => chat.userId)
|
||||
toSend = text
|
||||
|
||||
let vals = Object.values(aliases)
|
||||
const vals = Object.values(aliases)
|
||||
|
||||
let longestAlias =
|
||||
const longestAlias =
|
||||
vals.reduce((a, b) => a.length > b.length ? a: b)
|
||||
|
||||
let textNotStartsWithAnyAlias =
|
||||
const textNotStartsWithAnyAlias =
|
||||
! vals.some(a => a.startsWith(text))
|
||||
|
||||
let textContainsCharNotInAnyAlias =
|
||||
const textContainsCharNotInAnyAlias =
|
||||
vals.every(a => text.split("").some(c => ! a.includes(c)))
|
||||
|
||||
// Only set typing when it's sure that the user will not use
|
||||
@@ -162,21 +162,21 @@ Rectangle {
|
||||
ev.modifiers & Qt.AltModifier)
|
||||
{
|
||||
let indents = 0
|
||||
let parts = lineText.split(indent)
|
||||
const parts = lineText.split(indent)
|
||||
|
||||
for (const [i, part] of parts.entries()) {
|
||||
if (i === parts.length - 1 || part) { break }
|
||||
indents += 1
|
||||
}
|
||||
|
||||
let add = indent.repeat(indents)
|
||||
const add = indent.repeat(indents)
|
||||
textArea.insert(cursorPosition, "\n" + add)
|
||||
return
|
||||
}
|
||||
|
||||
if (textArea.text === "") { return }
|
||||
|
||||
let args = [chat.roomId, toSend]
|
||||
const args = [chat.roomId, toSend]
|
||||
py.callClientCoro(writingUserId, "send_text", args)
|
||||
|
||||
area.clear()
|
||||
|
@@ -71,8 +71,8 @@ HMxcImage {
|
||||
return
|
||||
}
|
||||
|
||||
let toOpen = loader.mediaUrl || loader.thumbnailMxc
|
||||
let isMxc = toOpen.startsWith("mxc://")
|
||||
const toOpen = loader.mediaUrl || loader.thumbnailMxc
|
||||
const isMxc = toOpen.startsWith("mxc://")
|
||||
|
||||
isMxc ?
|
||||
py.callClientCoro(chat.userId, "mxc_to_http", [toOpen], callback) :
|
||||
|
@@ -20,11 +20,11 @@ Rectangle {
|
||||
target: null
|
||||
onActiveChanged: if (! active) dragFlicker.speed = 0
|
||||
onCentroidChanged: {
|
||||
let left = centroid.pressedButtons & Qt.LeftButton
|
||||
let vel = centroid.velocity.y
|
||||
let pos = centroid.position.y
|
||||
let dist = Math.min(selectableLabelContainer.height / 4, 50)
|
||||
let boost = 20 * (pos < dist ? -pos : -(height - pos))
|
||||
const left = centroid.pressedButtons & Qt.LeftButton
|
||||
const vel = centroid.velocity.y
|
||||
const pos = centroid.position.y
|
||||
const dist = Math.min(selectableLabelContainer.height / 4, 50)
|
||||
const boost = 20 * (pos < dist ? -pos : -(height - pos))
|
||||
|
||||
dragFlicker.speed =
|
||||
left && vel && pos < dist ? 1000 + boost :
|
||||
|
@@ -47,19 +47,19 @@ HLoader {
|
||||
if (singleMediaInfo.event_type === "RoomAvatarEvent")
|
||||
return EventDelegate.Media.Image
|
||||
|
||||
let mainType = singleMediaInfo.media_mime.split("/")[0].toLowerCase()
|
||||
const mainType = singleMediaInfo.media_mime.split("/")[0].toLowerCase()
|
||||
|
||||
if (mainType === "image") return EventDelegate.Media.Image
|
||||
if (mainType === "video") return EventDelegate.Media.Video
|
||||
if (mainType === "audio") return EventDelegate.Media.Audio
|
||||
|
||||
let fileEvents = ["RoomMessageFile", "RoomEncryptedFile"]
|
||||
const fileEvents = ["RoomMessageFile", "RoomEncryptedFile"]
|
||||
|
||||
if (fileEvents.includes(singleMediaInfo.event_type))
|
||||
return EventDelegate.Media.File
|
||||
|
||||
// If this is a preview for a link in a normal message
|
||||
let ext = utils.urlExtension(mediaUrl)
|
||||
const ext = utils.urlExtension(mediaUrl)
|
||||
|
||||
if (imageExtensions.includes(ext)) return EventDelegate.Media.Image
|
||||
if (videoExtensions.includes(ext)) return EventDelegate.Media.Video
|
||||
|
Reference in New Issue
Block a user