Closed Bug 1757401 Opened 3 years ago Closed 3 years ago

Use new source object's thread attribute to simplify reducers

Categories

(DevTools :: Debugger, enhancement)

enhancement

Tracking

(firefox99 fixed)

RESOLVED FIXED
99 Branch
Tracking Status
firefox99 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Bug 1757375 just added a thread attribute on all redux source objects.
This should help get rid of various selectors which were computing this data out of the source actors related to a the given source.
We can replace these couple of selectors with a simple attribute access!

https://searchfox.org/mozilla-central/rev/684aefab97202faa982dd898f1d99208a46f12b0/devtools/client/debugger/src/selectors/threads.js#51-62

export function getThreadForSource(state, sourceId) {
  const actors = getSourceActorsForSource(
    state,
    isOriginalId(sourceId) ? originalToGeneratedId(sourceId) : sourceId
  );

  if (!actors || !actors.length) {
    console.error(`Error no source actors exist for source ${sourceId}`);
    return null;
  }
  return getThread(state, actors[0].thread);
}

https://searchfox.org/mozilla-central/rev/684aefab97202faa982dd898f1d99208a46f12b0/devtools/client/debugger/src/selectors/source-actors.js#59-77

const queryThreadsBySourceObject = makeReduceAllQuery(
  actor => ({ thread: actor.thread, source: actor.source }),
  actors =>
    actors.reduce((acc, { source, thread }) => {
      let sourceThreads = acc[source];
      if (!sourceThreads) {
        sourceThreads = [];
        acc[source] = sourceThreads;
      }

      sourceThreads.push(thread);
      return acc;
    }, {})
);

// Used by threads selectors
export function getAllThreadsBySource(state) {
  return queryThreadsBySourceObject(state.sourceActors);
}
Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/10e5ac539c0d [devtools] Simplify source selectors thanks to thread attribute on sources. r=bomsy
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 99 Branch
Blocks: 1748224
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: