Skip to content

Commit 6b1176e

Browse files
✨ add flag when an answer has multiple versions (#394)
Fix #386. Automatically create a flag when an answer has different versions (the certified version and the latest version).
1 parent d0bd643 commit 6b1176e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

client/src/components/Flags/Flag.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ const flagMeta = {
2626
icon: 'verified',
2727
color: '#caac00',
2828
},
29+
versions: {
30+
icon: 'group',
31+
color: '#1E2019',
32+
},
2933
}
3034

3135
const Flag = ({ flag, withlabel, style, ...otherProps }) => {
@@ -68,6 +72,7 @@ Flag.translations = {
6872
unanswered: 'unanswered',
6973
certified: 'certified',
7074
certifiedAdd: ' on ',
75+
versions: 'multiple versions',
7176
},
7277
fr: {
7378
duplicate: 'doublon',
@@ -76,6 +81,7 @@ Flag.translations = {
7681
unanswered: 'sans réponse',
7782
certified: 'certifiée',
7883
certifiedAdd: ' le ',
84+
versions: 'plusieurs versions',
7985
},
8086
}
8187

server/src/resolvers/answer.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ const {
33
ctxUser,
44
refreshCertifiedFlag,
55
addCertifiedFlagWhenSpecialist,
6-
storeTranslation
6+
storeTranslation,
7+
createFlagAndUpdateHistoryAndAlgolia
78
} = require('../helpers')
89
const { algolia, mailgun } = require('../integrations')
910

@@ -239,6 +240,16 @@ module.exports = {
239240
certifiedContent = answer.certified
240241
}
241242

243+
if (certifiedContent && !answer.node.flags.find(flag => flag.type === 'versions')) {
244+
await createFlagAndUpdateHistoryAndAlgolia(
245+
history,
246+
'versions',
247+
ctx,
248+
answer.node.id,
249+
ctxUser(ctx).id
250+
)
251+
}
252+
242253
const { language, translation } = await storeTranslation(content)
243254

244255
const updateAnswerData = {

0 commit comments

Comments
 (0)