Skip to content

Commit

Permalink
moving the code to a helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Sep 29, 2022
1 parent 1aefe89 commit c8b3f43
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,33 +170,28 @@ export default class MetaMetricsController {
);

if (hasAlarm) {
Object.values(this.store.getState().fragments).forEach(
(fragment) => {
if (
fragment.timeout &&
Date.now() - fragment.lastUpdated / 1000 > fragment.timeout
) {
this.finalizeEventFragment(fragment.id, { abandoned: true });
}
},
);
this.finalizeAbandonedFragments();
}
});
});
} else {
setInterval(() => {
Object.values(this.store.getState().fragments).forEach((fragment) => {
if (
fragment.timeout &&
Date.now() - fragment.lastUpdated / 1000 > fragment.timeout
) {
this.finalizeEventFragment(fragment.id, { abandoned: true });
}
});
this.finalizeAbandonedFragments();
}, SECOND * 30);
}
}

finalizeAbandonedFragments() {
Object.values(this.store.getState().fragments).forEach((fragment) => {
if (
fragment.timeout &&
Date.now() - fragment.lastUpdated / 1000 > fragment.timeout
) {
this.finalizeEventFragment(fragment.id, { abandoned: true });
}
});
}

generateMetaMetricsId() {
return bufferToHex(
keccak(
Expand Down

0 comments on commit c8b3f43

Please sign in to comment.