summaryrefslogtreecommitdiff
path: root/settings/accounts/ui
diff options
context:
space:
mode:
Diffstat (limited to 'settings/accounts/ui')
-rw-r--r--settings/accounts/ui/MastodonSettingsDisplay.qml15
-rw-r--r--settings/accounts/ui/mastodon-settings.qml13
-rw-r--r--settings/accounts/ui/mastodon-update.qml1
-rw-r--r--settings/accounts/ui/mastodon.qml19
4 files changed, 43 insertions, 5 deletions
diff --git a/settings/accounts/ui/MastodonSettingsDisplay.qml b/settings/accounts/ui/MastodonSettingsDisplay.qml
index a9e2c5a..9a45e45 100644
--- a/settings/accounts/ui/MastodonSettingsDisplay.qml
+++ b/settings/accounts/ui/MastodonSettingsDisplay.qml
@@ -9,6 +9,16 @@ StandardAccountSettingsDisplay {
settingsModified: true
+ function _displayNameFromApiHost(apiHost) {
+ var host = apiHost ? apiHost.toString().trim() : ""
+ host = host.replace(/^https?:\/\//i, "")
+ var pathSeparator = host.indexOf("/")
+ if (pathSeparator !== -1) {
+ host = host.substring(0, pathSeparator)
+ }
+ return host
+ }
+
onAboutToSaveAccount: {
settingsLoader.updateAllSyncProfiles()
@@ -33,6 +43,11 @@ StandardAccountSettingsDisplay {
: ""
if (credentialsUserName.length > 0 && root.account.displayName !== credentialsUserName) {
root.account.displayName = credentialsUserName
+ } else if ((!root.account.displayName || root.account.displayName.toString().trim().length === 0)) {
+ var fallback = _displayNameFromApiHost(root.account.configurationValues("")["api/Host"])
+ if (fallback.length > 0) {
+ root.account.displayName = fallback
+ }
}
var autoSync = root.account.configurationValues("")["FeedViewAutoSync"]
diff --git a/settings/accounts/ui/mastodon-settings.qml b/settings/accounts/ui/mastodon-settings.qml
index 630f51d..6b25bb3 100644
--- a/settings/accounts/ui/mastodon-settings.qml
+++ b/settings/accounts/ui/mastodon-settings.qml
@@ -13,7 +13,18 @@ AccountSettingsAgent {
if (credentialsUserName.length > 0) {
return credentialsUserName
}
- return account.displayName
+ var displayName = account.displayName ? account.displayName.toString().trim() : ""
+ if (displayName.length > 0) {
+ return displayName
+ }
+ var apiHost = account.configurationValues("")["api/Host"]
+ var host = apiHost ? apiHost.toString().trim() : ""
+ host = host.replace(/^https?:\/\//i, "")
+ var pathSeparator = host.indexOf("/")
+ if (pathSeparator !== -1) {
+ host = host.substring(0, pathSeparator)
+ }
+ return host
}
Account {
diff --git a/settings/accounts/ui/mastodon-update.qml b/settings/accounts/ui/mastodon-update.qml
index 3a6c25c..d577b05 100644
--- a/settings/accounts/ui/mastodon-update.qml
+++ b/settings/accounts/ui/mastodon-update.qml
@@ -2,6 +2,7 @@ import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Accounts 1.0
import com.jolla.settings.accounts 1.0
+import com.jolla.settings.accounts.mastodon 1.0
AccountCredentialsAgent {
id: root
diff --git a/settings/accounts/ui/mastodon.qml b/settings/accounts/ui/mastodon.qml
index 758ed9b..3359ce8 100644
--- a/settings/accounts/ui/mastodon.qml
+++ b/settings/accounts/ui/mastodon.qml
@@ -2,6 +2,7 @@ import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Accounts 1.0
import com.jolla.settings.accounts 1.0
+import com.jolla.settings.accounts.mastodon 1.0
AccountCreationAgent {
id: root
@@ -43,6 +44,14 @@ AccountCreationAgent {
return oauthHost(apiHost)
}
+ function _fallbackDisplayName(apiHost) {
+ var display = _displayName(apiHost)
+ if (display.length > 0) {
+ return display
+ }
+ return _displayName(defaultApiHost)
+ }
+
function _showRegistrationError(message, busyPage) {
_registering = false
accountCreationError(message)
@@ -290,10 +299,12 @@ AccountCreationAgent {
? newAccount.defaultCredentialsUserName.toString().trim()
: ""
var providerDisplayName = root._displayName(apiHost)
- if (credentialsUserName.length > 0) {
- newAccount.displayName = credentialsUserName
- } else if (providerDisplayName.length > 0) {
- newAccount.displayName = providerDisplayName
+ var accountDescription = credentialsUserName.length > 0
+ ? credentialsUserName
+ : root._fallbackDisplayName(apiHost)
+ if (accountDescription.length > 0) {
+ newAccount.displayName = accountDescription
+ newAccount.setConfigurationValue("", "description", accountDescription)
}
newAccount.setConfigurationValue("", "api/Host", apiHost)