Qt 5.12 ES5 → 7: Use "() =>" and array.includes

This commit is contained in:
miruka 2019-07-18 03:13:34 -04:00
parent f5d747cbc4
commit 8f53d2e018
11 changed files with 26 additions and 30 deletions

View File

@ -35,18 +35,18 @@ Banner {
]
buttonCallbacks: {
"accept": function(button) {
"accept": button => {
button.loading = true
py.callClientCoro(
chatPage.userId, "join", [chatPage.roomId], function() {
chatPage.userId, "join", [chatPage.roomId], () => {
button.loading = false
})
},
"decline": function(button) {
"decline": button => {
button.loading = true
py.callClientCoro(
chatPage.userId, "room_leave", [chatPage.roomId], function() {
chatPage.userId, "room_leave", [chatPage.roomId], () => {
button.loading = false
})
}

View File

@ -23,10 +23,10 @@ Banner {
]
buttonCallbacks: {
"forget": function(button) {
"forget": button => {
button.loading = true
py.callClientCoro(
chatPage.userId, "room_forget", [chatPage.roomId], function() {
chatPage.userId, "room_forget", [chatPage.roomId], () => {
button.loading = false
})
}

View File

@ -21,8 +21,8 @@ Banner {
]
buttonCallbacks: {
"inspect": function(button) {
"inspect": button => {
print("show")
},
}
}
}

View File

@ -107,7 +107,7 @@ HPage {
to: target.oldWidth
onStopped: target.Layout.minimumWidth = Qt.binding(
function() { return theme.avatar.size }
() => theme.avatar.size
)
}
@ -131,9 +131,7 @@ HPage {
currentWidth = referenceWidth
width = referenceWidth
wasSnapped = true
currentWidth = Qt.binding(
function() { return roomSidePane.width }
)
currentWidth = Qt.binding(() => roomSidePane.width)
} else {
wasSnapped = false
}

View File

@ -48,10 +48,8 @@ HRectangle {
print(canLoad, zz)
eventList.canLoad = false
py.callClientCoro(
chatPage.userId,
"load_past_events",
[chatPage.roomId],
function(more_to_load) { eventList.canLoad = more_to_load }
chatPage.userId, "load_past_events", [chatPage.roomId],
more_to_load => { eventList.canLoad = more_to_load }
)
}
}

View File

@ -14,7 +14,7 @@ function typingTextFor(members, our_user_id) {
}
}
profiles.sort(function(left, right) {
profiles.sort((left, right) => {
if (left.displayName < right.displayName) { return -1 }
if (left.displayName > right.displayName) { return +1 }
return 0

View File

@ -22,11 +22,11 @@ Item {
]
buttonCallbacks: {
"yes": function(button) {
"yes": button => {
py.callCoro("save_account", [userId])
pageStack.showPage("Default")
},
"no": function(button) {
"no": button => {
py.callCoro("forget_account", [userId])
pageStack.showPage("Default")
},

View File

@ -23,13 +23,13 @@ Item {
]
buttonCallbacks: {
"register": function(button) {},
"register": button => {},
"login": function(button) {
"login": button => {
button.loading = true
var args = [idField.text, passwordField.text]
py.callCoro("login_client", args, function(user_id) {
py.callCoro("login_client", args, user_id => {
pageStack.showPage(
"RememberAccount",
{"loginWith": loginWith, "userId": user_id}
@ -38,7 +38,7 @@ Item {
})
},
"forgot": function(button) {}
"forgot": button => {}
}
HRowLayout {

View File

@ -42,17 +42,17 @@ Python {
addImportPath("src")
addImportPath("qrc:/")
importNames("python", ["APP"], function() {
call("APP.is_debug_on", [Qt.application.arguments], function(on) {
importNames("python", ["APP"], () => {
call("APP.is_debug_on", [Qt.application.arguments], on => {
window.debug = on
callCoro("has_saved_accounts", [], function(has) {
callCoro("has_saved_accounts", [], has => {
py.ready = true
willLoadAccounts(has)
if (has) {
py.loadingAccounts = true
py.callCoro("load_saved_accounts", [], function() {
py.callCoro("load_saved_accounts", [], () => {
py.loadingAccounts = false
})
}

View File

@ -13,9 +13,9 @@ Item {
Connections {
target: py
onWillLoadAccounts: function(will) {
onWillLoadAccounts: will => {
pageStack.showPage(will ? "Default": "SignIn")
if (will) {initialRoomTimer.start()}
if (will) { initialRoomTimer.start() }
}
}

View File

@ -112,7 +112,7 @@ function filterMatches(filter, text) {
var words = filter.split(" ")
for (var i = 0; i < words.length; i++) {
if (words[i] && text.indexOf(words[i]) == -1) {
if (words[i] && ! text.includes(words[i])) {
return false
}
}