Skip to content

Commit c8647ff

Browse files
committed
Remove need for manual fetching, go for a Timer instead
1 parent 7d4c321 commit c8647ff

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/qml/QFieldCloudLogin.qml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ Item {
135135

136136
text: parent.displayText
137137
onTextChanged: {
138-
availableProvidersRepeater.model = [];
139-
getAvailableProvidersButton.visible = true;
140-
return text = text.replace(/\s+/g, '');
138+
const cleanedText = text.replace(/\s+/g, '');
139+
if (cleanedText !== cloudConnection.url) {
140+
getAuthenticationProvidersTimer.restart();
141+
} else {
142+
getAuthenticationProvidersTimer.stop();
143+
}
144+
return cleanedText;
141145
}
142146

143147
Keys.onReturnPressed: loginFormSumbitHandler()
@@ -146,6 +150,18 @@ Item {
146150
color: "transparent"
147151
}
148152
}
153+
154+
Timer {
155+
id: getAuthenticationProvidersTimer
156+
interval: 500
157+
repeat: false
158+
running: false
159+
160+
onTriggered: {
161+
cloudConnection.url = serverUrlField.text !== '' && prefixUrlWithProtocol(serverUrlField.text) !== cloudConnection.defaultUrl ? prefixUrlWithProtocol(serverUrlField.text) : cloudConnection.defaultUrl;
162+
cloudConnection.getAuthenticationProviders();
163+
}
164+
}
149165
}
150166

151167
TextField {
@@ -217,7 +233,7 @@ Item {
217233
font: Theme.tipFont
218234
color: Theme.secondaryTextColor
219235
horizontalAlignment: Qt.AlignHCenter
220-
visible: cloudConnection.status === QFieldCloudConnection.Disconnected && (qfieldCloudLogin.hasCredentialsAuthentication && availableProvidersRepeater.count > 2 || availableProvidersRepeater.count > 1 || getAvailableProvidersButton.visible)
236+
visible: cloudConnection.status === QFieldCloudConnection.Disconnected && (qfieldCloudLogin.hasCredentialsAuthentication && availableProvidersRepeater.count > 2 || availableProvidersRepeater.count > 1)
221237
}
222238

223239
Repeater {
@@ -236,19 +252,6 @@ Item {
236252
}
237253
}
238254

239-
QfButton {
240-
id: getAvailableProvidersButton
241-
Layout.fillWidth: true
242-
text: qsTr("Retrieve additional sign in methods")
243-
enabled: !cloudConnection.isFetchingAvailableProviders
244-
visible: false
245-
246-
onClicked: {
247-
cloudConnection.url = serverUrlField.text !== '' && prefixUrlWithProtocol(serverUrlField.text) !== cloudConnection.defaultUrl ? prefixUrlWithProtocol(serverUrlField.text) : cloudConnection.defaultUrl;
248-
cloudConnection.getAuthenticationProviders();
249-
}
250-
}
251-
252255
Text {
253256
id: cloudRegisterLabel
254257
Layout.fillWidth: true
@@ -315,7 +318,6 @@ Item {
315318
}
316319
qfieldCloudLogin.hasCredentialsAuthentication = credentialAuthenticationAvailable;
317320
availableProvidersRepeater.model = cloudConnection.availableProviders;
318-
getAvailableProvidersButton.visible = false;
319321
}
320322
}
321323

0 commit comments

Comments
 (0)