Skip to content

Commit

Permalink
improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopivi committed May 27, 2019
1 parent 792e0ae commit ae7a22e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
12 changes: 6 additions & 6 deletions web/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ export default class Editor extends React.Component<{}, IEditorState> {
private saveToLocalStorage = (saveTabs, saveAdapterOptions, saveCurrentAdapter) => {
if (window && localStorage) {
if (saveTabs) {
localStorage.setItem('tabs', JSON.stringify(this.tabs));
localStorage.setItem('__tabs', JSON.stringify(this.tabs));
}
if (saveAdapterOptions) {
localStorage.setItem('adapterOptions', this.state.useCustomOptions ? JSON.stringify(this.state.adapterOptions) : '');
localStorage.setItem('__adapterOptions', this.state.useCustomOptions ? JSON.stringify(this.state.adapterOptions) : '');
}
if (saveCurrentAdapter) {
localStorage.setItem('currentAdapter', this.state.currentAdapter);
localStorage.setItem('__currentAdapter', this.state.currentAdapter);
}
}
};
Expand Down Expand Up @@ -351,9 +351,9 @@ export default class Editor extends React.Component<{}, IEditorState> {
private loadFromLocalStorage = (cb: () => void) => {
if (window && localStorage) {
const newState: any = {};
const localTabs = this.loadFromLocalIfPresent('tabs', true);
const localAdapterOptions = this.loadFromLocalIfPresent('adapterOptions', true);
const localCurrentAdapter = this.loadFromLocalIfPresent('currentAdapter', false);
const localTabs = this.loadFromLocalIfPresent('__tabs', true);
const localAdapterOptions = this.loadFromLocalIfPresent('__adapterOptions', true);
const localCurrentAdapter = this.loadFromLocalIfPresent('__currentAdapter', false);
this.tabs = localTabs ? localTabs : tabs;
if (localAdapterOptions) {
newState.adapterOptions = localAdapterOptions;
Expand Down
18 changes: 11 additions & 7 deletions web/lib/editorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import * as webAdapter from '../../src/adapters/web';

const findRestaurantsByCity = `import ./common.chatito
# Ways to request a restaurant within a location (using probability operator)
# NOTE: 60% of the examples should come from the first sentence, and 40 from the second
%[findRestaurantsByCity]('training': '100', 'testing': '100')
~[hi?] ~[please?] ~[find?] ~[restaurants] ~[located at] @[city] ~[city?] ~[thanks?]
*[60] ~[hi?] ~[please?] ~[find?] ~[restaurants] ~[located at] @[city] ~[city?] ~[thanks?]
*[40] ~[restaurants] ~[located at] @[city]
@[city]
~[new york]
Expand Down Expand Up @@ -33,7 +37,7 @@ const affirmative = `// Ways to say yes
import ./common.chatito
%[affirmative]('training': '50', 'testing': '50')
~[yes]
*[20] ~[yes]
~[yes] ~[please?]
~[yes] ~[yes?] ~[thanks?]
~[yes?] ~[that is good] ~[yes?]
Expand Down Expand Up @@ -66,7 +70,7 @@ const bye = `// Ways to say goodbye
import ./common.chatito
%[bye]('training': '50', 'testing': '50')
~[bye]
*[10] ~[bye]
~[thanks?] ~[bye]
~[bye] ~[thanks?]
~[leaving]
Expand Down Expand Up @@ -99,7 +103,7 @@ const greet = `// Ways to say hello
import ./common.chatito
%[greet]('training': '50', 'testing': '50')
~[hi]
*[10] ~[hi]
~[greetings]
~[hi] ~[greetings?]
~[hi] ~[whats up]
Expand Down Expand Up @@ -127,15 +131,15 @@ import ./common.chatito
are you around?
`;

const negative = `// Ways to say no
const negative = `/// Ways to say no
import ./common.chatito
%[negative]('training': '50', 'testing': '50')
~[no]
*[20] ~[no]
~[no] ~[please?] ~[its not ok?]
~[please?] ~[no] ~[its not ok?]
~[its not ok]
*[20] ~[its not ok]
~[no]
no
Expand Down

0 comments on commit ae7a22e

Please sign in to comment.