Skip to content

Commit 9982d14

Browse files
committed
prevent duplicate updateAllUnprocessedInputs call
TimelineContext loadTimelineEntries retrieves the pipeline range, calls updateAllUnprocessedInputs for that range, and then sets the pipeline range as state via setPipelineRange. Then in LabelTab, we have a useEffect: when pipelineRange changes, we call updateAllUnprocessedInputs (again!) setPipelineRange is not called from anywhere else, meaning that this duplicate scenario is the time this useEffect gets called. We can remove it. tested recording new labels, refreshing the page, and changing to different dates, and labels still get matched properly
1 parent 6cd0d55 commit 9982d14

3 files changed

Lines changed: 2 additions & 7 deletions

File tree

www/js/TimelineContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export const useTimelineContext = (): ContextProps => {
139139
}, [timelineMap]);
140140

141141
async function loadTimelineEntries() {
142+
logDebug('Timeline: loadTimelineEntries called');
142143
try {
143144
const pipelineRange = await getPipelineRangeTs();
144145
await updateAllUnprocessedInputs(pipelineRange, appConfig);

www/js/diary/LabelTab.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ const LabelTab = () => {
9797
setDisplayedEntries(entriesToDisplay);
9898
}, [timelineMap, filterInputs, timelineLabelMap, filterRefreshTs]);
9999

100-
// once pipelineRange is set, update all unprocessed inputs
101-
useEffect(() => {
102-
if (pipelineRange && pipelineRange.end_ts) {
103-
updateAllUnprocessedInputs(pipelineRange, appConfig);
104-
}
105-
}, [pipelineRange]);
106-
107100
const Tab = createStackNavigator();
108101

109102
const contextVals: LabelContextProps = {

www/js/diary/timelineHelper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export async function updateAllUnprocessedInputs(
170170
pipelineRange: TimestampRange,
171171
appConfig: DeploymentConfig,
172172
) {
173+
logDebug(`timelineHelper: updateAllUnprocessedInputs for ${JSON.stringify(pipelineRange)}`);
173174
const tq = getUnprocessedInputQuery(pipelineRange);
174175
const getMethod = window['cordova'].plugins.BEMUserCache.getMessagesForInterval;
175176
const labelsPromises = keysForLabelInputs(appConfig).map((key) =>

0 commit comments

Comments
 (0)