chore: extract Utils.elideText()

This commit is contained in:
Patryk Osmaczko 2022-07-04 10:58:51 +02:00 committed by osmaczko
parent ff747c2a5f
commit 51aa4a6d86
2 changed files with 6 additions and 2 deletions

View File

@ -30,7 +30,7 @@ StatusModal {
Layout.fillWidth: true Layout.fillWidth: true
readonly property string elidedPkey: root.privateKey.substring(0, 15) + "..." + root.privateKey.substring(root.privateKey.length - 16) readonly property string elidedPkey: Utils.elideText(root.privateKey, 16)
leftPadding: 0 leftPadding: 0
rightPadding: 0 rightPadding: 0

View File

@ -684,7 +684,11 @@ QtObject {
return "" return ""
} }
let compressedPk = getCompressedPk(publicKey) let compressedPk = getCompressedPk(publicKey)
return compressedPk.substr(0, 6) + "..." + compressedPk.substr(compressedPk.length - 3) return elideText(compressedPk, 6, 3)
}
function elideText(text, leftCharsCount, rightCharsCount = leftCharsCount) {
return text.substr(0, leftCharsCount) + "..." + text.substr(text.length - rightCharsCount)
} }
function getTimeDifference(d1, d2) { function getTimeDifference(d1, d2) {