Skip to content

Commit

Permalink
Merge pull request #138 from froboy/main
Browse files Browse the repository at this point in the history
fix: Count length of alerts with markup
  • Loading branch information
podarok authored Apr 11, 2024
2 parents 4343bf4 + d5797a3 commit 1d29bcd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
9 changes: 1 addition & 8 deletions js/openy-alerts/build/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/openy-alerts/build/main.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ class AlertItem extends Component {
description = description.concat(parse(this.props.description));
description.forEach( el => {
if(el.props) {
length += el.props.children.length;
// If the description has markup, we need to count each element.
if(el.props.children instanceof Object) {
el.props.children.forEach( el => {
// If the element has markup it's an object.
if(el instanceof Object){
length += el.props.children.length;
}
// If not an object we just get the length.
else length += el.length;
})
}
else length += el.props.children.length;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ class AlertItem extends Component {
description = description.concat(parse(this.props.description));
description.forEach( el => {
if(el.props) {
length += el.props.children.length;
// If the description has markup, we need to count each element.
if(el.props.children instanceof Object) {
el.props.children.forEach( el => {
// If the element has markup it's an object.
if(el instanceof Object){
length += el.props.children.length;
}
// If not an object we just get the length.
else length += el.length;
})
}
else length += el.props.children.length;
}
});
this.setState({
Expand Down
2 changes: 1 addition & 1 deletion openy_node_alert.libraries.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alert:
version: 1.4
version: 1.5
js:
js/openy-alerts/build/main.js: {preprocess: false}
js/openy_node_alert.js: {preprocess: false}
Expand Down

0 comments on commit 1d29bcd

Please sign in to comment.