From 3d4202f6ae4b09f110f1f9ccedd01699a2be2c6e Mon Sep 17 00:00:00 2001 From: Sahar Mehrpour Date: Wed, 2 May 2018 12:22:48 -0400 Subject: [PATCH] fixed the problem of changing view upon clicking on a snippet, still problem for the first file change after clicking --- src/appManager/hashManager.js | 14 ++++++++++++-- src/appManager/webSocketManager.js | 2 +- src/ui/ruleTable.js | 9 +++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/appManager/hashManager.js b/src/appManager/hashManager.js index 95d1e66..acbd73b 100644 --- a/src/appManager/hashManager.js +++ b/src/appManager/hashManager.js @@ -16,6 +16,7 @@ class HashManager { this.history = ["#/index"]; this.clicked = false; this.activeHash = 0; + this.ignoreFile = false; this.attachListener(); this.setupNavigationButtons(); @@ -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]; }); } diff --git a/src/appManager/webSocketManager.js b/src/appManager/webSocketManager.js index a55c4fb..62ba2cf 100644 --- a/src/appManager/webSocketManager.js +++ b/src/appManager/webSocketManager.js @@ -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; diff --git a/src/ui/ruleTable.js b/src/ui/ruleTable.js index ade0932..3e40bad 100644 --- a/src/ui/ruleTable.js +++ b/src/ui/ruleTable.js @@ -19,7 +19,6 @@ class RuleTable extends React.Component { this.attachListener(); this.state = {rulesToDisplay: [], codeChanged: false, filePath: "nonegit status"}; - this.ignoreFile = false; } render() { @@ -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]; @@ -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(); });