Skip to content

Commit

Permalink
fixed the problem of changing view upon clicking on a snippet, still …
Browse files Browse the repository at this point in the history
…problem for the first file change after clicking
  • Loading branch information
Sahar Mehrpour authored and Sahar Mehrpour committed May 2, 2018
1 parent e2ba76d commit 3d4202f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 12 additions & 2 deletions src/appManager/hashManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class HashManager {
this.history = ["#/index"];
this.clicked = false;
this.activeHash = 0;
this.ignoreFile = false;

this.attachListener();
this.setupNavigationButtons();
Expand All @@ -30,8 +31,17 @@ class HashManager {

// [hash, values]
PubSub.subscribe('UPDATE_HASH', (msg, data) => {
data.forEach((d, i, a) => a[i] = d.replace('/Users/saharmehrpour/Documents/Workspace/', '').replace(/\//g, '%2F'));
window.location.hash = '#/' + data.join('/');
if(!this.ignoreFile) {
if (data.length > 0)
data.forEach((d, i, a) => a[i] = d.replace('/Users/saharmehrpour/Documents/Workspace/', '').replace(/\//g, '%2F'));
window.location.hash = '#/' + data.join('/');
}
else
PubSub.publish('IGNORE_FILE', [false]);
});

PubSub.subscribe('IGNORE_FILE', (msg, data) => {
this.ignoreFile = data[0];
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/appManager/webSocketManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class WebSocketManager {
// after sending a piece of code DECL_STMT
case "SHOW_RULES_FOR_FILE":
let focusedFilePath = message.data;
PubSub.publish('SHOW_RULES_FOR_FILE', [focusedFilePath]);
// PubSub.publish('SHOW_RULES_FOR_FILE', [focusedFilePath]);
PubSub.publish('UPDATE_HASH', ['rulesForFile', focusedFilePath]);
break;

Expand Down
9 changes: 3 additions & 6 deletions src/ui/ruleTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class RuleTable extends React.Component {

this.attachListener();
this.state = {rulesToDisplay: [], codeChanged: false, filePath: "nonegit status"};
this.ignoreFile = false;
}

render() {
Expand Down Expand Up @@ -108,6 +107,7 @@ class RuleTable extends React.Component {
this.rules = data[0];
});

// Publishing from WebSocket - commented
// [ruleTable, filePath]
PubSub.subscribe('DISPLAY_UPDATE_RULES_FOR_FILE', (msg, data) => {
this.rules = data[0];
Expand All @@ -117,11 +117,8 @@ class RuleTable extends React.Component {

// [filePath]
PubSub.subscribe('SHOW_RULES_FOR_FILE', (msg, data) => {
if (!this.ignoreFile) {
this.setState({rulesToDisplay: this.rules, codeChanged: false, filePath: data[0]});
this.updateTextareaLength();
}
else PubSub.publish('IGNORE_FILE', [false])
this.setState({rulesToDisplay: this.rules, codeChanged: false, filePath: data[0]});
this.updateTextareaLength();
});


Expand Down

0 comments on commit 3d4202f

Please sign in to comment.