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

Conversation

rabble
Copy link
Contributor

@rabble rabble commented Jul 20, 2024

Issues covered

#1275

Description

Provides a better error message and gives the option to pay for nostr.build

How to test

  1. Build the app.
  2. Click the post button on the tab bar.
  3. Click the gallery/file icon at the bottom left of the popup.
  4. Upload a photo / video that is greater than 25mb.
  5. Please check that the error message that shows up is about the exceeded file size, with two buttons, 1 to cancel and the other to purchase a premium nostr account plan. Clicking the "Get Account" button should take you to the pricing plan screen.

Screenshots/Video

Screen.Recording.2024-09-11.at.6.04.56.PM.mov

@mplorentz
Copy link
Member

@rabble unfortunately that error message is usually a lie and is hiding the real error. Try commenting out some of your changes until you narrow down the line that is wrong. If that doesn't help maybe @joshuatbrown or I can take a look on Monday.

@joshuatbrown
Copy link
Contributor

@rabble thanks for working on this! It's a really annoying bug.

@mplorentz
Copy link
Member

Also we've picked up the habit as marking WIP PRs as "drafts" in Github. We'll still review them, but it's just an extra signal that it's not ready for merging yet. You can click the "convert to draft" button up by the reviewers to make this PR a draft.

@rabble rabble marked this pull request as draft July 22, 2024 23:17
@rabble rabble changed the title [WIP] non-functional update of layout for upload alerts Fixes alerts when uploading big files and suggests users subscribe to nostr.build Jul 23, 2024
@rabble rabble marked this pull request as ready for review July 23, 2024 04:49
Copy link
Contributor

@joshuatbrown joshuatbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this looks great! It works exactly as expected, and it's super nice to have this message to tell people what's going on. In addition to my comment, I see a few SwiftLint errors to address, but this looks like it's really close.

Nos/Assets/Localization/ImagePicker.xcstrings Outdated Show resolved Hide resolved
Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Rabble, this is close but there are a few things missing.

  • Right now it will return the size error no matter what error we get back from the nostr.build API. So even if the user is offline or something it will tell them they hit the size limit. I think we'll want to make a new case in the FileStorageAPIClientError type that is like fileTooBig, and then when we get an error from nostr.build we should check to see if the error message is about the file size. We could check for the text "File size exceeds the limit" in the message. Search for the line throw FileStorageAPIClientError.uploadFailed(response.message) and replace it with something like if itLooksLIkeASizeError { throw fileTooBigError } else { throw uploadFailed }.
  • There are some linting errors. You can see this locally if you brew install swiftlint
  • Can you add a line to the top of the changelog?

Nos/Assets/Localization/ImagePicker.xcstrings Outdated Show resolved Hide resolved
Nos/Assets/Localization/ImagePicker.xcstrings Outdated Show resolved Hide resolved
@mplorentz
Copy link
Member

There is also a bug I see that XCStringsTool isn't generating accessors for Nos/Assets/Localization/ImagePicker.xcstrings. I don't see a way to fix that in the docs. There isn't a configuration file that I see. @joshuatbrown do you know how to fix this off the top of your head? I know you tried removing XCStringsTool recently.

…StorageAPIClient and also some of the lint issues
…StorageAPIClient and also some of the lint issues
@rabble
Copy link
Contributor Author

rabble commented Jul 24, 2024

There is also a bug I see that XCStringsTool isn't generating accessors for Nos/Assets/Localization/ImagePicker.xcstrings. I don't see a way to fix that in the docs. There isn't a configuration file that I see. @joshuatbrown do you know how to fix this off the top of your head? I know you tried removing XCStringsTool recently.

Ah, i wasn't aware xcode had a way of editing those files visually... i was editing the json.. i've now tried opening the file from teh CLI and it shows an editor.... i added spanish too. Should be fixed..

I think it's ready for you guys to look at again.

@rabble rabble requested a review from mplorentz July 24, 2024 07:28
Nos/Assets/Localization/ImagePicker.xcstrings Outdated Show resolved Hide resolved
Nos/Assets/Localization/ImagePicker.xcstrings Outdated Show resolved Hide resolved
Nos/Assets/Localization/ImagePicker.xcstrings Outdated Show resolved Hide resolved
Nos/Assets/Localization/ImagePicker.xcstrings Outdated Show resolved Hide resolved
Nos/Views/New Note/ComposerActionBar.swift Outdated Show resolved Hide resolved
Nos/Views/New Note/ComposerActionBar.swift Outdated Show resolved Hide resolved
Nos/Service/FileStorage/FileStorageAPIClient.swift Outdated Show resolved Hide resolved
rabble and others added 8 commits July 25, 2024 12:20
Co-authored-by: Josh Brown <josh@nos.social>
spelling fix

Co-authored-by: Josh Brown <josh@nos.social>
grammar fix

Co-authored-by: Josh Brown <josh@nos.social>
embed format fix

Co-authored-by: Josh Brown <josh@nos.social>
Co-authored-by: Josh Brown <josh@nos.social>
Co-authored-by: Josh Brown <josh@nos.social>
Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Rabble, I checked this out and fixed the linter errors for you. However I'm seeing one more bug. If I turn my internet off and try to upload a photo the resulting error message looks correct now the but the "Get Account" button is shown instead of "Ok".

Screenshot 2024-07-31 at 10 41 10 AM

One more request: can the "Get Account" button open https://nostr.build/plans instead of https://nostr.build?

@joshuatbrown joshuatbrown self-assigned this Sep 12, 2024
Copy link
Contributor

@joshuatbrown joshuatbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works perfectly and I'm glad we're looking for the HTTP 413! I just have some comments on how it's implemented, and I'd love to see a unit test or two. I have some ideas for how to do that, so I'm happy to help if needed.

Nos/Views/NoteComposer/ComposerActionBar.swift Outdated Show resolved Hide resolved
Nos/Service/FileStorage/FileStorageAPIClient.swift Outdated Show resolved Hide resolved
@pelumy
Copy link
Contributor

pelumy commented Sep 13, 2024

This works perfectly and I'm glad we're looking for the HTTP 413! I just have some comments on how it's implemented, and I'd love to see a unit test or two. I have some ideas for how to do that, so I'm happy to help if needed.

@joshuatbrown, this is something I have been looking forward to do. I would be happy to have a guide on the unit testing.

Copy link
Contributor

@joshuatbrown joshuatbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works perfectly, and I love the updates! Everything looks great, though I'd love to see one very small tweak. Thanks!

Nos/Views/NoteComposer/ComposerActionBar.swift Outdated Show resolved Hide resolved
Co-authored-by: Josh Brown <josh@nos.social>
Copy link
Contributor

@joshuatbrown joshuatbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! This is perfect!

@pelumy
Copy link
Contributor

pelumy commented Sep 16, 2024

Thanks for the update! This is perfect!

Thank you @joshuatbrown

Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I blocked the merge on this. Nice work!

@pelumy pelumy added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit 2b3a70d Sep 17, 2024
4 checks passed
@pelumy pelumy deleted the large_file_upload_error branch September 17, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants