Replace all ==/!= by ===/!==

This commit is contained in:
miruka 2019-12-09 11:35:50 -04:00
parent 3b78d12f9c
commit 13d3f19997
33 changed files with 73 additions and 74 deletions

View File

@ -23,13 +23,12 @@
- EventFile & Downloading (right click on media > save as...)
- Refactoring
- Replace all the `==` by `===`
- Use a singleton for utils.js
- Use HBox for Profile
- Banners
- Composer
- Room Sidepane save/load size
- Room Sidepane save/load size & keybinds
- Fixes
- Pausing uploads doesn't work well with matrix.org

View File

@ -61,10 +61,10 @@ Rectangle {
text: modelData.text
icon.name: modelData.iconName || ""
icon.color: modelData.iconColor || (
name == "ok" || name == "apply" || name == "retry" ?
name === "ok" || name === "apply" || name === "retry" ?
theme.colors.positiveBackground :
name == "cancel" ?
name === "cancel" ?
theme.colors.negativeBackground :
theme.icons.colorize
@ -90,7 +90,7 @@ Rectangle {
Keys.onEnterPressed: Keys.onReturnPressed(event)
Component.onCompleted:
if (name == focusButton) forceActiveFocus()
if (name === focusButton) forceActiveFocus()
Layout.fillWidth: true
Layout.preferredHeight: theme.baseElementsHeight

View File

@ -52,7 +52,7 @@ Image {
parent.height - theme.spacing * 2,
theme.controls.image.maxPauseIndicatorSize,
)
scale: parent.status == Image.Ready && parent.paused ? 1 : 0
scale: parent.status === Image.Ready && parent.paused ? 1 : 0
Behavior on scale { HScaleAnimator { overshoot: 4 } }
}

View File

@ -10,5 +10,5 @@ Label {
color: theme.colors.text
linkColor: theme.colors.link
maximumLineCount: elide == Label.ElideNone ? Number.MAX_VALUE : 1
maximumLineCount: elide === Label.ElideNone ? Number.MAX_VALUE : 1
}

View File

@ -13,7 +13,7 @@ JsonListModel {
let obj = JSON.parse(JSON.stringify(item))
for (let role in obj) {
if (obj[role]["objectName"] != undefined) {
if (obj[role]["objectName"] !== undefined) {
obj[role] = toObject(item[role])
}
}

View File

@ -3,5 +3,5 @@ import QtQuick 2.12
Loader {
id: loader
asynchronous: true
visible: status == Loader.Ready
visible: status === Loader.Ready
}

View File

@ -32,7 +32,7 @@ HImage {
if (! image) return // if it was destroyed
if (! isMxc) {
if (source != mxc) source = mxc
if (source !== mxc) source = mxc
show = image.visible
return
}
@ -43,7 +43,7 @@ HImage {
py.callCoro("media_cache." + method, args, path => {
if (! image) return
if (image.cachedPath != path) image.cachedPath = path
if (image.cachedPath !== path) image.cachedPath = path
image.broken = false
image.show = image.visible

View File

@ -1,7 +1,7 @@
import QtQuick 2.12
HAvatar {
name: displayName[0] == "#" && displayName.length > 1 ?
name: displayName[0] === "#" && displayName.length > 1 ?
displayName.substring(1) :
displayName

View File

@ -54,7 +54,7 @@ TextEdit {
var lastPos = container.selectionStartPosition
}
if (first == index && last == index) {
if (first === index && last === index) {
select(
label.positionAt(firstPos.x, firstPos.y),
label.positionAt(lastPos.x, lastPos.y),
@ -65,10 +65,10 @@ TextEdit {
{
label.selectAll()
} else if (first == index) {
} else if (first === index) {
label.select(positionAt(firstPos.x, firstPos.y), length)
} else if (last == index) {
} else if (last === index) {
label.select(0, positionAt(lastPos.x, lastPos.y))
} else {
@ -121,8 +121,8 @@ TextEdit {
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: {
tapCount == 2 ? selectWordAt(eventPoint.position) :
tapCount == 3 ? selectAllText() :
tapCount === 2 ? selectWordAt(eventPoint.position) :
tapCount === 3 ? selectAllText() :
container.clearSelection()
}
}

View File

@ -31,7 +31,7 @@ TabButton {
readonly property alias label: contentItem.label
property color backgroundColor:
TabBar.index % 2 == 0 ?
TabBar.index % 2 === 0 ?
theme.controls.tab.background : theme.controls.tab.alternateBackground
property bool loading: false

View File

@ -154,7 +154,7 @@ HColumnLayout {
boundPosition >= savedDuration - 500 ?
"restart" :
media.playbackState == MediaPlayer.PlayingState ? "pause" :
media.playbackState === MediaPlayer.PlayingState ? "pause" :
"play"

View File

@ -83,7 +83,7 @@ Rectangle {
Rectangle {
id: buttonsRightPadding
color: theme.controls.button.background
visible: bannerGrid.flow == GridLayout.TopToBottom
visible: bannerGrid.flow === GridLayout.TopToBottom
Layout.fillWidth: true
Layout.fillHeight: true

View File

@ -157,7 +157,7 @@ Rectangle {
let parts = lineText.split(indent)
for (const [i, part] of parts.entries()) {
if (i == parts.length - 1 || part) { break }
if (i === parts.length - 1 || part) { break }
indents += 1
}
@ -191,8 +191,8 @@ Rectangle {
return
}
if (ev.modifiers == Qt.NoModifier &&
ev.key == Qt.Key_Backspace &&
if (ev.modifiers === Qt.NoModifier &&
ev.key === Qt.Key_Backspace &&
! textArea.selectedText)
{
ev.accepted = true

View File

@ -7,7 +7,7 @@ Column {
id: eventDelegate
width: eventList.width
topPadding:
model.event_type == "RoomCreateEvent" ? 0 :
model.event_type === "RoomCreateEvent" ? 0 :
dayBreak ? theme.spacing * 4 :
talkBreak ? theme.spacing * 6 :
combine ? theme.spacing / 2 :

View File

@ -11,7 +11,7 @@ Rectangle {
HSelectableLabelContainer {
id: selectableLabelContainer
anchors.fill: parent
reversed: eventList.verticalLayoutDirection == ListView.BottomToTop
reversed: eventList.verticalLayoutDirection === ListView.BottomToTop
DragHandler {
target: null
@ -33,11 +33,11 @@ Rectangle {
Timer {
id: dragFlicker
interval: 100
running: speed != 0
running: speed !== 0
repeat: true
onTriggered: {
if (eventList.verticalOvershoot != 0) return
if (eventList.verticalOvershoot !== 0) return
if (speed < 0 && eventList.atYEnd) return
if (eventList.atYBeggining) {
if (bouncedStart) { return } else { bouncedStart = true }
@ -116,13 +116,13 @@ Rectangle {
}
function canDayBreak(item, itemAfter) {
if (itemAfter && itemAfter.event_type == "RoomCreateEvent")
if (itemAfter && itemAfter.event_type === "RoomCreateEvent")
return true
if (! item || ! itemAfter || ! item.date || ! itemAfter.date)
return false
return item.date.getDate() != itemAfter.date.getDate()
return item.date.getDate() !== itemAfter.date.getDate()
}
function loadPastEvents() {

View File

@ -29,7 +29,7 @@ HLoader {
]
readonly property int type: {
if (singleMediaInfo.event_type == "RoomAvatarEvent")
if (singleMediaInfo.event_type === "RoomAvatarEvent")
return EventDelegate.Media.Image
let mainType = singleMediaInfo.media_mime.split("/")[0].toLowerCase()

View File

@ -32,8 +32,8 @@ Rectangle {
text: {
let tm = chat.roomInfo.typing_members
if (tm.length == 0) return ""
if (tm.length == 1) return qsTr("%1 is typing...").arg(tm[0])
if (tm.length === 0) return ""
if (tm.length === 1) return qsTr("%1 is typing...").arg(tm[0])
return qsTr("%1 and %2 are typing...")
.arg(tm.slice(0, -1).join(", ")).arg(tm.slice(-1)[0])

View File

@ -38,12 +38,12 @@ Item {
})
nameFilters:
fileType == HFileDialogOpener.FileType.Images ?
fileType === HFileDialogOpener.FileType.Images ?
[filters.images, filters.all] :
[filters.all]
folder: StandardPaths.writableLocation(
fileType == HFileDialogOpener.FileType.Images ?
fileType === HFileDialogOpener.FileType.Images ?
StandardPaths.PicturesLocation :
StandardPaths.HomeLocation
)

View File

@ -52,7 +52,7 @@ HPage {
width: ready ? parent.width : 96
source: ready ?
modelData :
(modelData == "Profile.qml" ?
(modelData === "Profile.qml" ?
"../../Base/HBusyIndicator.qml" : "")
}
}

View File

@ -147,7 +147,7 @@ HGridLayout {
}
HLabeledTextField {
property bool changed: field.text != accountInfo.display_name
property bool changed: field.text !== accountInfo.display_name
readonly property string fText: field.text
onFTextChanged: accountSettings.headerName = field.text
@ -168,7 +168,7 @@ HGridLayout {
property string currentAlias:
window.settings.writeAliases[userId] || ""
property bool changed: field.text != currentAlias
property bool changed: field.text !== currentAlias
id: aliasField
label.text: qsTr("Write alias:")

View File

@ -116,8 +116,8 @@ HBox {
HButton {
icon.name: modelData
circle: true
checked: signInWith == modelData
enabled: modelData == "username"
checked: signInWith === modelData
enabled: modelData === "username"
autoExclusive: true
onClicked: signInWith = modelData
}

View File

@ -14,9 +14,9 @@ BoxPopup {
box.focusButton: "ok"
onOk: py.callClientCoro(userId, "room_forget", [roomId], () => {
if (window.uiState.page == "Chat/Chat.qml" &&
window.uiState.pageProperties.userId == userId &&
window.uiState.pageProperties.roomId == roomId)
if (window.uiState.page === "Chat/Chat.qml" &&
window.uiState.pageProperties.userId === userId &&
window.uiState.pageProperties.roomId === roomId)
{
pageLoader.showPage("Default")
Qt.callLater(popup.destroy)

View File

@ -82,7 +82,7 @@ BoxPopup {
theme.colors.negativeBackground
Layout.preferredWidth:
passwordValid == null ||
passwordValid === null ||
(validateWhileTyping && ! okClicked && ! passwordValid) ?
0 :implicitWidth

View File

@ -45,7 +45,7 @@ BoxPopup {
if ((modelSources["Account"] || []).length < 2) {
pageLoader.showPage("AddAccount/AddAccount")
} else if (window.uiState.pageProperties.userId == userId) {
} else if (window.uiState.pageProperties.userId === userId) {
pageLoader.showPage("Default")
}

View File

@ -180,7 +180,7 @@ Item {
// Chat
HShortcut {
enabled: window.uiState.page == "Chat/Chat.qml"
enabled: window.uiState.page === "Chat/Chat.qml"
sequences: settings.keys.clearRoomMessages
onActivated: Utils.makePopup(
"Popups/ClearMessagesPopup.qml",
@ -193,7 +193,7 @@ Item {
}
HShortcut {
enabled: window.uiState.page == "Chat/Chat.qml"
enabled: window.uiState.page === "Chat/Chat.qml"
sequences: settings.keys.sendFile
onActivated: Utils.makeObject(
"Dialogs/SendFilePicker.qml",
@ -208,7 +208,7 @@ Item {
}
HShortcut {
enabled: window.uiState.page == "Chat/Chat.qml"
enabled: window.uiState.page === "Chat/Chat.qml"
sequences: settings.keys.sendFileFromPathInClipboard
onActivated: Utils.sendFile(
window.uiState.pageProperties.userId,

View File

@ -13,8 +13,8 @@ HTileDelegate {
theme.sidePane.account.collapsedOpacity : 1
shouldBeCurrent:
window.uiState.page == "Pages/AccountSettings/AccountSettings.qml" &&
window.uiState.pageProperties.userId == model.data.user_id
window.uiState.page === "Pages/AccountSettings/AccountSettings.qml" &&
window.uiState.pageProperties.userId === model.data.user_id
setCurrentTimer.running:
! sidePaneList.activateLimiter.running && ! sidePane.hasFocus

View File

@ -10,9 +10,9 @@ HTileDelegate {
opacity: model.data.left ? theme.sidePane.room.leftRoomOpacity : 1
shouldBeCurrent:
window.uiState.page == "Chat/Chat.qml" &&
window.uiState.pageProperties.userId == model.user_id &&
window.uiState.pageProperties.roomId == model.data.room_id
window.uiState.page === "Chat/Chat.qml" &&
window.uiState.pageProperties.userId === model.user_id &&
window.uiState.pageProperties.roomId === model.data.room_id
setCurrentTimer.running:
! sidePaneList.activateLimiter.running && ! sidePane.hasFocus
@ -54,7 +54,7 @@ HTileDelegate {
Utils.dateIsToday(lastEvent.date) ?
Utils.formatTime(lastEvent.date, false) : // no seconds
lastEvent.date.getFullYear() == new Date().getFullYear() ?
lastEvent.date.getFullYear() === new Date().getFullYear() ?
Qt.formatDate(lastEvent.date, "d MMM") : // e.g. "5 Dec"
lastEvent.date.getFullYear()

View File

@ -26,13 +26,13 @@ HListView {
for (let i = 0; i < window.sidePaneModelSource.length; i++) {
let item = window.sidePaneModelSource[i]
if (item.type == "Account" ||
if (item.type === "Account" ||
(filter ?
Utils.filterMatches(filter, item.data.filter_string) :
! window.uiState.collapseAccounts[item.user_id]))
{
if (filter && show.length && item.type == "Account" &&
show[show.length - 1].type == "Account" &&
if (filter && show.length && item.type === "Account" &&
show[show.length - 1].type === "Account" &&
! Utils.filterMatches(
filter, show[show.length - 1].data.filter_string)
) {
@ -47,7 +47,7 @@ HListView {
}
let last = show[show.length - 1]
if (show.length && filter && last.type == "Account" &&
if (show.length && filter && last.type === "Account" &&
! Utils.filterMatches(filter, last.data.filter_string))
{
// If filter active, last item is an account and last item
@ -95,7 +95,7 @@ HListView {
if (! currentItem) incrementCurrentIndex()
if (currentItem.item.delegateModel.type == "Account") {
if (currentItem.item.delegateModel.type === "Account") {
currentItem.item.toggleCollapse()
return
}
@ -103,7 +103,7 @@ HListView {
for (let i = 0; i < model.source.length; i++) {
let item = model.source[i]
if (item.type == "Account" && item.user_id ==
if (item.type === "Account" && item.user_id ==
currentItem.item.delegateModel.user_id)
{
currentIndex = i
@ -121,7 +121,7 @@ HListView {
delegate: Loader {
width: sidePaneList.width
Component.onCompleted: setSource(
model.type == "Account" ?
model.type === "Account" ?
"AccountDelegate.qml" : "RoomDelegate.qml",
{view: sidePaneList}
)

View File

@ -29,7 +29,7 @@ HRowLayout {
Component.onCompleted: filterField.text = uiState.sidePaneFilter
onTextChanged: {
if (window.uiState.sidePaneFilter == text) return
if (window.uiState.sidePaneFilter === text) return
window.uiState.sidePaneFilter = text
window.uiStateChanged()
}

View File

@ -82,7 +82,7 @@ Item {
let page = window.uiState.page
let props = window.uiState.pageProperties
if (page == "Chat/Chat.qml") {
if (page === "Chat/Chat.qml") {
pageLoader.showRoom(props.userId, props.roomId)
} else {
pageLoader._show(page, props)
@ -133,7 +133,7 @@ Item {
}
onStatusChanged: if (status == Loader.Ready) {
onStatusChanged: if (status === Loader.Ready) {
pageLoader.takeFocus()
appearAnimation.start()
}

View File

@ -18,10 +18,10 @@ ApplicationWindow {
readonly property alias hovered: windowHover.hovered
readonly property bool hidden:
Qt.application.state == Qt.ApplicationSuspended ||
Qt.application.state == Qt.ApplicationHidden ||
window.visibility == window.Minimized ||
window.visibility == window.Hidden
Qt.application.state === Qt.ApplicationSuspended ||
Qt.application.state === Qt.ApplicationHidden ||
window.visibility === window.Minimized ||
window.visibility === window.Hidden
// NOTE: For JS object variables, the corresponding method to notify
// key/value changes must be called manually, e.g. settingsChanged().

View File

@ -7,7 +7,7 @@ function onExitRequested(exitCode) {
function onAlertRequested() {
if (Qt.application.state != Qt.ApplicationActive) {
if (Qt.application.state !== Qt.ApplicationActive) {
window.alert(window.settings.alertOnMessageForMsec)
}
}
@ -32,7 +32,7 @@ function onCoroutineDone(uuid, result, error, traceback) {
function onModelUpdated(syncId, data, serializedSyncId) {
if (serializedSyncId == ["Account"] || serializedSyncId[0] == "Room") {
if (serializedSyncId === ["Account"] || serializedSyncId[0] === "Room") {
py.callCoro("get_flat_sidepane_data", [], data => {
window.sidePaneModelSource = data
})

View File

@ -102,7 +102,7 @@ function escapeHtml(string) {
function processedEventText(ev) {
if (ev.event_type == "RoomMessageEmote")
if (ev.event_type === "RoomMessageEmote")
return coloredNameHtml(ev.sender_name, ev.sender_id) + " " + ev.content
let unknown = ev.event_type === "RoomMessageUnknown"
@ -124,7 +124,7 @@ function processedEventText(ev) {
function filterMatches(filter, text) {
let filter_lower = filter.toLowerCase()
if (filter_lower == filter) {
if (filter_lower === filter) {
// Consider case only if filter isn't all lowercase (smart case)
filter = filter_lower
text = text.toLowerCase()
@ -170,9 +170,9 @@ function minutesBetween(date1, date2) {
function dateIsDay(date, dayDate) {
return date.getDate() == dayDate.getDate() &&
date.getMonth() == dayDate.getMonth() &&
date.getFullYear() == dayDate.getFullYear()
return date.getDate() === dayDate.getDate() &&
date.getMonth() === dayDate.getMonth() &&
date.getFullYear() === dayDate.getFullYear()
}