Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #363 from OkunaOrg/feature/138-mentions
Browse files Browse the repository at this point in the history
Feature/138 mentions
  • Loading branch information
lifenautjoe authored Aug 12, 2019
2 parents af94589 + 5648165 commit 5177ae9
Show file tree
Hide file tree
Showing 24 changed files with 1,645 additions and 492 deletions.
19 changes: 18 additions & 1 deletion lib/models/notifications/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import 'package:Okuna/models/notifications/follow_notification.dart';
import 'package:Okuna/models/notifications/post_comment_notification.dart';
import 'package:Okuna/models/notifications/post_comment_reaction_notification.dart';
import 'package:Okuna/models/notifications/post_comment_reply_notification.dart';
import 'package:Okuna/models/notifications/post_comment_user_mention_notification.dart';
import 'package:Okuna/models/notifications/post_reaction_notification.dart';
import 'package:Okuna/models/notifications/post_user_mention_notification.dart';
import 'package:Okuna/models/updatable_model.dart';
import 'package:Okuna/models/user.dart';
import 'package:dcache/dcache.dart';
Expand Down Expand Up @@ -38,6 +40,8 @@ class OBNotification extends UpdatableModel<OBNotification> {
static final connectionConfirmed = 'CC';
static final follow = 'F';
static final communityInvite = 'CI';
static final postCommentUserMention = 'PCUM';
static final postUserMention = 'PUM';

factory OBNotification.fromJSON(Map<String, dynamic> json) {
return factory.fromJson(json);
Expand Down Expand Up @@ -113,6 +117,10 @@ class NotificationFactory extends UpdatableModelFactory<OBNotification> {
notificationType = NotificationType.postCommentReply;
} else if (notificationTypeStr == OBNotification.postCommentReaction) {
notificationType = NotificationType.postCommentReaction;
} else if (notificationTypeStr == OBNotification.postCommentUserMention) {
notificationType = NotificationType.postCommentUserMention;
} else if (notificationTypeStr == OBNotification.postUserMention) {
notificationType = NotificationType.postUserMention;
} else if (notificationTypeStr == OBNotification.connectionRequest) {
notificationType = NotificationType.connectionRequest;
} else if (notificationTypeStr == OBNotification.connectionConfirmed) {
Expand Down Expand Up @@ -160,6 +168,13 @@ class NotificationFactory extends UpdatableModelFactory<OBNotification> {
contentObject =
PostCommentReactionNotification.fromJson(contentObjectData);
break;
case NotificationType.postCommentUserMention:
contentObject =
PostCommentUserMentionNotification.fromJson(contentObjectData);
break;
case NotificationType.postUserMention:
contentObject = PostUserMentionNotification.fromJson(contentObjectData);
break;
case NotificationType.communityInvite:
contentObject = CommunityInviteNotification.fromJson(contentObjectData);
break;
Expand All @@ -181,5 +196,7 @@ enum NotificationType {
connectionRequest,
connectionConfirmed,
follow,
communityInvite
communityInvite,
postCommentUserMention,
postUserMention,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:Okuna/models/post_comment_user_mention.dart';

class PostCommentUserMentionNotification {
final int id;
final PostCommentUserMention postCommentUserMention;

PostCommentUserMentionNotification({this.id, this.postCommentUserMention});

factory PostCommentUserMentionNotification.fromJson(
Map<String, dynamic> json) {
return PostCommentUserMentionNotification(
id: json['id'],
postCommentUserMention:
_parsePostCommentUserMention(json['post_comment_user_mention']));
}

static PostCommentUserMention _parsePostCommentUserMention(
Map postCommentUserMentionData) {
return PostCommentUserMention.fromJSON(postCommentUserMentionData);
}
}
18 changes: 18 additions & 0 deletions lib/models/notifications/post_user_mention_notification.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:Okuna/models/post_user_mention.dart';

class PostUserMentionNotification {
final int id;
final PostUserMention postUserMention;

PostUserMentionNotification({this.id, this.postUserMention});

factory PostUserMentionNotification.fromJson(Map<String, dynamic> json) {
return PostUserMentionNotification(
id: json['id'],
postUserMention: _parsePostUserMention(json['post_user_mention']));
}

static PostUserMention _parsePostUserMention(Map postUserMentionData) {
return PostUserMention.fromJSON(postUserMentionData);
}
}
32 changes: 32 additions & 0 deletions lib/models/post_comment_user_mention.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:Okuna/models/post_comment.dart';
import 'package:Okuna/models/user.dart';

class PostCommentUserMention {
final int id;
final User user;
final PostComment postComment;

PostCommentUserMention({
this.id,
this.user,
this.postComment,
});

factory PostCommentUserMention.fromJSON(Map<String, dynamic> parsedJson) {
return PostCommentUserMention(
id: parsedJson['id'],
user: parseUser(parsedJson['user']),
postComment: parsePostComment(parsedJson['post_comment']),
);
}

static User parseUser(Map userData) {
if (userData == null) return null;
return User.fromJson(userData);
}

static PostComment parsePostComment(Map postCommentData) {
if (postCommentData == null) return null;
return PostComment.fromJSON(postCommentData);
}
}
32 changes: 32 additions & 0 deletions lib/models/post_user_mention.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:Okuna/models/post.dart';
import 'package:Okuna/models/user.dart';

class PostUserMention {
final int id;
final User user;
final Post post;

PostUserMention({
this.id,
this.user,
this.post,
});

factory PostUserMention.fromJSON(Map<String, dynamic> parsedJson) {
return PostUserMention(
id: parsedJson['id'],
user: parseUser(parsedJson['user']),
post: parsePost(parsedJson['post']),
);
}

static User parseUser(Map userData) {
if (userData == null) return null;
return User.fromJson(userData);
}

static Post parsePost(Map postData) {
if (postData == null) return null;
return Post.fromJson(postData);
}
}
Loading

0 comments on commit 5177ae9

Please sign in to comment.