Skip to content

Commit

Permalink
Merge pull request #669 from matrix-org/edits_start_reaction_end
Browse files Browse the repository at this point in the history
Edits start -  reaction end
  • Loading branch information
manuroe committed May 24, 2019
2 parents 49b7cf4 + 68891f9 commit 1bd1e1f
Show file tree
Hide file tree
Showing 16 changed files with 1,440 additions and 573 deletions.
30 changes: 25 additions & 5 deletions MatrixSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
322A51D81D9E846800C8536D /* MXCryptoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 322A51D71D9E846800C8536D /* MXCryptoTests.m */; };
322D01C422492B0700150C68 /* MXCryptoShareTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 322D01C322492B0700150C68 /* MXCryptoShareTests.m */; };
32322A481E57264E005DD155 /* MXSelfSignedHomeserverTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32322A471E57264E005DD155 /* MXSelfSignedHomeserverTests.m */; };
32322A4B1E575F65005DD155 /* MXAllowedCertificates.h in Headers */ = {isa = PBXBuildFile; fileRef = 32322A491E575F65005DD155 /* MXAllowedCertificates.h */; };
32322A4B1E575F65005DD155 /* MXAllowedCertificates.h in Headers */ = {isa = PBXBuildFile; fileRef = 32322A491E575F65005DD155 /* MXAllowedCertificates.h */; settings = {ATTRIBUTES = (Public, ); }; };
32322A4C1E575F65005DD155 /* MXAllowedCertificates.m in Sources */ = {isa = PBXBuildFile; fileRef = 32322A4A1E575F65005DD155 /* MXAllowedCertificates.m */; };
3233606F1A403A0D0071A488 /* MXFileStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 3233606D1A403A0D0071A488 /* MXFileStore.h */; settings = {ATTRIBUTES = (Public, ); }; };
323360701A403A0D0071A488 /* MXFileStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 3233606E1A403A0D0071A488 /* MXFileStore.m */; };
Expand Down Expand Up @@ -176,6 +176,12 @@
3275FD9921A6B53300B9C13D /* MXLoginPolicyData.m in Sources */ = {isa = PBXBuildFile; fileRef = 3275FD9721A6B53300B9C13D /* MXLoginPolicyData.m */; };
3275FD9C21A6B60B00B9C13D /* MXLoginPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 3275FD9A21A6B60B00B9C13D /* MXLoginPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; };
3275FD9D21A6B60B00B9C13D /* MXLoginPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3275FD9B21A6B60B00B9C13D /* MXLoginPolicy.m */; };
32792BD42295A86600F4FC9D /* MXAggregatedReactionsUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 32792BD22295A86600F4FC9D /* MXAggregatedReactionsUpdater.h */; };
32792BD52295A86600F4FC9D /* MXAggregatedReactionsUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 32792BD32295A86600F4FC9D /* MXAggregatedReactionsUpdater.m */; };
32792BDC2296B90A00F4FC9D /* MXAggregatedEditsUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 32792BDA2296B90A00F4FC9D /* MXAggregatedEditsUpdater.h */; };
32792BDD2296B90A00F4FC9D /* MXAggregatedEditsUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 32792BDB2296B90A00F4FC9D /* MXAggregatedEditsUpdater.m */; };
32792BDF2296C59B00F4FC9D /* MXAggregatedReactionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32792BDE2296C59B00F4FC9D /* MXAggregatedReactionTests.m */; };
32792BE12296C64200F4FC9D /* MXAggregatedEditsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32792BE02296C64200F4FC9D /* MXAggregatedEditsTests.m */; };
327E37B61A974F75007F026F /* MXLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E37B41A974F75007F026F /* MXLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
327E37B71A974F75007F026F /* MXLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E37B51A974F75007F026F /* MXLogger.m */; };
327E37B91A977810007F026F /* MXLoggerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E37B81A977810007F026F /* MXLoggerTests.m */; };
Expand All @@ -192,7 +198,6 @@
327E9AE22285497100A98BC1 /* MXEventContentRelatesTo.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E9AE02285497100A98BC1 /* MXEventContentRelatesTo.m */; };
327E9AE72285A8C400A98BC1 /* MXAggregationPaginatedResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E9AE52285A8C400A98BC1 /* MXAggregationPaginatedResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
327E9AE82285A8C400A98BC1 /* MXAggregationPaginatedResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E9AE62285A8C400A98BC1 /* MXAggregationPaginatedResponse.m */; };
327E9AEA2285DFB600A98BC1 /* MXReactionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E9AE92285DFB600A98BC1 /* MXReactionTests.m */; };
327E9AEF2289C61100A98BC1 /* MXAggregations.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E9AED2289C61000A98BC1 /* MXAggregations.h */; settings = {ATTRIBUTES = (Public, ); }; };
327E9AF02289C61100A98BC1 /* MXAggregations.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E9AEE2289C61100A98BC1 /* MXAggregations.m */; };
327E9AF62289D53800A98BC1 /* MXReactionCount.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E9AF42289D53800A98BC1 /* MXReactionCount.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -624,6 +629,12 @@
3275FD9721A6B53300B9C13D /* MXLoginPolicyData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXLoginPolicyData.m; sourceTree = "<group>"; };
3275FD9A21A6B60B00B9C13D /* MXLoginPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXLoginPolicy.h; sourceTree = "<group>"; };
3275FD9B21A6B60B00B9C13D /* MXLoginPolicy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXLoginPolicy.m; sourceTree = "<group>"; };
32792BD22295A86600F4FC9D /* MXAggregatedReactionsUpdater.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXAggregatedReactionsUpdater.h; sourceTree = "<group>"; };
32792BD32295A86600F4FC9D /* MXAggregatedReactionsUpdater.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXAggregatedReactionsUpdater.m; sourceTree = "<group>"; };
32792BDA2296B90A00F4FC9D /* MXAggregatedEditsUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXAggregatedEditsUpdater.h; sourceTree = "<group>"; };
32792BDB2296B90A00F4FC9D /* MXAggregatedEditsUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXAggregatedEditsUpdater.m; sourceTree = "<group>"; };
32792BDE2296C59B00F4FC9D /* MXAggregatedReactionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXAggregatedReactionTests.m; sourceTree = "<group>"; };
32792BE02296C64200F4FC9D /* MXAggregatedEditsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXAggregatedEditsTests.m; sourceTree = "<group>"; };
327E37B41A974F75007F026F /* MXLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXLogger.h; sourceTree = "<group>"; };
327E37B51A974F75007F026F /* MXLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLogger.m; sourceTree = "<group>"; };
327E37B81A977810007F026F /* MXLoggerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLoggerTests.m; sourceTree = "<group>"; };
Expand All @@ -640,7 +651,6 @@
327E9AE02285497100A98BC1 /* MXEventContentRelatesTo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXEventContentRelatesTo.m; sourceTree = "<group>"; };
327E9AE52285A8C400A98BC1 /* MXAggregationPaginatedResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXAggregationPaginatedResponse.h; sourceTree = "<group>"; };
327E9AE62285A8C400A98BC1 /* MXAggregationPaginatedResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXAggregationPaginatedResponse.m; sourceTree = "<group>"; };
327E9AE92285DFB600A98BC1 /* MXReactionTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXReactionTests.m; sourceTree = "<group>"; };
327E9AED2289C61000A98BC1 /* MXAggregations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXAggregations.h; sourceTree = "<group>"; };
327E9AEE2289C61100A98BC1 /* MXAggregations.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXAggregations.m; sourceTree = "<group>"; };
327E9AF12289C6B300A98BC1 /* MXAggregations_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXAggregations_Private.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1341,6 +1351,10 @@
327E9AED2289C61000A98BC1 /* MXAggregations.h */,
327E9AEE2289C61100A98BC1 /* MXAggregations.m */,
327E9AF12289C6B300A98BC1 /* MXAggregations_Private.h */,
32792BDA2296B90A00F4FC9D /* MXAggregatedEditsUpdater.h */,
32792BDB2296B90A00F4FC9D /* MXAggregatedEditsUpdater.m */,
32792BD22295A86600F4FC9D /* MXAggregatedReactionsUpdater.h */,
32792BD32295A86600F4FC9D /* MXAggregatedReactionsUpdater.m */,
);
path = Aggregations;
sourceTree = "<group>";
Expand Down Expand Up @@ -1591,7 +1605,8 @@
32C6F93919DD814400EA4E9C /* MatrixSDKTests */ = {
isa = PBXGroup;
children = (
327E9AE92285DFB600A98BC1 /* MXReactionTests.m */,
32792BE02296C64200F4FC9D /* MXAggregatedEditsTests.m */,
32792BDE2296C59B00F4FC9D /* MXAggregatedReactionTests.m */,
327E9ACE2284783E00A98BC1 /* MXEventAnnotationTests.swift */,
329E808E22512DF500A48C3A /* MXCryptoDeviceVerificationTests.m */,
322D01C322492B0700150C68 /* MXCryptoShareTests.m */,
Expand Down Expand Up @@ -1894,6 +1909,7 @@
329D3E621E251027002E2F1E /* MXRoomSummaryUpdater.h in Headers */,
321B413F1E09937E009EEEC7 /* MXRoomSummary.h in Headers */,
B17982F52119E4A2001FD722 /* MXRoomCreateContent.h in Headers */,
32792BDC2296B90A00F4FC9D /* MXAggregatedEditsUpdater.h in Headers */,
327E9AEF2289C61100A98BC1 /* MXAggregations.h in Headers */,
32DC15CF1A8CF7AE006F9AD3 /* MXPushRuleConditionChecker.h in Headers */,
32954019216385F100E300FC /* MXServerNoticeContent.h in Headers */,
Expand Down Expand Up @@ -1973,6 +1989,7 @@
32A9E8251EF4026E0081358A /* MXUIKitBackgroundModeHandler.h in Headers */,
325D1C261DFECE0D0070B8BF /* MXCrypto_Private.h in Headers */,
32E402B921C957D2004E87A6 /* MXOlmSession.h in Headers */,
32792BD42295A86600F4FC9D /* MXAggregatedReactionsUpdater.h in Headers */,
B146D4D621A5A44E00D8C2C6 /* MXScanRealmInMemoryProvider.h in Headers */,
B17285792100C8EA0052C51E /* MXSendReplyEventStringsLocalizable.h in Headers */,
32A151521DAF8A7200400192 /* MXQueuedEncryption.h in Headers */,
Expand Down Expand Up @@ -2235,6 +2252,7 @@
32B94E06228EE90300716A26 /* MXRealmReactionRelation.m in Sources */,
320BBF411D6C81550079890E /* MXEventsByTypesEnumeratorOnArray.m in Sources */,
3213301E228B190F0070BA9B /* MXRealmAggregationsMapper.m in Sources */,
32792BDD2296B90A00F4FC9D /* MXAggregatedEditsUpdater.m in Sources */,
3259CD541DF860C300186944 /* MXRealmCryptoStore.m in Sources */,
321B41401E09937E009EEEC7 /* MXRoomSummary.m in Sources */,
32CAB1081A91EA34008C5BB9 /* MXPushRuleRoomMemberCountConditionChecker.m in Sources */,
Expand Down Expand Up @@ -2321,6 +2339,7 @@
32A151471DAF7C0C00400192 /* MXDeviceInfo.m in Sources */,
321CFDEB22525DEE004D31DF /* MXIncomingSASTransaction.m in Sources */,
32A1515C1DB525DA00400192 /* NSObject+sortedKeys.m in Sources */,
32792BD52295A86600F4FC9D /* MXAggregatedReactionsUpdater.m in Sources */,
32618E7C20EFA45B00E1D2EA /* MXRoomMembers.m in Sources */,
02CAD43A217DD12F0074700B /* MXContentScanEncryptedBody.m in Sources */,
F03EF5091DF071D5009DF592 /* MXEncryptedAttachments.m in Sources */,
Expand Down Expand Up @@ -2434,15 +2453,16 @@
327137241A24BDDE00DB6757 /* MXUserTests.m in Sources */,
32720DA2222EB5650086FFF5 /* MXAutoDiscoveryTests.m in Sources */,
327E37B91A977810007F026F /* MXLoggerTests.m in Sources */,
32792BE12296C64200F4FC9D /* MXAggregatedEditsTests.m in Sources */,
329571931B0240CE00ABB3BA /* MXVoIPTests.m in Sources */,
327E9AEA2285DFB600A98BC1 /* MXReactionTests.m in Sources */,
32A27D1F19EC335300BAFADE /* MXRoomTests.m in Sources */,
32D8CAC219DEE6ED002AF8A0 /* MXRestClientNoAuthAPITests.m in Sources */,
32FCAB4D19E578860049C555 /* MXRestClientTests.m in Sources */,
32C03CB62123076F00D92712 /* DirectRoomTests.m in Sources */,
329FB17C1A0A963700A5E88E /* MXRoomMemberTests.m in Sources */,
3246BDC51A1A0789000A7D62 /* MXRoomStateDynamicTests.m in Sources */,
3264DB941CECA72900B99881 /* MXAccountDataTests.m in Sources */,
32792BDF2296C59B00F4FC9D /* MXAggregatedReactionTests.m in Sources */,
322D01C422492B0700150C68 /* MXCryptoShareTests.m in Sources */,
323EF7471C7CB4C7000DC98C /* MXEventTimelineTests.m in Sources */,
32E226A91D081CE200E6CA54 /* MXPeekingRoomTests.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ - (void)setReactionCounts:(nonnull NSArray<MXReactionCount *> *)reactionCounts o
RLMRealm *realm = self.realm;

[realm transactionWithBlock:^{
// Flush previous data
RLMResults<MXRealmReactionCount *> *realmReactionCounts = [MXRealmReactionCount objectsInRealm:self.realm
where:@"eventId = %@", eventId];
[realm deleteObjects:realmReactionCounts];

// Set new one
for (MXReactionCount *reactionCount in reactionCounts)
{
MXRealmReactionCount *realmReactionCount = [self.mapper realmReactionCountFromReactionCount:reactionCount
Expand Down
47 changes: 47 additions & 0 deletions MatrixSDK/Aggregations/MXAggregatedEditsUpdater.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2019 The Matrix.org Foundation C.I.C
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import <Foundation/Foundation.h>

#import "MXStore.h"
#import "MXAggregationsStore.h"

NS_ASSUME_NONNULL_BEGIN

@interface MXAggregatedEditsUpdater : NSObject

- (instancetype)initWithMyUser:(NSString*)userId
aggregationStore:(id<MXAggregationsStore>)store
matrixStore:(id<MXStore>)matrixStore;

#pragma mark - Data access
//- (nullable MXAggregatedReactions *)aggregatedReactionsOnEvent:(NSString*)eventId inRoom:(NSString*)roomId;
//- (nullable MXReactionCount*)reactionCountForReaction:(NSString*)reaction onEvent:(NSString*)eventId;

#pragma mark - Data update listener
//- (id)listenToEditsUpdateInRoom:(NSString *)roomId block:(void (^)(NSDictionary<NSString *,MXReactionCountChange *> * _Nonnull))block;
//- (void)removeListener:(id)listener;

#pragma mark - Data update
//- (void)handleOriginalAggregatedDataOfEvent:(MXEvent *)event replaces:(MXEventReplaceChunk*)replaces;
- (void)handleReplace:(MXEvent *)event direction:(MXTimelineDirection)direction;
- (void)handleRedaction:(MXEvent *)event;

- (void)resetDataInRoom:(NSString *)roomId;

@end

NS_ASSUME_NONNULL_END
78 changes: 78 additions & 0 deletions MatrixSDK/Aggregations/MXAggregatedEditsUpdater.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Copyright 2019 The Matrix.org Foundation C.I.C
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import "MXAggregatedEditsUpdater.h"

@interface MXAggregatedEditsUpdater ()

@property (nonatomic) NSString *myUserId;
@property (nonatomic, weak) id<MXStore> matrixStore;
@property (nonatomic, weak) id<MXAggregationsStore> store;
//@property (nonatomic) NSMutableArray<MXReactionCountChangeListener*> *listeners;

@end

@implementation MXAggregatedEditsUpdater

- (instancetype)initWithMyUser:(NSString*)userId
aggregationStore:(id<MXAggregationsStore>)store
matrixStore:(id<MXStore>)matrixStore
{
self = [super init];
if (self)
{
self.myUserId = userId;
self.store = store;
self.matrixStore = matrixStore;

//self.listeners = [NSMutableArray array];
}
return self;
}


#pragma mark - Data access

//- (nullable MXAggregatedReactions *)aggregatedReactionsOnEvent:(NSString*)eventId inRoom:(NSString*)roomId;
//- (nullable MXReactionCount*)reactionCountForReaction:(NSString*)reaction onEvent:(NSString*)eventId;


#pragma mark - Data update listener

//- (id)listenToEditsUpdateInRoom:(NSString *)roomId block:(void (^)(NSDictionary<NSString *,MXReactionCountChange *> * _Nonnull))block;
//- (void)removeListener:(id)listener;


#pragma mark - Data update

//- (void)handleOriginalAggregatedDataOfEvent:(MXEvent *)event replaces:(MXEventReplaceChunk*)replaces;

- (void)handleReplace:(MXEvent *)event direction:(MXTimelineDirection)direction
{

}

- (void)handleRedaction:(MXEvent *)event
{

}

- (void)resetDataInRoom:(NSString *)roomId
{

}

@end
51 changes: 51 additions & 0 deletions MatrixSDK/Aggregations/MXAggregatedReactionsUpdater.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright 2019 The Matrix.org Foundation C.I.C
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import <Foundation/Foundation.h>

#import "MXAggregatedReactions.h"
#import "MXEventAnnotationChunk.h"

#import "MXStore.h"
#import "MXAggregationsStore.h"
#import "MXReactionCountChangeListener.h"

NS_ASSUME_NONNULL_BEGIN

@interface MXAggregatedReactionsUpdater : NSObject

- (instancetype)initWithMyUser:(NSString*)userId
aggregationStore:(id<MXAggregationsStore>)store
matrixStore:(id<MXStore>)matrixStore;

#pragma mark - Data access
- (nullable MXAggregatedReactions *)aggregatedReactionsOnEvent:(NSString*)eventId inRoom:(NSString*)roomId;
- (nullable MXReactionCount*)reactionCountForReaction:(NSString*)reaction onEvent:(NSString*)eventId;

#pragma mark - Data update listener
- (id)listenToReactionCountUpdateInRoom:(NSString *)roomId block:(void (^)(NSDictionary<NSString *,MXReactionCountChange *> * _Nonnull))block;
- (void)removeListener:(id)listener;

#pragma mark - Data update
- (void)handleOriginalAggregatedDataOfEvent:(MXEvent *)event annotations:(MXEventAnnotationChunk*)annotations;
- (void)handleReaction:(MXEvent *)event direction:(MXTimelineDirection)direction;
- (void)handleRedaction:(MXEvent *)event;

- (void)resetDataInRoom:(NSString *)roomId;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 1bd1e1f

Please sign in to comment.