Skip to content

Commit

Permalink
Merge pull request #397 from vgteam/fix_failed_prop_type_error
Browse files Browse the repository at this point in the history
Fix failed prop type error
  • Loading branch information
adamnovak authored Mar 4, 2024
2 parents 7b31d04 + b7f802a commit dac6e11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/components/HeaderForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,16 @@ class HeaderForm extends Component {
}
return null;
}

// Function to convert array to object, where the key would be the index and the value
// would be the value at the array index
convertArrayToObject = (array) => {
let obj = {};
for(let i = 0; i < array.length; i++){
obj[i] = array[i];
}
return obj;
}

// Adopt a new region
// Update the region description
Expand Down Expand Up @@ -636,7 +646,7 @@ class HeaderForm extends Component {

// Override current tracks with new tracks from chunk dir
if (tracks) {
this.setState({ tracks: tracks });
this.setState({ tracks: this.convertArrayToObject(tracks) });
console.log("New tracks have been applied");
} else if (this.state.bedFile && chunk) {
// Try to retrieve tracks from the server
Expand All @@ -651,7 +661,8 @@ class HeaderForm extends Component {
this.setState((laterState) => {
if (laterState.region === coords) {
// The user still has the same region selected, so apply the tracks we now have
return { tracks: json.tracks };
console.log("json tracks: ", json.tracks)
return {tracks: this.convertArrayToObject(json.tracks)};
}
// Otherwise, don't apply the downloaded tracks, because they are no longer relevant.
// TODO: Save the downloaded tracks in case the user selects the region again?
Expand Down
2 changes: 1 addition & 1 deletion src/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ async function getBedRegions(bed) {
bed_data = fs.readFileSync(bed).toString();
}

lines = bed_data.split("\n");
lines = bed_data.split(/\r?\n/);
lines.map(function (line) {
let records = line.split("\t");

Expand Down

0 comments on commit dac6e11

Please sign in to comment.