Skip to content

Commit

Permalink
force file loads when returning to file browser
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Jul 16, 2020
1 parent fcf6aef commit 9c55da7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
11 changes: 8 additions & 3 deletions app/actions/fileLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export function loadRootFolder() {
}

if (rootFolderPath === getState().fileLoader.rootFolderPath) {
// Reload the currently selected folder even if the root hasn't changed, the loadRootFolder
// function only gets called when entering the fileLoader component from the main menu and
// we want to support returning to the fileLoader from the main menu to update the files
// in the list
await changeFolderSelection(getState().fileLoader.selectedFolderFullPath)(dispatch, getState);
return;
}

Expand Down Expand Up @@ -183,9 +188,9 @@ export function setStatsGamePage(index) {
dispatch({
type: SET_STATS_GAME_PAGE,
payload: { statsGameIndex: statsGameIndex },
})
});
gameProfileLoad(files[statsGameIndex].game)(dispatch);
}
};
}

async function loadFilesInFolder(folderPath) {
Expand Down Expand Up @@ -230,7 +235,7 @@ async function loadFilesInFolder(folderPath) {
hasError = true;
}

const startTime = timeUtils.fileToDateAndTime(game, fileName, fullPath)
const startTime = timeUtils.fileToDateAndTime(game, fileName, fullPath);

return {
fullPath: fullPath,
Expand Down
6 changes: 3 additions & 3 deletions app/components/FileLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export default class FileLoader extends Component {

componentDidMount() {
if (this.props.history.action === "PUSH") {
// I don't really like this but when returning back to the file loader, the action is "POP"
// instead of "PUSH", and we don't want to trigger the loader and ruin our ability to restore
// scroll position when returning to fileLoader from a game
// The action when returning from the stats page is "POP". The action when coming from the
// main menu is "PUSH". When coming from the main menu, we want to reload the files such that
// any new files show up correctly
this.props.loadRootFolder();
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/FileRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class FileRow extends Component {
<Icon size="big" name="check square outline" />
<div className={styles['pos-text']}>{this.props.selectedOrdinal}</div>
</div>
)
);
} else {
contents = (
<Icon size="big" name="square outline" />
Expand Down Expand Up @@ -162,7 +162,7 @@ export default class FileRow extends Component {

generateTeamElements() {
if (this.state.isError) {
return null;
return <div />;
}

const file = this.props.file || {};
Expand Down
1 change: 0 additions & 1 deletion app/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ const handleSlippiURIAsync = async (aUrl) => {
await waitForMainWindow();
mainWindow.webContents.send("play-replay", path.join(tmpDir, 'replay.slp'));


break;
case "file:":
log.info(myUrl.pathname);
Expand Down

0 comments on commit 9c55da7

Please sign in to comment.