mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Simplify subscription
This commit is contained in:
@@ -93,7 +93,7 @@ function showNotification(queue, comment, user) {
|
||||
notification.info(text);
|
||||
}
|
||||
|
||||
export function handleCommentStatusChange(root, comment, {sort, notify, user, activeQueue}) {
|
||||
export function handleCommentStatusChange(root, comment, {sort, notify, activeQueue}) {
|
||||
let next = root;
|
||||
const nextQueues = getCommentQueues(comment);
|
||||
|
||||
@@ -102,7 +102,8 @@ export function handleCommentStatusChange(root, comment, {sort, notify, user, ac
|
||||
if (notificationShown) {
|
||||
return;
|
||||
}
|
||||
showNotification(...args);
|
||||
const user = comment.status_history[comment.status_history.length - 1].assigned_by;
|
||||
showNotification(...[...args, user]);
|
||||
notificationShown = true;
|
||||
};
|
||||
|
||||
@@ -111,13 +112,13 @@ export function handleCommentStatusChange(root, comment, {sort, notify, user, ac
|
||||
if (!queueHasComment(next, queue, comment.id)) {
|
||||
next = addCommentToQueue(next, queue, comment, sort);
|
||||
if (notify && activeQueue === queue && shouldCommentBeAdded(next, queue, comment, sort)) {
|
||||
showNotificationOnce(queue, comment, user);
|
||||
showNotificationOnce(queue, comment);
|
||||
}
|
||||
}
|
||||
} else if(queueHasComment(next, queue, comment.id)){
|
||||
next = removeCommentFromQueue(next, queue, comment.id);
|
||||
if (notify && activeQueue === queue) {
|
||||
showNotificationOnce(queue, comment, user);
|
||||
showNotificationOnce(queue, comment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +128,7 @@ export function handleCommentStatusChange(root, comment, {sort, notify, user, ac
|
||||
&& notify
|
||||
&& activeQueue === queue
|
||||
) {
|
||||
showNotificationOnce(queue, comment, user);
|
||||
showNotificationOnce(queue, comment);
|
||||
}
|
||||
|
||||
// TODO: Flagged notification
|
||||
|
||||
@@ -42,12 +42,13 @@ class ModerationContainer extends Component {
|
||||
variables: {
|
||||
asset_id: this.props.data.variables.asset_id,
|
||||
},
|
||||
updateQuery: (prev, {subscriptionData: {data: {commentStatusChanged: {user, comment}}}}) => {
|
||||
updateQuery: (prev, {subscriptionData: {data: {commentStatusChanged: comment}}}) => {
|
||||
const user = comment.status_history[comment.status_history.length - 1].assigned_by;
|
||||
|
||||
const extraParams = this.props.auth.user.id === user.id
|
||||
? {}
|
||||
: {
|
||||
notify: true,
|
||||
user,
|
||||
activeQueue: this.activeTab,
|
||||
};
|
||||
return handleCommentStatusChange(prev, comment, {
|
||||
@@ -218,12 +219,14 @@ const COMMENTS_EDITED_SUBSCRIPTION = gql`
|
||||
const STATUS_CHANGED_SUBSCRIPTION = gql`
|
||||
subscription CommentStatusChanged($asset_id: ID){
|
||||
commentStatusChanged(asset_id: $asset_id){
|
||||
user {
|
||||
id
|
||||
username
|
||||
}
|
||||
comment {
|
||||
...${getDefinitionName(Comment.fragments.comment)}
|
||||
...${getDefinitionName(Comment.fragments.comment)}
|
||||
status_history {
|
||||
type
|
||||
created_at
|
||||
assigned_by {
|
||||
id
|
||||
username
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user