Skip to content

Commit

Permalink
clean up loadStashedFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
outofambit committed Apr 11, 2019
1 parent 7ca9301 commit 318e131
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
7 changes: 5 additions & 2 deletions app/src/lib/stores/app-store.ts
Expand Up @@ -4816,9 +4816,12 @@ export class AppStore extends TypedBaseStore<IAppState> {
}

/** This shouldn't be called directly. See `Dispatcher`. */
public async _loadStashedFiles(repository: Repository, branchName: string) {
public async _loadStashedFiles(
repository: Repository,
stashEntry: IStashEntry
) {
const gitStore = this.gitStoreCache.get(repository)
await gitStore.loadStashedFiles(branchName)
await gitStore.loadStashedFiles(stashEntry)
this.emitUpdate()
}

Expand Down
9 changes: 2 additions & 7 deletions app/src/lib/stores/git-store.ts
Expand Up @@ -1003,15 +1003,10 @@ export class GitStore extends BaseStore {
/**
* Updates the latest stash entry with a list of files that it changes
*/
public async loadStashedFiles(branchName: string) {
// get current branch stash entry
const stashEntry = this._stashEntries.get(branchName)
if (stashEntry === undefined) {
return
}
public async loadStashedFiles(stashEntry: IStashEntry) {
const files = await getChangedFiles(this.repository, stashEntry.stashSha)

this._stashEntries.set(branchName, { ...stashEntry, files })
this._stashEntries.set(stashEntry.branchName, { ...stashEntry, files })
this.emitUpdate()
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/ui/dispatcher/dispatcher.ts
Expand Up @@ -1961,8 +1961,8 @@ export class Dispatcher {
}

/** Loads the list of changed files for the latest stash on this branch */
public loadStashedFiles(repository: Repository, branchName: string) {
return this.appStore._loadStashedFiles(repository, branchName)
public loadStashedFiles(repository: Repository, stashEntry: IStashEntry) {
return this.appStore._loadStashedFiles(repository, stashEntry)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/src/ui/repository.tsx
Expand Up @@ -306,7 +306,7 @@ export class RepositoryView extends React.Component<
} else if (this.props.state.branchesState.tip.kind === TipState.Valid) {
this.props.dispatcher.loadStashedFiles(
this.props.repository,
this.props.state.branchesState.tip.branch.name
stashEntry
)
return null
}
Expand Down

0 comments on commit 318e131

Please sign in to comment.