Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes alerts when uploading big files and suggests users subscribe to nostr.build #1321

Merged
merged 30 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b17ed98
non-functional update of layout for upload alerts
rabble Jul 20, 2024
fde083b
fixed one problem with localization strings, still stuck on calling t…
rabble Jul 23, 2024
4564fbf
fixed one problem with localization strings, still stuck on calling t…
rabble Jul 23, 2024
e66b0b7
added fix to help users with suggestion to pay for nostr.build to upl…
rabble Jul 23, 2024
f477447
Merge branch 'main' into large_file_upload_error
rabble Jul 23, 2024
c9f73fb
fixes error message when file size is too big by adding error to File…
rabble Jul 24, 2024
b74027b
fixes error message when file size is too big by adding error to File…
rabble Jul 24, 2024
877edd5
Update Nos/Assets/Localization/ImagePicker.xcstrings
rabble Jul 25, 2024
6f61dea
Update Nos/Assets/Localization/ImagePicker.xcstrings
rabble Jul 25, 2024
37d18a3
Update Nos/Assets/Localization/ImagePicker.xcstrings
rabble Jul 25, 2024
25cc94b
Update Nos/Assets/Localization/ImagePicker.xcstrings
rabble Jul 25, 2024
dc1dd5b
reverting package.resolved file
rabble Jul 25, 2024
862c384
adding changelog for file upload error screen
rabble Jul 30, 2024
b3f88fd
Update Nos/Views/New Note/ComposerActionBar.swift
rabble Jul 30, 2024
b4c64f1
Update Nos/Views/New Note/ComposerActionBar.swift
rabble Jul 30, 2024
e6cd12e
Merge branch 'main' into large_file_upload_error
mplorentz Jul 31, 2024
c74b82a
Fix swiftlint errors
mplorentz Jul 31, 2024
ac9c72f
Merge branch 'main' into large_file_upload_error
mplorentz Jul 31, 2024
e1eb233
Merge remote-tracking branch 'origin/main' into large_file_upload_error
pelumy Sep 11, 2024
19ede8b
differentiate buttons to show on alert for large files from other errors
pelumy Sep 11, 2024
781ab37
fix minor swiftlint warnings
pelumy Sep 11, 2024
cd298aa
make function body length shorter to fix swiftlint error
pelumy Sep 11, 2024
a3129c1
fix more swiftlint warnings
pelumy Sep 11, 2024
8276f18
Merge branch 'main' into large_file_upload_error
pelumy Sep 11, 2024
a24d659
Merge branch 'main' into large_file_upload_error
pelumy Sep 12, 2024
4be1b8c
check for error code 413
pelumy Sep 12, 2024
0b5eef9
Merge branch 'main' into large_file_upload_error
pelumy Sep 12, 2024
d9d357a
refactored regular expression for file size limit
joshuatbrown Sep 13, 2024
2aeab85
refactor createAlert function
pelumy Sep 13, 2024
d15cdf4
Update premium nostr url string
pelumy Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion Nos/Assets/Localization/ImagePicker.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,39 @@
}
}
},
"getAccount" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Get Account"
}
}
}
},
"errorUploadingFileExceedsSizeLimit" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Get a Nostr.Build account to upload larger files"
rabble marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
},
"errorUploadingFileExceedsLimit" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "The max file size for free media uploads is of %@. To upload large files, upgrade to a Nostr.Build Professional account."
rabble marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
},
rabble marked this conversation as resolved.
Show resolved Hide resolved
"openSettingsMessage" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -424,4 +457,4 @@
}
},
"version" : "1.0"
}
}
45 changes: 34 additions & 11 deletions Nos/Views/New Note/ComposerActionBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
@State private var alert: AlertState<AlertAction>?

fileprivate enum AlertAction {
case cancel
case getAccount
}

var backArrow: some View {
Expand Down Expand Up @@ -53,16 +55,26 @@
endUploadingImage()
print("error uploading: \(error)")

alert = AlertState(title: {
TextState(String(localized: .imagePicker.errorUploadingFile))
}, message: {
if case let FileStorageAPIClientError.uploadFailed(message) = error,
let message {
TextState(String(localized: .imagePicker.errorUploadingFileWithMessage(message)))
} else {
TextState(String(localized: .imagePicker.errorUploadingFileMessage))
}
})
alert = AlertState<ComposerActionBar.AlertAction>(
title: {
if case FileStorageAPIClientError.uploadFailed = error {
return TextState(String(localized: .imagePicker.errorUploadingFileExceedsSizeLimit))

Check failure on line 61 in Nos/Views/New Note/ComposerActionBar.swift

View workflow job for this annotation

GitHub Actions / swift_lint

Line should be 120 characters or less; currently it has 124 characters (line_length)
} else {
return TextState(String(localized: .imagePicker.errorUploadingFile))

Check failure on line 63 in Nos/Views/New Note/ComposerActionBar.swift

View workflow job for this annotation

GitHub Actions / swift_lint

Code should be indented using one tab or 4 spaces (indentation_width)
}
}(),
message: {
if case let FileStorageAPIClientError.uploadFailed(message) = error, let message = message {

Check failure on line 67 in Nos/Views/New Note/ComposerActionBar.swift

View workflow job for this annotation

GitHub Actions / swift_lint

Line should be 120 characters or less; currently it has 128 characters (line_length)
return TextState(String(localized: .imagePicker.errorUploadingFileWithMessage(message)))

Check failure on line 68 in Nos/Views/New Note/ComposerActionBar.swift

View workflow job for this annotation

GitHub Actions / swift_lint

Line should be 120 characters or less; currently it has 128 characters (line_length)
} else {
return TextState(String(localized: .imagePicker.errorUploadingFileMessage))
}
}(),
buttons: [
.cancel(TextState(String(localized: .localizable.cancel)), action: .send(.cancel)),
.default(TextState(String(localized: .imagePicker.getAccount)), action: .send(.getAccount))

Check failure on line 75 in Nos/Views/New Note/ComposerActionBar.swift

View workflow job for this annotation

GitHub Actions / swift_lint

All elements in a collection literal should be vertically aligned (collection_alignment)

Check failure on line 75 in Nos/Views/New Note/ComposerActionBar.swift

View workflow job for this annotation

GitHub Actions / swift_lint

Line should be 120 characters or less; currently it has 131 characters (line_length)
]
)
}
}
} label: {
Expand Down Expand Up @@ -118,7 +130,18 @@
.onChange(of: expirationTime) { _, _ in
subMenu = .none
}
.alert(unwrapping: $alert) { (_: AlertAction?) in
.alert(unwrapping: $alert) { action in
switch action {
case .cancel:
// Handle cancel action if needed
break
case .getAccount:
if let url = URL(string: "https://nostr.build") {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
default:
break
}
}
.background(
LinearGradient(
Expand Down
Loading