-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Priority Resolution #1193
WIP Priority Resolution #1193
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,19 @@ | |
const { render, returnedPropositions } = processPropositions( | ||
propositionsToExecute, | ||
); | ||
debugger; | ||
|
||
const handleNotifications = notificationHandler( | ||
renderDecisions, | ||
sendDisplayEvent, | ||
viewName, | ||
); | ||
render().then(handleNotifications); | ||
render().then( | ||
handleNotifications.bind( | ||
null, | ||
returnedPropositions.filter((p) => p.isSuppressedDisplay), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these params are in the wrong order. See createNotificationHandler.js#L28 |
||
), | ||
); | ||
|
||
return Promise.resolve({ | ||
propositions: returnedPropositions, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ const isValidInAppMessage = (data, logger) => { | |
}; | ||
|
||
export default ({ modules, logger }) => { | ||
return (item) => { | ||
return (item, firstItemInBatch) => { | ||
const data = item.getData(); | ||
const meta = { ...item.getProposition().getNotification() }; | ||
|
||
|
@@ -73,14 +73,16 @@ export default ({ modules, logger }) => { | |
} | ||
|
||
return { | ||
render: () => { | ||
return modules[type]({ | ||
...data, | ||
meta, | ||
}); | ||
}, | ||
setRenderAttempted: true, | ||
includeInNotification: true, | ||
render: firstItemInBatch | ||
? () => | ||
modules[type]({ | ||
...data, | ||
meta, | ||
}) | ||
: null, | ||
setRenderAttempted: firstItemInBatch, | ||
setSuppressedDisplay: !firstItemInBatch, | ||
includeInNotification: firstItemInBatch, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was under the impression that we should only be rendering the last item. |
||
}; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,12 +50,12 @@ | |
return meta; | ||
}); | ||
|
||
const processItem = (item) => { | ||
const processItem = (item, firstItemInBatch) => { | ||
const processor = schemaProcessors[item.getSchema()]; | ||
if (!processor) { | ||
return {}; | ||
} | ||
return processor(item); | ||
return processor(item, firstItemInBatch); | ||
}; | ||
|
||
const processItems = ({ | ||
|
@@ -64,6 +64,7 @@ | |
returnedDecisions: existingReturnedDecisions, | ||
items, | ||
proposition, | ||
firstItemInBatch = false, | ||
}) => { | ||
let renderers = [...existingRenderers]; | ||
let returnedPropositions = [...existingReturnedPropositions]; | ||
|
@@ -74,15 +75,22 @@ | |
let atLeastOneWithNotification = false; | ||
let render; | ||
let setRenderAttempted; | ||
let setSuppressedDisplay; | ||
let includeInNotification; | ||
let onlyRenderThis = false; | ||
let i = 0; | ||
let item; | ||
|
||
while (items.length > i) { | ||
item = items[i]; | ||
({ render, setRenderAttempted, includeInNotification, onlyRenderThis } = | ||
processItem(item)); | ||
({ | ||
render, | ||
setRenderAttempted, | ||
setSuppressedDisplay, | ||
includeInNotification, | ||
onlyRenderThis, | ||
} = processItem(item, firstItemInBatch)); | ||
|
||
if (onlyRenderThis) { | ||
returnedPropositions = []; | ||
returnedDecisions = []; | ||
|
@@ -98,6 +106,7 @@ | |
atLeastOneWithNotification = includeInNotification; | ||
break; | ||
} | ||
|
||
if (render) { | ||
itemRenderers.push(wrapRenderWithLogging(render, item)); | ||
} | ||
|
@@ -125,6 +134,7 @@ | |
returnedDecisions, | ||
renderedItems, | ||
true, | ||
setSuppressedDisplay, | ||
); | ||
} | ||
if (nonRenderedItems.length > 0) { | ||
|
@@ -133,9 +143,11 @@ | |
returnedDecisions, | ||
nonRenderedItems, | ||
false, | ||
setSuppressedDisplay, | ||
); | ||
} | ||
|
||
debugger; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember to remove |
||
return { | ||
renderers, | ||
returnedPropositions, | ||
|
@@ -163,6 +175,7 @@ | |
returnedDecisions, | ||
items, | ||
proposition, | ||
firstItemInBatch: i === 0, | ||
})); | ||
if (onlyRenderThis) { | ||
break; | ||
|
@@ -194,6 +207,7 @@ | |
false, | ||
); | ||
}); | ||
|
||
const render = () => { | ||
return Promise.all(renderers.map((renderer) => renderer())).then( | ||
(metas) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to remove this