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

Flescio/7253 add mar kas unread option for rooms #1696

Merged
merged 7 commits into from
Jan 31, 2023

Conversation

flescio
Copy link
Contributor

@flescio flescio commented Jan 25, 2023

@flescio flescio requested review from a team and Anderas and removed request for a team January 25, 2023 16:17
@Anderas
Copy link
Contributor

Anderas commented Jan 30, 2023

As discussed elsewhere I would suggest two improvements:

  • MXMemoryStore should not be instructing MXFileStore when to set (via a method only implemented by MXFileStore). Instead memory store merely mutates a dictionary, and lets file store save at opportune moments in the same way that other data is handled (filters, state ... )
  • the double negative of unmarkAsUnread is somewhat unreadable/confusing, in one place the method even calls related markAsRead. I would suggest instead something like resetUnreadMarkers or clearUnreadMarkers

@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Base: 37.51% // Head: 17.40% // Decreases project coverage by -20.11% ⚠️

Coverage data is based on head (3142e9a) compared to base (496b17e).
Patch coverage: 1.09% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1696       +/-   ##
============================================
- Coverage    37.51%   17.40%   -20.11%     
============================================
  Files          609      610        +1     
  Lines        95165    95430      +265     
  Branches     41297    40200     -1097     
============================================
- Hits         35701    16613    -19088     
- Misses       58423    78310    +19887     
+ Partials      1041      507      -534     
Impacted Files Coverage Δ
MatrixSDK/Background/MXBackgroundStore.swift 0.00% <0.00%> (ø)
MatrixSDK/Data/MXRoom.m 2.28% <0.00%> (-35.70%) ⬇️
MatrixSDK/Data/Store/MXFileStore/MXFileStore.m 17.37% <0.00%> (-0.62%) ⬇️
MatrixSDK/Data/Store/MXNoStore/MXNoStore.m 13.48% <0.00%> (-36.01%) ⬇️
MatrixSDK/MXSession.m 10.74% <0.00%> (-29.27%) ⬇️
MatrixSDKTests/MXRoomTests.m 0.00% <0.00%> (ø)
MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m 21.97% <10.00%> (-33.73%) ⬇️
MatrixSDK/Data/MXRoomSummary.m 16.83% <12.50%> (-38.80%) ⬇️
MatrixSDKTests/MatrixSDKTestsData.h 0.00% <0.00%> (-100.00%) ⬇️
MatrixSDK/Utils/MXDateProvider.swift 0.00% <0.00%> (-100.00%) ⬇️
... and 202 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@Anderas Anderas left a comment

Choose a reason for hiding this comment

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

I left just a few comments regarding style, naming and consistency, but the overal change looks good to me

It will set the entire room as unread.
This is only local since it's not possible to remove from the server the read events.
*/
-(void)setUnread;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to align with the MXStore api, either having set/resetUnread or set/resetUnreadMarker everywhere

- (void)setUnread
{
[mxSession.store setUnreadMarkerForRoom:self.roomId];
[mxSession.store commit];
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably won't be an issue in practice (store is always MXFileStore), but commit is marked as optional on the protocol, so should be surrounded with if ([mxSession.store respondsToSelector:@selector(commit)]) for safety as is done elsewhere in that file

@@ -998,6 +1000,36 @@ - (RoomThreadedReceiptsStore*)getOrCreateRoomThreadedReceiptsStore:(NSString*)ro
return threadedStore;
}

- (void)setUnreadMarkerForRoom:(nonnull NSString*)roomId;
Copy link
Contributor

Choose a reason for hiding this comment

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

If these 2 methods just call super there is no need to override them, and can be safely deleted.

/**
it will return if the room is marked unread by the user
*/
- (BOOL) isRoomMarkedAsUnread:(NSString*)roomId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove space (BOOL) isRoom... => (BOOL)isRoom... for consistency

@@ -879,6 +880,101 @@ - (void)testUpgrade
}];
}

- (void)testMarkUnread
Copy link
Contributor

Choose a reason for hiding this comment

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

Great to include tests for this 👍

@flescio flescio merged commit b1b6be3 into develop Jan 31, 2023
@flescio flescio deleted the flescio/7253-Add_mar_kas_unread_option_for_rooms branch January 31, 2023 11:37
Anderas added a commit that referenced this pull request Feb 2, 2023
…_kas_unread_option_for_rooms"

This reverts commit b1b6be3, reversing
changes made to 9e36625.
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.

2 participants