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

Preserve tableView selection when app entering background #1594

Merged
merged 6 commits into from
May 16, 2024

Conversation

charliescheer
Copy link
Contributor

@charliescheer charliescheer commented May 15, 2024

Fix

Currently if you have notes selected in the notes table view and you put Simplenote into the background, the selection is lost. Not an ideal situation, I would expect that you could background and then return to Simplenote and the state of the app should be the same, so the selection would be preserved. So in this PR I have fixed that.

Test

  1. Open up the note list, long press on a note and choose Select.
  2. Pick a few notes
  3. put the app in the background
  4. Go back into Simplenote
  • confirm that your notes are still selected

Review

(Required) Add instructions for reviewers. For example:

Only one developer is required to review these changes, but anyone can perform the review.

Release

(Required) Add a concise statement to RELEASE-NOTES.txt if the changes should be included in release notes. Include details about updating the notes in this section. For example:

RELEASE-NOTES.txt was updated in ea5992 with:

Fixed issue where notes selection was lost when app backgrounded

@charliescheer charliescheer added the [feature] note list Anything related to the note list. label May 15, 2024
@charliescheer charliescheer added this to the 4.52 milestone May 15, 2024
@charliescheer charliescheer self-assigned this May 15, 2024
Copy link
Contributor

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

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

Hey there @charliescheer !! Changes look good, buuut sending you a couple annoying comments 😆

LMK what you think!!

@@ -41,6 +41,7 @@
@interface SPAppDelegate ()

@property (weak, nonatomic) SPModalActivityIndicator *signOutActivityIndicator;
@property (nonatomic) NSArray *selectedNotesEnteringBackground;
Copy link
Contributor

Choose a reason for hiding this comment

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

@charliescheer do you think we could encapsulate this in the NoteList itself?

(So that the AppDelegate doesn't keep track of IndexPath(s))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooff that would have been so much easier if the whole thing was in swift. Yes I have made that change. 👍

@@ -189,12 +190,19 @@ - (void)applicationDidEnterBackground:(UIApplication *)application
[self cleanupScrollPositionCache];
[self syncWidgetDefaults];
[self resetWidgetTimelines];

self.selectedNotesEnteringBackground = self.noteListViewController.tableView.indexPathsForSelectedRows;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same note here, perhaps we could move this into the Note List itself?

(The appDelegate could relay the event, or the Note List could listen to the didEnterBackground notification)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -520,8 +529,6 @@ - (void)update
[self refreshTitle];
[self refreshSearchBar];

BOOL isTrashOnScreen = self.isDeletedFilterActive;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a warning in the project that I probably caused recently, but I was tired of it staring at me. So tossing that in here to shut it up.

@@ -29,7 +29,7 @@ extension URL {
}

static func newNoteWidgetURL() -> URL {
guard var components = URLComponents.simplenoteURLComponents(with: Constants.newNotePath) else {
guard let components = URLComponents.simplenoteURLComponents(with: Constants.newNotePath) else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

another warning that was poking me in the brain.

Copy link
Contributor

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

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

✅ Verified that the selected notes aren't getting lost

:shipit:

@@ -192,6 +194,9 @@ - (void)startListeningToNotifications {

// Themes
[nc addObserver:self selector:@selector(themeDidChange) name:SPSimplenoteThemeChangedNotification object:nil];

// App Background
[nc addObserver:self selector:@selector(appWillEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: UIApplicationWillEnterForegroundNotification and you can remove the AppDelegate from the equation!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, good call. Done

@charliescheer charliescheer merged commit 855cea4 into trunk May 16, 2024
2 of 3 checks passed
@charliescheer charliescheer deleted the charlie/1306/table-selection-lost-on-background branch May 16, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[feature] note list Anything related to the note list.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants