2018-08-29 01:18:58 +00:00
|
|
|
//
|
|
|
|
// Account+Preferences.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 8/28/18.
|
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2018-09-11 14:52:21 +00:00
|
|
|
import Pachyderm
|
2018-08-29 01:18:58 +00:00
|
|
|
|
|
|
|
extension Account {
|
|
|
|
|
|
|
|
var realDisplayName: String {
|
|
|
|
if Preferences.shared.hideCustomEmojiInUsernames {
|
|
|
|
return stripCustomEmoji(from: displayName)
|
|
|
|
} else {
|
|
|
|
return displayName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static let customEmojiRegex = try! NSRegularExpression(pattern: ":[a-zA-Z0-9_]+:", options: [])
|
|
|
|
|
|
|
|
private func stripCustomEmoji(from string: String) -> String {
|
|
|
|
let range = NSRange(location: 0, length: string.utf16.count)
|
|
|
|
return Account.customEmojiRegex.stringByReplacingMatches(in: string, options: [], range: range, withTemplate: "")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|