diff --git a/src/calc2/main.tsx b/src/calc2/main.tsx index c047802b..5e2210a0 100644 --- a/src/calc2/main.tsx +++ b/src/calc2/main.tsx @@ -67,7 +67,7 @@ export class Main extends React.Component { - + (

404

diff --git a/src/calc2/store/groups.ts b/src/calc2/store/groups.ts index 69227de4..cee4ab00 100644 --- a/src/calc2/store/groups.ts +++ b/src/calc2/store/groups.ts @@ -68,16 +68,39 @@ export function* rootSaga() { }; yield saga.put(success); if (setCurrent !== undefined && loadedGroups.length > 0) { - const { source, id, filename } = loadedGroups[0].groupInfo; - - const setCurrent: GROUP_SET_CURRENT = { - type: 'GROUP_SET_CURRENT', - source, - id, - filename, - index: 0, - }; - yield saga.put(setCurrent); + // In case the :filename and :index are set in the URL, + // it's necessary to set the correct group accordingly + if (setCurrent && setCurrent != 'first' && + setCurrent.filename && setCurrent.index) { + for(var i=0;i { constructor(props: Props) { super(props); this.state = {}; - this.mode = props.params.mode; - this.query = atob(props.params.query) + this.mode = props.params.mode; + // Fix issue of parsing + as a space + // https://www.npmjs.com/package/query-string + // https://github.com/sindresorhus/query-string/issues/305 + // https://stackoverflow.com/questions/2678551/when-to-encode-space-to-plus-or-20 + // https://stackoverflow.com/questions/3794919/replace-all-spaces-in-a-string-with + this.query = atob(props.params.query.split(' ').join('+')) } componentDidMount() { diff --git a/src/calc2/views/calc.tsx b/src/calc2/views/calc.tsx index c70b5b99..525ceeae 100644 --- a/src/calc2/views/calc.tsx +++ b/src/calc2/views/calc.tsx @@ -50,6 +50,11 @@ export class Calc extends React.Component { })*/ this.apiView = this.props.location.pathname.split("/")[2] == "api" this.params = queryString.parse(this.props.location.search) + + // It's necessary to load remote group synchronouly + if (this.apiView) { + this.loadGroup(this.props); + } } componentDidUpdate(prevProps: Props): void {