Merge branch 'master' into sort-enhancements

This commit is contained in:
Kiwi
2017-08-29 19:39:59 +02:00
committed by GitHub
3 changed files with 25 additions and 9 deletions
+13 -2
View File
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
export default class Popup extends Component {
ref = null;
detectCloseInterval = null;
resetCallbackInterval = null;
constructor(props) {
super(props);
@@ -41,16 +42,26 @@ export default class Popup extends Component {
this.ref.onunload = () => {
this.onUnload();
const interval = setInterval(() => {
if (this.resetCallbackInterval) {
clearInterval(this.resetCallbackInterval);
}
this.resetCallbackInterval = setInterval(() => {
if (this.ref && this.ref.onload === null) {
clearInterval(this.resetCallbackInterval);
this.resetCallbackInterval = null;
this.setCallbacks();
clearInterval(interval);
}
}, 50);
if (this.detectCloseInterval) {
clearInterval(this.detectCloseInterval);
}
this.detectCloseInterval = setInterval(() => {
if (!this.ref || this.ref.closed) {
clearInterval(this.detectCloseInterval);
this.detectCloseInterval = null;
this.onClose();
}
}, 50);
+9 -4
View File
@@ -185,10 +185,15 @@ export function getShallowChanges(a, b) {
.filter((key) => a[key] !== b[key]);
}
// TODO: replace with something less fragile.
// NOT_REACTION_TYPES are the action summaries that are not reactions.
const NOT_REACTION_TYPES = [
'FlagActionSummary',
'DontAgreeActionSummary',
];
export function getTotalReactionsCount(actionSummaries) {
return actionSummaries
.filter((s) => s.__typename !== 'FlagActionSummary')
.reduce((total, summary) => {
return total + summary.count;
}, 0);
.filter(({__typename}) => !NOT_REACTION_TYPES.includes(__typename))
.reduce((total, {count}) => total + count, 0);
}
+3 -3
View File
@@ -34,7 +34,7 @@ describe('graph.queries.asset', () => {
username: 'usernameC'
}
]);
comments = await CommentsService.publicCreate([0, 1, 0, 1].map((idx) => ({
comments = await CommentsService.publicCreate([0, 0, 1, 1].map((idx) => ({
author_id: users[idx].id,
asset_id: assets[idx].id,
body: `hello there! ${String(Math.random()).slice(2)}`,
@@ -74,12 +74,12 @@ describe('graph.queries.asset', () => {
expect(asset.nodes).to.have.length(2);
expect(asset.hasNextPage).to.be.false;
expect(asset.nodes[0]).to.have.property('id', comments[2].id);
expect(asset.nodes[0]).to.have.property('id', comments[1].id);
expect(asset.nodes[1]).to.have.property('id', comments[0].id);
expect(otherAsset.nodes).to.have.length(2);
expect(otherAsset.hasNextPage).to.be.false;
expect(otherAsset.nodes[0]).to.have.property('id', comments[3].id);
expect(otherAsset.nodes[1]).to.have.property('id', comments[1].id);
expect(otherAsset.nodes[1]).to.have.property('id', comments[2].id);
for (let node of asset.nodes) {
for (let otherNode of otherAsset.nodes) {