WFCUMessageModel.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // MessageModel.m
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/9/1.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUMessageModel.h"
  9. @implementation WFCUMessageModel
  10. + (instancetype)modelOf:(WFCCMessage *)message showName:(BOOL)showName showTime:(BOOL)showTime {
  11. WFCUMessageModel *model = [[WFCUMessageModel alloc] init];
  12. model.message = message;
  13. model.showNameLabel = showName;
  14. model.showTimeLabel = showTime;
  15. [model loadQuotedMessage];
  16. return model;
  17. }
  18. - (void)loadQuotedMessage {
  19. if([self.message.content isKindOfClass:[WFCCTextMessageContent class]]) {
  20. WFCCTextMessageContent *txtCont = (WFCCTextMessageContent *)self.message.content;
  21. if(txtCont.quoteInfo) {
  22. self.quotedMessage = [[WFCCIMService sharedWFCIMService] getMessageByUid:txtCont.quoteInfo.messageUid];
  23. if(!self.quotedMessage) {
  24. [[WFCCIMService sharedWFCIMService] getRemoteMessage:txtCont.quoteInfo.messageUid success:^(WFCCMessage *message) {
  25. self.quotedMessage = message;
  26. [[NSNotificationCenter defaultCenter] postNotificationName:kMessageUpdated object:@(self.message.messageId)];
  27. } error:^(int error_code) {
  28. }];
  29. }
  30. }
  31. }
  32. }
  33. - (instancetype)init {
  34. self = [super init];
  35. if (self) {
  36. self.deliveryRate = -1;
  37. self.readRate = -1;
  38. }
  39. return self;
  40. }
  41. @end