fix: add check for when notifications is empty
This commit is contained in:
@ -3295,7 +3295,7 @@ input NotifiedInput {
|
||||
}
|
||||
|
||||
type PageInfo {
|
||||
endCursor: String!
|
||||
endCursor: String
|
||||
hasNextPage: Boolean!
|
||||
}
|
||||
|
||||
@ -13127,14 +13127,11 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(string)
|
||||
res := resTmp.(*string)
|
||||
fc.Result = res
|
||||
return ec.marshalNString2string(ctx, field.Selections, res)
|
||||
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) (ret graphql.Marshaler) {
|
||||
@ -22809,9 +22806,6 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet,
|
||||
out.Values[i] = graphql.MarshalString("PageInfo")
|
||||
case "endCursor":
|
||||
out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
invalids++
|
||||
}
|
||||
case "hasNextPage":
|
||||
out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
|
@ -405,8 +405,8 @@ type OwnersList struct {
|
||||
}
|
||||
|
||||
type PageInfo struct {
|
||||
EndCursor string `json:"endCursor"`
|
||||
HasNextPage bool `json:"hasNextPage"`
|
||||
EndCursor *string `json:"endCursor"`
|
||||
HasNextPage bool `json:"hasNextPage"`
|
||||
}
|
||||
|
||||
type ProfileIcon struct {
|
||||
|
@ -163,11 +163,30 @@ func (r *queryResolver) Notified(ctx context.Context, input NotifiedInput) (*Not
|
||||
log.WithError(err).Error("error decoding cursor")
|
||||
return &NotifiedResult{}, err
|
||||
}
|
||||
enableRead := false
|
||||
enableActionType := false
|
||||
actionTypes := []string{}
|
||||
switch input.Filter {
|
||||
case NotificationFilterUnread:
|
||||
enableRead = true
|
||||
break
|
||||
case NotificationFilterMentioned:
|
||||
enableActionType = true
|
||||
actionTypes = []string{"COMMENT_MENTIONED"}
|
||||
break
|
||||
case NotificationFilterAssigned:
|
||||
enableActionType = true
|
||||
actionTypes = []string{"TASK_ASSIGNED"}
|
||||
break
|
||||
}
|
||||
n, err := r.Repository.GetNotificationsForUserIDCursor(ctx, db.GetNotificationsForUserIDCursorParams{
|
||||
CreatedOn: t,
|
||||
NotificationID: id,
|
||||
LimitRows: int32(input.Limit + 1),
|
||||
UserID: userID,
|
||||
CreatedOn: t,
|
||||
NotificationID: id,
|
||||
LimitRows: int32(input.Limit + 1),
|
||||
UserID: userID,
|
||||
EnableUnread: enableRead,
|
||||
EnableActionType: enableActionType,
|
||||
ActionType: actionTypes,
|
||||
})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("error decoding fetching notifications")
|
||||
@ -180,11 +199,14 @@ func (r *queryResolver) Notified(ctx context.Context, input NotifiedInput) (*Not
|
||||
"cursorId": id,
|
||||
"limit": input.Limit,
|
||||
}).Info("fetched notified")
|
||||
endCursor := n[len(n)-1]
|
||||
if len(n) == input.Limit+1 {
|
||||
hasNextPage = true
|
||||
n = n[:len(n)-1]
|
||||
endCursor = n[len(n)-1]
|
||||
var endCursor *db.GetNotificationsForUserIDCursorRow
|
||||
if len(n) != 0 {
|
||||
endCursor = &n[len(n)-1]
|
||||
if len(n) == input.Limit+1 {
|
||||
hasNextPage = true
|
||||
n = n[:len(n)-1]
|
||||
endCursor = &n[len(n)-1]
|
||||
}
|
||||
}
|
||||
userNotifications := []Notified{}
|
||||
for _, notified := range n {
|
||||
@ -206,9 +228,14 @@ func (r *queryResolver) Notified(ctx context.Context, input NotifiedInput) (*Not
|
||||
}
|
||||
userNotifications = append(userNotifications, n)
|
||||
}
|
||||
var endCursorEncoded *string
|
||||
if endCursor != nil {
|
||||
eCur := utils.EncodeCursor(endCursor.CreatedOn, endCursor.NotificationID)
|
||||
endCursorEncoded = &eCur
|
||||
}
|
||||
pageInfo := &PageInfo{
|
||||
HasNextPage: hasNextPage,
|
||||
EndCursor: utils.EncodeCursor(endCursor.CreatedOn, endCursor.NotificationID),
|
||||
EndCursor: endCursorEncoded,
|
||||
}
|
||||
log.WithField("pageInfo", pageInfo).Info("created page info")
|
||||
return &NotifiedResult{
|
||||
@ -249,11 +276,14 @@ func (r *queryResolver) Notified(ctx context.Context, input NotifiedInput) (*Not
|
||||
"nLen": len(n),
|
||||
"limit": input.Limit,
|
||||
}).Info("fetched notified")
|
||||
endCursor := n[len(n)-1]
|
||||
if len(n) == input.Limit+1 {
|
||||
hasNextPage = true
|
||||
n = n[:len(n)-1]
|
||||
endCursor = n[len(n)-1]
|
||||
var endCursor *db.GetNotificationsForUserIDPagedRow
|
||||
if len(n) != 0 {
|
||||
endCursor = &n[len(n)-1]
|
||||
if len(n) == input.Limit+1 {
|
||||
hasNextPage = true
|
||||
n = n[:len(n)-1]
|
||||
endCursor = &n[len(n)-1]
|
||||
}
|
||||
}
|
||||
userNotifications := []Notified{}
|
||||
for _, notified := range n {
|
||||
@ -275,9 +305,14 @@ func (r *queryResolver) Notified(ctx context.Context, input NotifiedInput) (*Not
|
||||
}
|
||||
userNotifications = append(userNotifications, n)
|
||||
}
|
||||
var endCursorEncoded *string
|
||||
if endCursor != nil {
|
||||
eCur := utils.EncodeCursor(endCursor.CreatedOn, endCursor.NotificationID)
|
||||
endCursorEncoded = &eCur
|
||||
}
|
||||
pageInfo := &PageInfo{
|
||||
HasNextPage: hasNextPage,
|
||||
EndCursor: utils.EncodeCursor(endCursor.CreatedOn, endCursor.NotificationID),
|
||||
EndCursor: endCursorEncoded,
|
||||
}
|
||||
log.WithField("pageInfo", pageInfo).Info("created page info")
|
||||
return &NotifiedResult{
|
||||
|
@ -26,7 +26,7 @@ input NotifiedInput {
|
||||
}
|
||||
|
||||
type PageInfo {
|
||||
endCursor: String!
|
||||
endCursor: String
|
||||
hasNextPage: Boolean!
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ input NotifiedInput {
|
||||
}
|
||||
|
||||
type PageInfo {
|
||||
endCursor: String!
|
||||
endCursor: String
|
||||
hasNextPage: Boolean!
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user