mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Merge pull request #7067 from vector-im/gil/7066-unread_thread_notifications_shouldn_t_be_sent_if_the_homeserver_doesn_t_support_notifications_per_threads
Threads: removed "unread_thread_notifications" from sync filters
This commit is contained in:
commit
17536ccca8
3 changed files with 49 additions and 35 deletions
|
@ -359,11 +359,6 @@ typedef BOOL (^MXKAccountOnCertificateChange)(MXKAccount *mxAccount, NSData *cer
|
|||
- (void)resetDeviceId;
|
||||
|
||||
#pragma mark - Sync filter
|
||||
/**
|
||||
Check if the homeserver supports room members lazy loading.
|
||||
@param completion the check result.
|
||||
*/
|
||||
- (void)supportLazyLoadOfRoomMembers:(void (^)(BOOL supportLazyLoadOfRoomMembers))completion;
|
||||
|
||||
/**
|
||||
Call this method at an appropriate time to attempt dehydrating to a new backup device
|
||||
|
|
|
@ -2088,14 +2088,15 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
|||
|
||||
#pragma mark - Sync filter
|
||||
|
||||
- (void)supportLazyLoadOfRoomMembers:(void (^)(BOOL supportLazyLoadOfRoomMembers))completion
|
||||
- (void)supportLazyLoadOfRoomMembersWithMatrixVersion:(MXMatrixVersions *)matrixVersions
|
||||
completion:(void (^)(BOOL supportLazyLoadOfRoomMembers))completion
|
||||
{
|
||||
void(^onUnsupportedLazyLoadOfRoomMembers)(NSError *) = ^(NSError *error) {
|
||||
completion(NO);
|
||||
};
|
||||
|
||||
// Check if the server supports LL sync filter
|
||||
MXFilterJSONModel *filter = [self syncFilterWithLazyLoadOfRoomMembers:YES];
|
||||
MXFilterJSONModel *filter = [self syncFilterWithLazyLoadOfRoomMembers:YES supportsNotificationsForThreads:NO];
|
||||
[mxSession.store filterIdForFilter:filter success:^(NSString * _Nullable filterId) {
|
||||
|
||||
if (filterId)
|
||||
|
@ -2106,8 +2107,8 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
|||
else
|
||||
{
|
||||
// Check the Matrix versions supported by the HS
|
||||
[self.mxSession supportedMatrixVersions:^(MXMatrixVersions *matrixVersions) {
|
||||
|
||||
if (matrixVersions)
|
||||
{
|
||||
if (matrixVersions.supportLazyLoadMembers)
|
||||
{
|
||||
// The HS supports LL
|
||||
|
@ -2117,8 +2118,11 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
|||
{
|
||||
onUnsupportedLazyLoadOfRoomMembers(nil);
|
||||
}
|
||||
|
||||
} failure:onUnsupportedLazyLoadOfRoomMembers];
|
||||
}
|
||||
else
|
||||
{
|
||||
completion(NO);
|
||||
}
|
||||
}
|
||||
} failure:onUnsupportedLazyLoadOfRoomMembers];
|
||||
}
|
||||
|
@ -2133,28 +2137,42 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
|||
// Check settings
|
||||
BOOL syncWithLazyLoadOfRoomMembersSetting = [MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers;
|
||||
|
||||
if (syncWithLazyLoadOfRoomMembersSetting)
|
||||
{
|
||||
// Check if the server supports LL sync filter before enabling it
|
||||
[self supportLazyLoadOfRoomMembers:^(BOOL supportLazyLoadOfRoomMembers) {
|
||||
void(^buildSyncFilter)(MXMatrixVersions *) = ^(MXMatrixVersions *matrixVersions) {
|
||||
BOOL supportsNotificationsForThreads = matrixVersions ? matrixVersions.supportsNotificationsForThreads : NO;
|
||||
|
||||
if (syncWithLazyLoadOfRoomMembersSetting)
|
||||
{
|
||||
// Check if the server supports LL sync filter before enabling it
|
||||
[self supportLazyLoadOfRoomMembersWithMatrixVersion:matrixVersions completion:^(BOOL supportLazyLoadOfRoomMembers) {
|
||||
|
||||
|
||||
if (supportLazyLoadOfRoomMembers)
|
||||
{
|
||||
completion([self syncFilterWithLazyLoadOfRoomMembers:YES]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No support from the HS
|
||||
// Disable the setting. That will avoid to make a request at every startup
|
||||
[MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers = NO;
|
||||
completion([self syncFilterWithLazyLoadOfRoomMembers:NO]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
completion([self syncFilterWithLazyLoadOfRoomMembers:NO]);
|
||||
}
|
||||
if (supportLazyLoadOfRoomMembers)
|
||||
{
|
||||
completion([self syncFilterWithLazyLoadOfRoomMembers:YES
|
||||
supportsNotificationsForThreads:supportsNotificationsForThreads]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No support from the HS
|
||||
// Disable the setting. That will avoid to make a request at every startup
|
||||
[MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers = NO;
|
||||
completion([self syncFilterWithLazyLoadOfRoomMembers:NO
|
||||
supportsNotificationsForThreads:supportsNotificationsForThreads]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
completion([self syncFilterWithLazyLoadOfRoomMembers:NO supportsNotificationsForThreads:supportsNotificationsForThreads]);
|
||||
}
|
||||
};
|
||||
|
||||
[mxSession supportedMatrixVersions:^(MXMatrixVersions *matrixVersions) {
|
||||
buildSyncFilter(matrixVersions);
|
||||
} failure:^(NSError *error) {
|
||||
MXLogWarning(@"[MXAccount] buildSyncFilter: failed to get supported versions: %@", error);
|
||||
buildSyncFilter(nil);
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2163,7 +2181,7 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
|||
@param syncWithLazyLoadOfRoomMembers enable LL support.
|
||||
@return the sync filter to use.
|
||||
*/
|
||||
- (MXFilterJSONModel *)syncFilterWithLazyLoadOfRoomMembers:(BOOL)syncWithLazyLoadOfRoomMembers
|
||||
- (MXFilterJSONModel *)syncFilterWithLazyLoadOfRoomMembers:(BOOL)syncWithLazyLoadOfRoomMembers supportsNotificationsForThreads:(BOOL)supportsNotificationsForThreads
|
||||
{
|
||||
MXFilterJSONModel *syncFilter;
|
||||
NSUInteger limit = 10;
|
||||
|
@ -2198,11 +2216,11 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
|||
// Set that limit in the filter
|
||||
if (syncWithLazyLoadOfRoomMembers)
|
||||
{
|
||||
syncFilter = [MXFilterJSONModel syncFilterForLazyLoadingWithMessageLimit:limit unreadThreadNotifications:YES];
|
||||
syncFilter = [MXFilterJSONModel syncFilterForLazyLoadingWithMessageLimit:limit unreadThreadNotifications:supportsNotificationsForThreads];
|
||||
}
|
||||
else
|
||||
{
|
||||
syncFilter = [MXFilterJSONModel syncFilterWithMessageLimit:limit unreadThreadNotifications:YES];
|
||||
syncFilter = [MXFilterJSONModel syncFilterWithMessageLimit:limit unreadThreadNotifications:supportsNotificationsForThreads];
|
||||
}
|
||||
|
||||
// TODO: We could extend the filter to match other settings (self.showAllEventsInRoomHistory,
|
||||
|
|
1
changelog.d/7066.bugfix
Normal file
1
changelog.d/7066.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Threads: removed "unread_thread_notifications" from sync filters for server that doesn't support MSC3773
|
Loading…
Reference in a new issue