Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

[WIP] consolidate source text#3081

Merged
jasonLaster merged 1 commit into
firefox-devtools:masterfrom
jasonLaster:consolidate-sources
Jun 5, 2017
Merged

[WIP] consolidate source text#3081
jasonLaster merged 1 commit into
firefox-devtools:masterfrom
jasonLaster:consolidate-sources

Conversation

@jasonLaster
Copy link
Copy Markdown
Contributor

Associated Issue: #3078

Summary of Changes

I started refactoring the sources store to remove SourceText. The reason is that it is not needed and creates extra complexity around selectors and typing in our components, actions, and utilities.

@jasonLaster jasonLaster force-pushed the consolidate-sources branch from 2cbdf8a to 11e4542 Compare June 5, 2017 03:13
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2017

Codecov Report

Merging #3081 into master will increase coverage by 0.11%.
The diff coverage is 94.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3081      +/-   ##
==========================================
+ Coverage   66.15%   66.27%   +0.11%     
==========================================
  Files          74       74              
  Lines        2603     2612       +9     
  Branches      527      528       +1     
==========================================
+ Hits         1722     1731       +9     
  Misses        881      881
Impacted Files Coverage Δ
src/reducers/sources.js 80.13% <94.73%> (+1.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92b200f...6414f0f. Read the comment docs.

Copy link
Copy Markdown
Contributor

@codehag codehag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work so far!

Comment thread src/reducers/sources.js Outdated
// to rethink how we type async actions.
function updateText(state, action: any): Record<SourcesState> {
const source = action.source;
const text = getTextFromAction(action);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be more than text. for example it can also have an id, content type, and loading state. maybe we can name this a bit better? sourceTextProps comes to mind, or just updateProps

Comment thread src/reducers/sources.js Outdated
// "start" and "error" states but we don't type it like that. We need
// to rethink how we type async actions.
function _updateText(state, action: any): Record<SourcesState> {
function getTextFromAction(action: any) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this returns more than text, maybe getTextPropsFromAction is clearer?

Comment thread src/reducers/sources.js
contentType: sourceText.contentType
})
);
return state.mergeIn(["sources", source.id], source);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can have a comment here about why we are merging, rather than setting? I saw above there was such a comment in the previous version of the code, might be helpful here too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment before covered a special case that we no longer are concerned with. I am not sure if I have something that I want to say here except that we're adding source fields :)

}

const hasLoaded = sourceText && !sourceText.get("loading");
const hasLoaded = selectedSource && !selectedSource.get("loading");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jasonLaster jasonLaster force-pushed the consolidate-sources branch from 11e4542 to 6414f0f Compare June 5, 2017 14:22
Copy link
Copy Markdown
Contributor

@codehag codehag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jasonLaster jasonLaster merged commit 781c96c into firefox-devtools:master Jun 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants