Skip to content

Commit

Permalink
partition saved state by domain and botid
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Dec 20, 2023
1 parent 43d86c2 commit 5567b65
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 104 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/chat-headless-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"sourceMap": true,
/**
* Use "react" instead of "react-jsx" to be compatible with lower React versions (e.g. 16)
*
*
* "react/jsx-runtime" have explicit "exports" field in React 18 but not in React 16/17 when
* it was backported. This would require our SDK to provide two bundles, one for React 18 and
* one for legacy versions that require us to define explicit paths
* (https://github.com/facebook/react/issues/20235).
*
*
* by using "react", we avoid the syntactic sugar JSX and output code directly using "React.createElement"
*/
"jsx": "react",
Expand Down
162 changes: 79 additions & 83 deletions packages/chat-headless/THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
The following NPM package may be included in this product:

The following npm package may be included in this product:

- @babel/[email protected]
- @babel/[email protected]

This package contains the following license and notice below:

Expand Down Expand Up @@ -32,37 +29,37 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- @reduxjs/[email protected]

This package contains the following license and notice below:

MIT License

Copyright (c) 2018 Mark Erikson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
MIT License
Copyright (c) 2018 Mark Erikson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- @yext/[email protected]

Expand Down Expand Up @@ -103,7 +100,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- @yext/[email protected]

Expand Down Expand Up @@ -145,7 +142,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand Down Expand Up @@ -175,7 +172,7 @@ SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand Down Expand Up @@ -205,7 +202,7 @@ SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand Down Expand Up @@ -235,7 +232,7 @@ SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand Down Expand Up @@ -265,37 +262,37 @@ SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

This package contains the following license and notice below:

The MIT License (MIT)

Copyright (c) 2015-present Dan Abramov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
The MIT License (MIT)
Copyright (c) 2015-present Dan Abramov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand Down Expand Up @@ -325,9 +322,9 @@ SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected].0
- [email protected].1

This package contains the following license and notice below:

Expand Down Expand Up @@ -355,37 +352,37 @@ SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

This package contains the following license and notice below:

The MIT License (MIT)

Copyright (c) 2015-2018 Reselect Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
The MIT License (MIT)
Copyright (c) 2015-2018 Reselect Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand All @@ -395,7 +392,7 @@ This package contains the following license and notice below:

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand Down Expand Up @@ -425,7 +422,7 @@ SOFTWARE.

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand All @@ -446,7 +443,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND

-----------

The following npm package may be included in this product:
The following NPM package may be included in this product:

- [email protected]

Expand Down Expand Up @@ -476,5 +473,4 @@ THE SOFTWARE.

-----------

This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
This file was generated with generate-license-file! https://www.npmjs.com/package/generate-license-file
2 changes: 1 addition & 1 deletion packages/chat-headless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/chat-headless",
"version": "0.7.2",
"version": "0.7.3",
"description": "A state manager library powered by Redux for Yext Chat integrations",
"main": "./dist/commonjs/src/index.js",
"module": "./dist/esm/src/index.mjs",
Expand Down
11 changes: 4 additions & 7 deletions packages/chat-headless/src/ChatHeadlessImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { State } from "./models/state";
import { ReduxStateManager } from "./ReduxStateManager";
import {
loadSessionState,
saveSessionState,
setCanSendMessage,
setConversationId,
setIsLoading,
setMessageNotes,
setMessages,
addMessage,
STATE_SESSION_STORAGE_KEY,
} from "./slices/conversation";
import { DeepPartial, Store, Unsubscribe } from "@reduxjs/toolkit";
import { StateListener } from "./models";
Expand Down Expand Up @@ -102,15 +102,12 @@ export class ChatHeadlessImpl implements ChatHeadless {
initSessionStorage() {
this.setState({
...this.state,
conversation: loadSessionState(),
conversation: loadSessionState(this.config.botId),
});
this.addListener({
valueAccessor: (s) => s.conversation,
callback: () =>
sessionStorage.setItem(
STATE_SESSION_STORAGE_KEY,
JSON.stringify(this.state.conversation)
),
saveSessionState(this.config.botId, this.state.conversation),
});
}

Expand Down Expand Up @@ -170,7 +167,7 @@ export class ChatHeadlessImpl implements ChatHeadless {
setChatLoadingStatus(isLoading: boolean) {
this.stateManager.dispatch(setIsLoading(isLoading));
}

setCanSendMessage(canSendMessage: boolean) {
this.stateManager.dispatch(setCanSendMessage(canSendMessage));
}
Expand Down
Loading

0 comments on commit 5567b65

Please sign in to comment.