Skip to content

Commit

Permalink
Rename top-level profiles to profileGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Wong committed Aug 12, 2018
1 parent 0bf2d79 commit afc0143
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {actions} from './actions'
import * as redux from 'redux'
import {setter, Reducer} from '../lib/typed-redux'
import {HashParams, getHashParams} from '../lib/hash-params'
import {ProfileGroupState, profiles} from './profiles-state'
import {ProfileGroupState, profileGroup} from './profiles-state'

export const enum ViewMode {
CHRONO_FLAME_CHART,
Expand All @@ -28,7 +28,7 @@ export interface ApplicationState {
loading: boolean
error: boolean

profiles: ProfileGroupState
profileGroup: ProfileGroupState
}

const protocol = window.location.protocol
Expand All @@ -46,7 +46,7 @@ export function createApplicationStore(
const loading = canUseXHR && hashParams.profileURL != null

const reducer: Reducer<ApplicationState> = redux.combineReducers({
profiles,
profileGroup,

hashParams: setter<HashParams>(actions.setHashParams, hashParams),

Expand Down
2 changes: 1 addition & 1 deletion src/store/profiles-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function actionProfileIndex(action: Action<any>): number | null {
}
}

export const profiles: Reducer<ProfileGroupState> = (state = null, action) => {
export const profileGroup: Reducer<ProfileGroupState> = (state = null, action) => {
if (actions.setProfileGroup.matches(action)) {
const {indexToView, profiles, name} = action.payload
return {
Expand Down
14 changes: 7 additions & 7 deletions src/views/application-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {actions} from '../store/actions'
export const ApplicationContainer = createContainer(
Application,
(state: ApplicationState, dispatch: Dispatch) => {
const {flattenRecursion, profiles} = state
const {flattenRecursion, profileGroup} = state

let activeProfileState: ActiveProfileState | null = null
if (profiles) {
if (profiles.profiles.length > profiles.indexToView) {
const index = profiles.indexToView
const profileState = profiles.profiles[index]
if (profileGroup) {
if (profileGroup.profiles.length > profileGroup.indexToView) {
const index = profileGroup.indexToView
const profileState = profileGroup.profiles[index]
activeProfileState = {
...profiles.profiles[profiles.indexToView],
...profileGroup.profiles[profileGroup.indexToView],
profile: getProfileToView({profile: profileState.profile, flattenRecursion}),
index: profiles.indexToView,
index: profileGroup.indexToView,
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/views/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ export class Toolbar extends StatelessComponent<ToolbarProps> {
}

renderCenterContent() {
const {activeProfileState, profiles} = this.props
if (activeProfileState && profiles) {
const {activeProfileState, profileGroup} = this.props
if (activeProfileState && profileGroup) {
const {index} = activeProfileState
if (profiles.profiles.length === 1) {
if (profileGroup.profiles.length === 1) {
return activeProfileState.profile.getName()
} else {
function makeNavButton(content: string, disabled: boolean, onClick: () => void) {
Expand All @@ -106,7 +106,7 @@ export class Toolbar extends StatelessComponent<ToolbarProps> {
const prevButton = makeNavButton('⬅️', index === 0, () =>
this.props.setProfileIndexToView(index - 1),
)
const nextButton = makeNavButton('➡️', index >= profiles.profiles.length - 1, () =>
const nextButton = makeNavButton('➡️', index >= profileGroup.profiles.length - 1, () =>
this.props.setProfileIndexToView(index + 1),
)

Expand All @@ -115,7 +115,7 @@ export class Toolbar extends StatelessComponent<ToolbarProps> {
{prevButton}
{activeProfileState.profile.getName()}{' '}
<span className={css(style.toolbarProfileIndex)}>
({activeProfileState.index + 1}/{profiles.profiles.length})
({activeProfileState.index + 1}/{profileGroup.profiles.length})
</span>
{nextButton}
</div>
Expand Down Expand Up @@ -299,7 +299,7 @@ export class Application extends StatelessComponent<ApplicationProps> {
return profiles
}

if (this.props.profiles && this.props.activeProfileState) {
if (this.props.profileGroup && this.props.activeProfileState) {
// If a profile is already loaded, it's possible the file being imported is
// a symbol map. If that's the case, we want to parse it, and apply the symbol
// mapping to the already loaded profile. This can be use to take an opaque
Expand All @@ -310,7 +310,7 @@ export class Application extends StatelessComponent<ApplicationProps> {
console.log('Importing as emscripten symbol map')
profile.remapNames(name => map.get(name) || name)
return {
name: this.props.profiles.name || 'profile',
name: this.props.profileGroup.name || 'profile',
indexToView: index,
profiles: [profile],
}
Expand Down Expand Up @@ -387,8 +387,8 @@ export class Application extends StatelessComponent<ApplicationProps> {
}

private saveFile = () => {
if (this.props.profiles) {
const {name, indexToView, profiles} = this.props.profiles
if (this.props.profileGroup) {
const {name, indexToView, profiles} = this.props.profileGroup
const profileGroup: ProfileGroup = {
name,
indexToView,
Expand Down

0 comments on commit afc0143

Please sign in to comment.