Skip to content

Commit 5921b41

Browse files
committed
improve notification settings
1 parent c86bfb7 commit 5921b41

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

src/graphql/resolvers/Notification.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,36 @@ export default {
2727
updateNotificationSettings: async (
2828
parent,
2929
{
30-
disableAll, disableUntil, procedures, tags,
30+
enabled, disableUntil, procedures, tags, newVote, newPreperation,
3131
},
3232
{ user },
3333
) => {
3434
user.notificationSettings = {
3535
...user.notificationSettings,
3636
..._.omitBy(
3737
{
38-
disableAll,
38+
enabled,
3939
disableUntil,
4040
procedures,
4141
tags,
42+
newVote,
43+
newPreperation,
4244
},
4345
_.isNil,
4446
),
4547
};
48+
console.log(_.omitBy(
49+
{
50+
enabled,
51+
disableUntil,
52+
procedures,
53+
tags,
54+
newVote,
55+
newPreperation,
56+
},
57+
_.isNil,
58+
));
59+
console.log(user);
4660
await user.save();
4761
return user.notificationSettings;
4862
},

src/graphql/schemas/Notification.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export default `
55
}
66
77
type NotificationSettings {
8-
disableAll: Boolean
8+
enabled: Boolean
9+
newVote: Boolean
10+
newPreperation: Boolean
911
disableUntil: Date
1012
procedures: [String]
1113
tags: [String]
@@ -17,7 +19,14 @@ export default `
1719
1820
type Mutation {
1921
addToken(token: String!, os: String!): TokenResult
20-
updateNotificationSettings(disableAll: String, disableUntil: Date, procedures: [String], tags: [String]): NotificationSettings
22+
updateNotificationSettings(
23+
enabled: Boolean,
24+
newVote: Boolean,
25+
newPreperation: Boolean,
26+
disableUntil: Date,
27+
procedures: [String],
28+
tags: [String]
29+
): NotificationSettings
2130
}
2231
2332
`;

src/models/User.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ const UserSchema = new Schema(
1212
},
1313
],
1414
notificationSettings: {
15-
disableAll: { type: Boolean, default: false },
16-
disableUntil: { type: Date },
15+
enabled: { type: Boolean, default: false },
16+
disableUntil: Date,
17+
newVote: { type: Boolean, default: true },
18+
newPreperation: { type: Boolean, default: false },
1719
procedures: [{ type: Schema.Types.ObjectId, ref: 'Procedure' }],
1820
tags: [],
1921
},

0 commit comments

Comments
 (0)