Remove unused code

Closes: #1105
This commit is contained in:
Bryan Montz
2023-05-07 14:13:06 -05:00
committed by William Casarin
parent 0da10eb716
commit 9847f12c95
105 changed files with 52 additions and 1873 deletions

View File

@@ -8,51 +8,8 @@
import SwiftUI
import Combine
let PPM_SIZE: CGFloat = 80.0
let BANNER_HEIGHT: CGFloat = 150.0;
func isHttpsUrl(_ string: String) -> Bool {
let urlRegEx = "^https://.*$"
let urlTest = NSPredicate(format:"SELF MATCHES %@", urlRegEx)
return urlTest.evaluate(with: string)
}
func isImage(_ urlString: String) -> Bool {
let imageTypes = ["image/jpg", "image/jpeg", "image/png", "image/gif", "image/tiff", "image/bmp", "image/webp"]
guard let url = URL(string: urlString) else {
return false
}
var result = false
let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: url) { data, response, error in
if let error = error {
print(error)
semaphore.signal()
return
}
guard let httpResponse = response as? HTTPURLResponse,
let contentType = httpResponse.allHeaderFields["Content-Type"] as? String else {
semaphore.signal()
return
}
if imageTypes.contains(contentType.lowercased()) {
result = true
}
semaphore.signal()
}
task.resume()
semaphore.wait()
return result
}
struct EditMetadataView: View {
let damus_state: DamusState
@State var display_name: String
@@ -66,7 +23,6 @@ struct EditMetadataView: View {
let profile: Profile?
@Environment(\.dismiss) var dismiss
@Environment(\.colorScheme) var colorScheme
@State var confirm_ln_address: Bool = false
@StateObject var profileUploadViewModel = ProfileUploadingViewModel()
@@ -86,10 +42,6 @@ struct EditMetadataView: View {
_ln = State(initialValue: data?.lud16 ?? data?.lud06 ?? "")
}
func imageBorderColor() -> Color {
colorScheme == .light ? DamusColors.white : DamusColors.black
}
func to_profile() -> Profile {
let profile = self.profile ?? Profile()

View File

@@ -12,30 +12,16 @@ struct EventProfileName: View {
let damus_state: DamusState
let pubkey: String
let profile: Profile?
let prefix: String
let show_friend_confirmed: Bool
@State var display_name: DisplayName?
@State var nip05: NIP05?
let size: EventViewKind
init(pubkey: String, profile: Profile?, damus: DamusState, show_friend_confirmed: Bool, size: EventViewKind = .normal) {
init(pubkey: String, profile: Profile?, damus: DamusState, size: EventViewKind = .normal) {
self.damus_state = damus
self.pubkey = pubkey
self.profile = profile
self.prefix = ""
self.show_friend_confirmed = show_friend_confirmed
self.size = size
}
init(pubkey: String, profile: Profile?, prefix: String, damus: DamusState, show_friend_confirmed: Bool, size: EventViewKind = .normal) {
self.damus_state = damus
self.pubkey = pubkey
self.profile = profile
self.prefix = prefix
self.show_friend_confirmed = show_friend_confirmed
self.size = size
}
@@ -102,6 +88,6 @@ struct EventProfileName: View {
struct EventProfileName_Previews: PreviewProvider {
static var previews: some View {
EventProfileName(pubkey: "pk", profile: nil, damus: test_damus_state(), show_friend_confirmed: true)
EventProfileName(pubkey: "pk", profile: nil, damus: test_damus_state())
}
}

View File

@@ -13,13 +13,6 @@ struct MaybeAnonPfpView: View {
let pubkey: String
let size: CGFloat
init(state: DamusState, event: NostrEvent, pubkey: String, size: CGFloat) {
self.state = state
self.is_anon = event_is_anonymous(ev: event)
self.pubkey = pubkey
self.size = size
}
init(state: DamusState, is_anon: Bool, pubkey: String, size: CGFloat) {
self.state = state
self.is_anon = is_anon

View File

@@ -30,27 +30,24 @@ struct ProfileName: View {
let profile: Profile?
let prefix: String
let show_friend_confirmed: Bool
let show_nip5_domain: Bool
@State var display_name: DisplayName?
@State var nip05: NIP05?
init(pubkey: String, profile: Profile?, damus: DamusState, show_friend_confirmed: Bool, show_nip5_domain: Bool = true) {
init(pubkey: String, profile: Profile?, damus: DamusState, show_nip5_domain: Bool = true) {
self.pubkey = pubkey
self.profile = profile
self.prefix = ""
self.show_friend_confirmed = show_friend_confirmed
self.show_nip5_domain = show_nip5_domain
self.damus_state = damus
}
init(pubkey: String, profile: Profile?, prefix: String, damus: DamusState, show_friend_confirmed: Bool, show_nip5_domain: Bool = true) {
init(pubkey: String, profile: Profile?, prefix: String, damus: DamusState, show_nip5_domain: Bool = true) {
self.pubkey = pubkey
self.profile = profile
self.prefix = prefix
self.damus_state = damus
self.show_friend_confirmed = show_friend_confirmed
self.show_nip5_domain = show_nip5_domain
}
@@ -108,6 +105,6 @@ struct ProfileName: View {
struct ProfileName_Previews: PreviewProvider {
static var previews: some View {
ProfileName(pubkey:
test_damus_state().pubkey, profile: make_test_profile(), damus: test_damus_state(), show_friend_confirmed: true)
test_damus_state().pubkey, profile: make_test_profile(), damus: test_damus_state())
}
}

View File

@@ -21,7 +21,7 @@ struct ProfileNameView: View {
switch Profile.displayName(profile: profile, pubkey: pubkey) {
case .one:
HStack(alignment: .center, spacing: spacing) {
ProfileName(pubkey: pubkey, profile: profile, damus: damus, show_friend_confirmed: true)
ProfileName(pubkey: pubkey, profile: profile, damus: damus)
.font(.title3.weight(.bold))
if follows_you {
FollowsYou()
@@ -32,7 +32,7 @@ struct ProfileNameView: View {
.font(.title3.weight(.bold))
HStack(alignment: .center, spacing: spacing) {
ProfileName(pubkey: pubkey, profile: profile, prefix: "@", damus: damus, show_friend_confirmed: true)
ProfileName(pubkey: pubkey, profile: profile, prefix: "@", damus: damus)
.font(.callout)
.foregroundColor(.gray)

View File

@@ -7,11 +7,6 @@
import SwiftUI
enum ProfileTab: Hashable {
case posts
case following
}
enum FollowState {
case follows
case following
@@ -36,19 +31,6 @@ func follow_btn_txt(_ fs: FollowState, follows_you: Bool) -> String {
}
}
func follow_btn_enabled_state(_ fs: FollowState) -> Bool {
switch fs {
case .follows:
return true
case .following:
return false
case .unfollowing:
return false
case .unfollows:
return true
}
}
func followersCountString(_ count: Int, locale: Locale = Locale.current) -> String {
let format = localizedStringFormat(key: "followers_count", locale: locale)
return String(format: format, locale: locale, count)
@@ -114,8 +96,6 @@ struct ProfileView: View {
static let markdown = Markdown()
@State private var selected_tab: ProfileTab = .posts
@State private var showingEditProfile = false
@State var showing_select_wallet: Bool = false
@State var is_zoomed: Bool = false
@State var show_share_sheet: Bool = false
@@ -141,7 +121,6 @@ struct ProfileView: View {
@Environment(\.dismiss) var dismiss
@Environment(\.colorScheme) var colorScheme
@Environment(\.openURL) var openURL
@Environment(\.presentationMode) var presentationMode
func imageBorderColor() -> Color {
@@ -419,7 +398,7 @@ struct ProfileView: View {
}
.buttonStyle(PlainButtonStyle())
} else {
NavigationLink(destination: UserRelaysView(state: damus_state, pubkey: profile.pubkey, relays: Array(relays.keys).sorted())) {
NavigationLink(destination: UserRelaysView(state: damus_state, relays: Array(relays.keys).sorted())) {
relay_text
}
.buttonStyle(PlainButtonStyle())
@@ -450,10 +429,10 @@ struct ProfileView: View {
.background(colorScheme == .dark ? Color.black : Color.white)
if filter_state == FilterState.posts {
InnerTimelineView(events: profile.events, damus: damus_state, show_friend_icon: false, filter: FilterState.posts.filter)
InnerTimelineView(events: profile.events, damus: damus_state, filter: FilterState.posts.filter)
}
if filter_state == FilterState.posts_and_replies {
InnerTimelineView(events: profile.events, damus: damus_state, show_friend_icon: false, filter: FilterState.posts_and_replies.filter)
InnerTimelineView(events: profile.events, damus: damus_state, filter: FilterState.posts_and_replies.filter)
}
}
.padding(.horizontal, Theme.safeAreaInsets?.left)