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: { buttonCallbacks: {
"accept": function(button) { "accept": button => {
button.loading = true button.loading = true
py.callClientCoro( py.callClientCoro(
chatPage.userId, "join", [chatPage.roomId], function() { chatPage.userId, "join", [chatPage.roomId], () => {
button.loading = false button.loading = false
}) })
}, },
"decline": function(button) { "decline": button => {
button.loading = true button.loading = true
py.callClientCoro( py.callClientCoro(
chatPage.userId, "room_leave", [chatPage.roomId], function() { chatPage.userId, "room_leave", [chatPage.roomId], () => {
button.loading = false button.loading = false
}) })
} }

View File

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

View File

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

View File

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

View File

@ -48,10 +48,8 @@ HRectangle {
print(canLoad, zz) print(canLoad, zz)
eventList.canLoad = false eventList.canLoad = false
py.callClientCoro( py.callClientCoro(
chatPage.userId, chatPage.userId, "load_past_events", [chatPage.roomId],
"load_past_events", more_to_load => { eventList.canLoad = more_to_load }
[chatPage.roomId],
function(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 }
if (left.displayName > right.displayName) { return +1 } if (left.displayName > right.displayName) { return +1 }
return 0 return 0

View File

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

View File

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

View File

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

View File

@ -13,9 +13,9 @@ Item {
Connections { Connections {
target: py target: py
onWillLoadAccounts: function(will) { onWillLoadAccounts: will => {
pageStack.showPage(will ? "Default": "SignIn") 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(" ") var words = filter.split(" ")
for (var i = 0; i < words.length; i++) { 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 return false
} }
} }