Fix repetitive phone formatting.

This commit is contained in:
John Preston 2024-03-19 11:04:11 +04:00
parent 529eb4e954
commit 8982a49192
2 changed files with 3 additions and 2 deletions

View File

@ -381,13 +381,14 @@ QString FormatImageSizeText(const QSize &size) {
+ QString::number(size.height());
}
QString FormatPhone(const QString &phone) {
QString FormatPhone(QString phone) {
if (phone.isEmpty()) {
return QString();
}
if (phone.at(0) == '0') {
return phone;
}
phone = phone.remove(QChar::Space);
return Countries::Instance().format({
.phone = (phone.at(0) == '+') ? phone.mid(1) : phone,
}).formatted;

View File

@ -24,7 +24,7 @@ inline constexpr auto FileStatusSizeFailed = 0xFFFFFFF2LL;
[[nodiscard]] QString FormatGifAndSizeText(qint64 size);
[[nodiscard]] QString FormatPlayedText(qint64 played, qint64 duration);
[[nodiscard]] QString FormatImageSizeText(const QSize &size);
[[nodiscard]] QString FormatPhone(const QString &phone);
[[nodiscard]] QString FormatPhone(QString phone);
[[nodiscard]] QString FormatTTL(float64 ttl);
[[nodiscard]] QString FormatTTLAfter(float64 ttl);
[[nodiscard]] QString FormatTTLTiny(float64 ttl);