@athoscommerce/snap-store-mobx 1.2.3-beta.3 → 1.2.3-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.js +8 -5
- package/dist/cjs/Autocomplete/Stores/AutocompleteFacetStore.js +2 -1
- package/dist/cjs/Chat/ChatStore.d.ts +36 -5
- package/dist/cjs/Chat/ChatStore.d.ts.map +1 -1
- package/dist/cjs/Chat/ChatStore.js +214 -54
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.js +4 -2
- package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts +2 -0
- package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatCompareStore.js +4 -2
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts +10 -7
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatSessionStore.js +34 -23
- package/dist/cjs/Finder/FinderStore.d.ts +1 -1
- package/dist/cjs/Finder/FinderStore.d.ts.map +1 -1
- package/dist/cjs/Finder/FinderStore.js +3 -3
- package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts +1 -1
- package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts.map +1 -1
- package/dist/cjs/ProductQuickView/ProductQuickViewStore.d.ts +21 -0
- package/dist/cjs/ProductQuickView/ProductQuickViewStore.d.ts.map +1 -0
- package/dist/cjs/ProductQuickView/ProductQuickViewStore.js +69 -0
- package/dist/cjs/ProductQuickView/cloneProductForQuickView.d.ts +7 -0
- package/dist/cjs/ProductQuickView/cloneProductForQuickView.d.ts.map +1 -0
- package/dist/cjs/ProductQuickView/cloneProductForQuickView.js +23 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts +2 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/cjs/Recommendation/RecommendationStore.js +3 -0
- package/dist/cjs/Recommendation/Stores/RecommendationProfileStore.js +1 -1
- package/dist/cjs/Search/SearchStore.d.ts +1 -1
- package/dist/cjs/Search/SearchStore.d.ts.map +1 -1
- package/dist/cjs/Search/SearchStore.js +2 -2
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts +1 -1
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SearchFacetStore.js +13 -10
- package/dist/cjs/Search/Stores/SearchHistoryStore.js +2 -2
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +8 -4
- package/dist/cjs/types.d.ts +8 -2
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.js +5 -3
- package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.js +1 -1
- package/dist/esm/Chat/ChatStore.d.ts +36 -5
- package/dist/esm/Chat/ChatStore.d.ts.map +1 -1
- package/dist/esm/Chat/ChatStore.js +201 -43
- package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatAttachmentStore.js +4 -2
- package/dist/esm/Chat/Stores/ChatCompareStore.d.ts +2 -0
- package/dist/esm/Chat/Stores/ChatCompareStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatCompareStore.js +3 -1
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts +10 -7
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatSessionStore.js +26 -18
- package/dist/esm/Finder/FinderStore.d.ts +1 -1
- package/dist/esm/Finder/FinderStore.d.ts.map +1 -1
- package/dist/esm/Finder/FinderStore.js +1 -1
- package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts +1 -1
- package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts.map +1 -1
- package/dist/esm/ProductQuickView/ProductQuickViewStore.d.ts +21 -0
- package/dist/esm/ProductQuickView/ProductQuickViewStore.d.ts.map +1 -0
- package/dist/esm/ProductQuickView/ProductQuickViewStore.js +56 -0
- package/dist/esm/ProductQuickView/cloneProductForQuickView.d.ts +7 -0
- package/dist/esm/ProductQuickView/cloneProductForQuickView.d.ts.map +1 -0
- package/dist/esm/ProductQuickView/cloneProductForQuickView.js +19 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts +2 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/esm/Recommendation/RecommendationStore.js +3 -0
- package/dist/esm/Recommendation/Stores/RecommendationProfileStore.js +1 -1
- package/dist/esm/Search/SearchStore.d.ts +1 -1
- package/dist/esm/Search/SearchStore.d.ts.map +1 -1
- package/dist/esm/Search/SearchStore.js +1 -1
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts +1 -1
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SearchFacetStore.js +13 -10
- package/dist/esm/Search/Stores/SearchHistoryStore.js +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/types.d.ts +8 -2
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +11 -6
- package/dist/cjs/Storage/StorageStore.d.ts +0 -27
- package/dist/cjs/Storage/StorageStore.d.ts.map +0 -1
- package/dist/cjs/Storage/StorageStore.js +0 -176
- package/dist/esm/Storage/StorageStore.d.ts +0 -27
- package/dist/esm/Storage/StorageStore.d.ts.map +0 -1
- package/dist/esm/Storage/StorageStore.js +0 -169
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UrlManager } from '@athoscommerce/snap-url-manager';
|
|
2
|
+
import { StorageStore } from '@athoscommerce/snap-toolbox';
|
|
2
3
|
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
3
4
|
import { SearchFilterStore, SearchResultStore, SearchMerchandisingStore, SearchPaginationStore, SearchSortingStore } from '../Search/Stores';
|
|
4
|
-
import { StorageStore } from '../Storage/StorageStore';
|
|
5
5
|
import { AutocompleteStateStore, AutocompleteTermStore, AutocompleteQueryStore, AutocompleteFacetStore, AutocompleteTrendingStore, AutocompleteHistoryStore } from './Stores';
|
|
6
6
|
import type { AutocompleteResponseModel, MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
7
7
|
import type { TrendingResponseModel } from '@athoscommerce/snap-client';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteStore.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"AutocompleteStore.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,sB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AAG,IAAI;IAiB1D,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,iBAAiB,CAAC;QAAC,MAAM,CAAC,EAAE,yBAAyB,CAAA;KAAE,GAAG,IAAI;CA8G5F"}
|
|
@@ -17,9 +17,9 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.AutocompleteStore = void 0;
|
|
19
19
|
var mobx_1 = require("mobx");
|
|
20
|
+
var snap_toolbox_1 = require("@athoscommerce/snap-toolbox");
|
|
20
21
|
var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
21
22
|
var Stores_1 = require("../Search/Stores");
|
|
22
|
-
var StorageStore_1 = require("../Storage/StorageStore");
|
|
23
23
|
var Stores_2 = require("./Stores");
|
|
24
24
|
var MetaStore_1 = require("../Meta/MetaStore");
|
|
25
25
|
var AutocompleteStore = /** @class */ (function (_super) {
|
|
@@ -34,7 +34,7 @@ var AutocompleteStore = /** @class */ (function (_super) {
|
|
|
34
34
|
_this.state = new Stores_2.AutocompleteStateStore({
|
|
35
35
|
services: _this.services,
|
|
36
36
|
});
|
|
37
|
-
_this.storage = new
|
|
37
|
+
_this.storage = new snap_toolbox_1.StorageStore();
|
|
38
38
|
_this.trending = [];
|
|
39
39
|
_this.history = [];
|
|
40
40
|
_this.initHistory();
|
|
@@ -69,9 +69,9 @@ var AutocompleteStore = /** @class */ (function (_super) {
|
|
|
69
69
|
};
|
|
70
70
|
AutocompleteStore.prototype.initHistory = function () {
|
|
71
71
|
var _this = this;
|
|
72
|
-
var _a, _b;
|
|
72
|
+
var _a, _b, _c, _d;
|
|
73
73
|
var limit = (_b = (_a = this.config.settings) === null || _a === void 0 ? void 0 : _a.history) === null || _b === void 0 ? void 0 : _b.limit;
|
|
74
|
-
if (limit) {
|
|
74
|
+
if (limit && ((_d = (_c = this.config.settings) === null || _c === void 0 ? void 0 : _c.history) === null || _d === void 0 ? void 0 : _d.enabled) !== false) {
|
|
75
75
|
var historyStore = new Stores_1.SearchHistoryStore({
|
|
76
76
|
services: this.services,
|
|
77
77
|
config: {
|
|
@@ -116,11 +116,14 @@ var AutocompleteStore = /** @class */ (function (_super) {
|
|
|
116
116
|
(_a = this.history) === null || _a === void 0 ? void 0 : _a.forEach(function (term) { return (term.active = false); });
|
|
117
117
|
};
|
|
118
118
|
AutocompleteStore.prototype.setService = function (name, service) {
|
|
119
|
+
var _a;
|
|
119
120
|
if (this.services[name] && service) {
|
|
120
121
|
this.services[name] = service;
|
|
121
122
|
if (name === 'urlManager') {
|
|
122
123
|
this.state.url = service;
|
|
123
|
-
this.
|
|
124
|
+
(_a = this.history) === null || _a === void 0 ? void 0 : _a.forEach(function (term) {
|
|
125
|
+
term.url = service.set({ query: term.value });
|
|
126
|
+
});
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
};
|
|
@@ -39,6 +39,7 @@ var AutocompleteFacetStore = /** @class */ (function (_super) {
|
|
|
39
39
|
var _a;
|
|
40
40
|
(_a = facet.values) === null || _a === void 0 ? void 0 : _a.forEach(function (value) {
|
|
41
41
|
value.preview = function () {
|
|
42
|
+
var _a;
|
|
42
43
|
facets.map(function (facet) {
|
|
43
44
|
var _a;
|
|
44
45
|
facet.filtered = false;
|
|
@@ -49,7 +50,7 @@ var AutocompleteFacetStore = /** @class */ (function (_super) {
|
|
|
49
50
|
facet.filtered = true;
|
|
50
51
|
value.filtered = true;
|
|
51
52
|
state === null || state === void 0 ? void 0 : state.autocomplete.locks.facets.lock();
|
|
52
|
-
value.url.go();
|
|
53
|
+
(_a = value.url) === null || _a === void 0 ? void 0 : _a.go();
|
|
53
54
|
};
|
|
54
55
|
});
|
|
55
56
|
});
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { ChatStoreConfig } from '../types';
|
|
1
|
+
import { ChatStoreConfig, StoreServices } from '../types';
|
|
2
2
|
import { MetaStore } from '../Meta/MetaStore';
|
|
3
|
-
import type { MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
3
|
+
import type { MetaResponseModel, SearchResponseModelFacet } from '@athoscommerce/snapi-types';
|
|
4
4
|
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
5
5
|
import type { ChatResponseModel, ChatRequestModel, ProductsResponseModel } from '@athoscommerce/snap-client';
|
|
6
|
-
import {
|
|
6
|
+
import type { UrlManager } from '@athoscommerce/snap-url-manager';
|
|
7
|
+
import { StorageStore } from '@athoscommerce/snap-toolbox';
|
|
7
8
|
import { ChatSessionStore } from './Stores/ChatSessionStore';
|
|
8
9
|
import { ChatStatusResponse } from '@athoscommerce/snap-client';
|
|
9
10
|
import { Product } from '../Search/Stores/SearchResultStore';
|
|
11
|
+
import { SearchFacetStore } from '../Search/Stores/SearchFacetStore';
|
|
10
12
|
export declare class ChatStore extends AbstractStore<ChatStoreConfig> {
|
|
11
13
|
meta?: MetaStore;
|
|
12
14
|
inputValue: string;
|
|
13
15
|
open: boolean;
|
|
14
16
|
storage: StorageStore;
|
|
17
|
+
services: StoreServices;
|
|
18
|
+
/** Detached UrlManager — holds the in-progress facet selection for the active facets display.
|
|
19
|
+
* Detached so .go() updates state without navigating the page. */
|
|
20
|
+
urlManager: UrlManager;
|
|
21
|
+
/** The single facet store rendered in chat — backed by the active message's facets. */
|
|
22
|
+
facets: SearchFacetStore;
|
|
15
23
|
chats: ChatSessionStore[];
|
|
16
24
|
currentChatId: string;
|
|
17
25
|
chatEnabled: boolean | null;
|
|
@@ -23,10 +31,29 @@ export declare class ChatStore extends AbstractStore<ChatStoreConfig> {
|
|
|
23
31
|
productQuickviewError: string | null;
|
|
24
32
|
/** Raw meta kept for lazy hydration of inactive chat sessions. */
|
|
25
33
|
private storedMetaData;
|
|
26
|
-
|
|
34
|
+
/** Tracks which message currently owns the displayed facets — guards against redundant rebuilds. */
|
|
35
|
+
private activeFacetsMessageId;
|
|
36
|
+
/** Bumps on every detached-urlManager change so observers re-evaluate isFacetSelected. */
|
|
37
|
+
urlVersion: number;
|
|
38
|
+
/** Snapshot of the applied filter state captured the last time the active message was seeded.
|
|
39
|
+
* Compared against the live urlManager state to decide whether there are pending changes. */
|
|
40
|
+
private appliedFilterSnapshot;
|
|
41
|
+
constructor(config: ChatStoreConfig, services: StoreServices);
|
|
42
|
+
/** Build a SearchFacetStore from raw facet data using the current detached urlManager.
|
|
43
|
+
* Synthesizes meta entries for each facet so SearchFacetStore's display/meta filter
|
|
44
|
+
* doesn't drop chat facets (the chat backend already decided what to send). */
|
|
45
|
+
private buildFacetStore;
|
|
46
|
+
/** Reset the detached urlManager and seed it with this message's filtered facet values,
|
|
47
|
+
* then rebuild the root SearchFacetStore so the UI shows the matching display. */
|
|
48
|
+
setActiveFacets(facets: SearchResponseModelFacet[], messageId: string | null): void;
|
|
49
|
+
/** True when the in-progress facet selection differs from the filters that were applied
|
|
50
|
+
* by the active productSearchResult — i.e. the user has selected/removed something that
|
|
51
|
+
* hasn't been sent yet. Used to decide whether to show the Apply button. */
|
|
52
|
+
get hasPendingFacetChanges(): boolean;
|
|
27
53
|
get currentChat(): ChatSessionStore | undefined;
|
|
28
54
|
get chatsIds(): string[];
|
|
29
55
|
get blocked(): boolean;
|
|
56
|
+
private applyChatStatusResponse;
|
|
30
57
|
handleChatStatusResponse(response: ChatStatusResponse): boolean;
|
|
31
58
|
reset(): void;
|
|
32
59
|
setProductQuickview(product: Product): void;
|
|
@@ -36,13 +63,17 @@ export declare class ChatStore extends AbstractStore<ChatStoreConfig> {
|
|
|
36
63
|
clearHistory(): void;
|
|
37
64
|
createChat(data?: {
|
|
38
65
|
sessionId: string;
|
|
66
|
+
sessionEndTime?: Date;
|
|
39
67
|
}): ChatSessionStore;
|
|
40
68
|
switchChat(id: string): void;
|
|
41
69
|
sendProductQuery(result: any, options: {
|
|
42
70
|
requestType: 'productQuery' | 'productSimilar' | 'productComparison';
|
|
43
71
|
}): void;
|
|
44
72
|
compareProduct(result: any): void;
|
|
45
|
-
addFacet(facet:
|
|
73
|
+
addFacet(facet: {
|
|
74
|
+
key: string;
|
|
75
|
+
value: string;
|
|
76
|
+
}): void;
|
|
46
77
|
removeFacet(key: string, value: string): void;
|
|
47
78
|
clearPendingFacets(): void;
|
|
48
79
|
isFacetSelected(key: string, value: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatStore.d.ts","sourceRoot":"","sources":["../../../src/Chat/ChatStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatStore.d.ts","sourceRoot":"","sources":["../../../src/Chat/ChatStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC7G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAY,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAIrE,qBAAa,SAAU,SAAQ,aAAa,CAAC,eAAe,CAAC;IACrD,IAAI,CAAC,EAAE,SAAS,CAAa;IAC7B,UAAU,EAAE,MAAM,CAAM;IACxB,IAAI,EAAE,OAAO,CAAS;IACtB,OAAO,EAAE,YAAY,CAAC;I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AAsB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IA8B7D,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/C,qBAAqB,IAAI,IAAI;IAK7B,YAAY,IAAI,IAAI;IAoBpB,UAAU,CAAC,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,IAAI,CAAA;KAAE,GAAG,gBAAgB;IA0BjF,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAa5B,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE;QAAE,WAAW,EAAE,cAAc,GAAG,gBAAgB,GAAG,mBAAmB,CAAA;KAAE,GAAG,IAAI;IAkBtH,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAMjC,QAAQ,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAKrD,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7C,kBAAkB,IAAI,IAAI;IAI1B,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAWpD,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IA6BxC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,IAAI,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI;CAkB/E"}
|
|
@@ -30,13 +30,14 @@ exports.ChatStore = void 0;
|
|
|
30
30
|
var mobx_1 = require("mobx");
|
|
31
31
|
var MetaStore_1 = require("../Meta/MetaStore");
|
|
32
32
|
var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
33
|
-
var
|
|
33
|
+
var snap_toolbox_1 = require("@athoscommerce/snap-toolbox");
|
|
34
34
|
var ChatSessionStore_1 = require("./Stores/ChatSessionStore");
|
|
35
35
|
var SearchResultStore_1 = require("../Search/Stores/SearchResultStore");
|
|
36
|
+
var SearchFacetStore_1 = require("../Search/Stores/SearchFacetStore");
|
|
36
37
|
var CHAT_STATUS_EXPIRATION_TIME = 1000 * 60 * 60 * 12; // 12 hours
|
|
37
38
|
var ChatStore = /** @class */ (function (_super) {
|
|
38
39
|
__extends(ChatStore, _super);
|
|
39
|
-
function ChatStore(config) {
|
|
40
|
+
function ChatStore(config, services) {
|
|
40
41
|
var _this = _super.call(this, config) || this;
|
|
41
42
|
_this.meta = undefined;
|
|
42
43
|
_this.inputValue = '';
|
|
@@ -51,12 +52,25 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
51
52
|
_this.productQuickviewError = null;
|
|
52
53
|
/** Raw meta kept for lazy hydration of inactive chat sessions. */
|
|
53
54
|
_this.storedMetaData = null;
|
|
55
|
+
/** Tracks which message currently owns the displayed facets — guards against redundant rebuilds. */
|
|
56
|
+
_this.activeFacetsMessageId = null;
|
|
57
|
+
/** Bumps on every detached-urlManager change so observers re-evaluate isFacetSelected. */
|
|
58
|
+
_this.urlVersion = 0;
|
|
59
|
+
/** Snapshot of the applied filter state captured the last time the active message was seeded.
|
|
60
|
+
* Compared against the live urlManager state to decide whether there are pending changes. */
|
|
61
|
+
_this.appliedFilterSnapshot = '{}';
|
|
62
|
+
_this.services = services;
|
|
63
|
+
_this.urlManager = services.urlManager.detach(true);
|
|
64
|
+
_this.urlManager.subscribe(function () {
|
|
65
|
+
_this.urlVersion++;
|
|
66
|
+
});
|
|
54
67
|
var legacyKey = "ss-".concat(_this.config.id);
|
|
55
68
|
var storageKey = _this.config.siteId ? "ss-".concat(_this.config.siteId, "-").concat(_this.config.id) : legacyKey;
|
|
56
|
-
_this.storage = new
|
|
69
|
+
_this.storage = new snap_toolbox_1.StorageStore({
|
|
57
70
|
type: 'local',
|
|
58
71
|
key: storageKey,
|
|
59
72
|
});
|
|
73
|
+
_this.facets = _this.buildFacetStore();
|
|
60
74
|
var storedChatStatusResponse = _this.storage.get('chatStatusResponse');
|
|
61
75
|
if (storedChatStatusResponse) {
|
|
62
76
|
try {
|
|
@@ -66,7 +80,10 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
66
80
|
_this.storage.set('chatStatusResponse', null);
|
|
67
81
|
}
|
|
68
82
|
else {
|
|
69
|
-
|
|
83
|
+
// Apply the stored response without persisting, so the 12-hour
|
|
84
|
+
// checkTime keeps counting from the last real API call rather
|
|
85
|
+
// than resetting on every page load.
|
|
86
|
+
_this.applyChatStatusResponse(storedChatStatus.response);
|
|
70
87
|
}
|
|
71
88
|
}
|
|
72
89
|
catch (_a) {
|
|
@@ -137,9 +154,102 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
137
154
|
welcomeMessage: mobx_1.observable,
|
|
138
155
|
productQuickview: mobx_1.observable,
|
|
139
156
|
productQuickviewError: mobx_1.observable,
|
|
157
|
+
facets: mobx_1.observable,
|
|
158
|
+
urlVersion: mobx_1.observable,
|
|
159
|
+
hasPendingFacetChanges: mobx_1.computed,
|
|
140
160
|
});
|
|
161
|
+
// Sync the root facets display with the active message. Only productSearchResult
|
|
162
|
+
// messages carry facets — for any other active message, clear the display so a
|
|
163
|
+
// stale facet bar from a previous response doesn't linger.
|
|
164
|
+
(0, mobx_1.reaction)(function () {
|
|
165
|
+
var _a;
|
|
166
|
+
var active = (_a = _this.currentChat) === null || _a === void 0 ? void 0 : _a.activeMessage;
|
|
167
|
+
return active && active.messageType === 'productSearchResult' ? active : null;
|
|
168
|
+
}, function (active) {
|
|
169
|
+
if (active && active.id !== _this.activeFacetsMessageId) {
|
|
170
|
+
var facets = active.facets;
|
|
171
|
+
_this.setActiveFacets(facets || [], active.id);
|
|
172
|
+
}
|
|
173
|
+
else if (!active && _this.activeFacetsMessageId !== null) {
|
|
174
|
+
_this.setActiveFacets([], null);
|
|
175
|
+
}
|
|
176
|
+
}, { fireImmediately: true });
|
|
141
177
|
return _this;
|
|
142
178
|
}
|
|
179
|
+
/** Build a SearchFacetStore from raw facet data using the current detached urlManager.
|
|
180
|
+
* Synthesizes meta entries for each facet so SearchFacetStore's display/meta filter
|
|
181
|
+
* doesn't drop chat facets (the chat backend already decided what to send). */
|
|
182
|
+
ChatStore.prototype.buildFacetStore = function (facets) {
|
|
183
|
+
var _a;
|
|
184
|
+
if (facets === void 0) { facets = []; }
|
|
185
|
+
var baseMeta = ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.data) || {};
|
|
186
|
+
var baseFacetMeta = baseMeta.facets || {};
|
|
187
|
+
var facetMeta = __assign({}, baseFacetMeta);
|
|
188
|
+
facets.forEach(function (facet) {
|
|
189
|
+
if (!facet.field)
|
|
190
|
+
return;
|
|
191
|
+
var expectedDisplay = facet.type === 'range' ? 'slider' : 'list';
|
|
192
|
+
var existing = facetMeta[facet.field];
|
|
193
|
+
if (!existing || existing.display !== expectedDisplay) {
|
|
194
|
+
facetMeta[facet.field] = __assign(__assign({}, (existing || {})), { field: facet.field, label: facet.label, display: expectedDisplay });
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return new SearchFacetStore_1.SearchFacetStore({
|
|
198
|
+
config: {},
|
|
199
|
+
services: __assign(__assign({}, this.services), { urlManager: this.urlManager }),
|
|
200
|
+
stores: { storage: this.storage },
|
|
201
|
+
data: {
|
|
202
|
+
search: { facets: facets },
|
|
203
|
+
meta: __assign(__assign({}, baseMeta), { facets: facetMeta }),
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
/** Reset the detached urlManager and seed it with this message's filtered facet values,
|
|
208
|
+
* then rebuild the root SearchFacetStore so the UI shows the matching display. */
|
|
209
|
+
ChatStore.prototype.setActiveFacets = function (facets, messageId) {
|
|
210
|
+
var _this = this;
|
|
211
|
+
var _a;
|
|
212
|
+
// reset url state, then seed with the API-reported filtered values
|
|
213
|
+
this.urlManager.reset().go();
|
|
214
|
+
facets.forEach(function (facet) {
|
|
215
|
+
// Slider/range facets carry the active selection on the facet itself rather
|
|
216
|
+
// than on individual bucket values.
|
|
217
|
+
if (facet.type === 'range') {
|
|
218
|
+
var active = facet.active;
|
|
219
|
+
var range = facet.range;
|
|
220
|
+
if (active && range && (active.low !== range.low || active.high !== range.high)) {
|
|
221
|
+
_this.urlManager.set("filter.".concat(facet.field), { low: active.low, high: active.high }).go();
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
var filteredValues = (facet.values || []).filter(function (v) { return v === null || v === void 0 ? void 0 : v.filtered; });
|
|
226
|
+
filteredValues.forEach(function (v) {
|
|
227
|
+
if (typeof v.low !== 'undefined' || typeof v.high !== 'undefined') {
|
|
228
|
+
_this.urlManager.merge("filter.".concat(facet.field), [{ low: v.low, high: v.high }]).go();
|
|
229
|
+
}
|
|
230
|
+
else if (typeof v.value !== 'undefined') {
|
|
231
|
+
_this.urlManager.merge("filter.".concat(facet.field), v.value).go();
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
this.facets = this.buildFacetStore(facets);
|
|
236
|
+
this.activeFacetsMessageId = messageId;
|
|
237
|
+
this.appliedFilterSnapshot = stableStringify((_a = this.urlManager.state) === null || _a === void 0 ? void 0 : _a.filter);
|
|
238
|
+
};
|
|
239
|
+
Object.defineProperty(ChatStore.prototype, "hasPendingFacetChanges", {
|
|
240
|
+
/** True when the in-progress facet selection differs from the filters that were applied
|
|
241
|
+
* by the active productSearchResult — i.e. the user has selected/removed something that
|
|
242
|
+
* hasn't been sent yet. Used to decide whether to show the Apply button. */
|
|
243
|
+
get: function () {
|
|
244
|
+
var _a;
|
|
245
|
+
// touch the version so mobx re-runs this when urlManager state changes
|
|
246
|
+
void this.urlVersion;
|
|
247
|
+
var current = stableStringify((_a = this.urlManager.state) === null || _a === void 0 ? void 0 : _a.filter);
|
|
248
|
+
return current !== this.appliedFilterSnapshot;
|
|
249
|
+
},
|
|
250
|
+
enumerable: false,
|
|
251
|
+
configurable: true
|
|
252
|
+
});
|
|
143
253
|
Object.defineProperty(ChatStore.prototype, "currentChat", {
|
|
144
254
|
get: function () {
|
|
145
255
|
var _this = this;
|
|
@@ -168,16 +278,22 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
168
278
|
enumerable: false,
|
|
169
279
|
configurable: true
|
|
170
280
|
});
|
|
171
|
-
ChatStore.prototype.
|
|
281
|
+
ChatStore.prototype.applyChatStatusResponse = function (response) {
|
|
172
282
|
var chatbot = response.chatbot, features = response.features;
|
|
173
283
|
var status = chatbot.status, suggestedQuestions = chatbot.suggestedQuestions, welcomeMessage = chatbot.welcomeMessage;
|
|
174
284
|
this.chatEnabled = status.enabled === true;
|
|
175
285
|
this.features = features;
|
|
176
286
|
this.suggestedQuestions = suggestedQuestions || [];
|
|
177
287
|
this.welcomeMessage = welcomeMessage || '';
|
|
178
|
-
this.storage.set('chatStatusResponse', JSON.stringify({ response: response, checkTime: Date.now() }));
|
|
179
288
|
return this.chatEnabled;
|
|
180
289
|
};
|
|
290
|
+
ChatStore.prototype.handleChatStatusResponse = function (response) {
|
|
291
|
+
var enabled = this.applyChatStatusResponse(response);
|
|
292
|
+
// Always persist on a real API response — restarts the 12-hour expiration
|
|
293
|
+
// so each new chat session refreshes the cache.
|
|
294
|
+
this.storage.set('chatStatusResponse', JSON.stringify({ response: response, checkTime: Date.now() }));
|
|
295
|
+
return enabled;
|
|
296
|
+
};
|
|
181
297
|
ChatStore.prototype.reset = function () {
|
|
182
298
|
this.chats = [];
|
|
183
299
|
this.clearProductQuickview();
|
|
@@ -185,7 +301,11 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
185
301
|
this.createChat();
|
|
186
302
|
};
|
|
187
303
|
ChatStore.prototype.setProductQuickview = function (product) {
|
|
188
|
-
|
|
304
|
+
var _a;
|
|
305
|
+
// Clone the product so variant selections (and the parent-mappings merge done
|
|
306
|
+
// in updateProductQuickview) only affect the quickview — the carousel and any
|
|
307
|
+
// other surfaces still hold the original instance.
|
|
308
|
+
this.productQuickview = cloneProductForQuickview(product, (_a = this.meta) === null || _a === void 0 ? void 0 : _a.data);
|
|
189
309
|
this.productQuickviewError = null;
|
|
190
310
|
};
|
|
191
311
|
ChatStore.prototype.updateProductQuickview = function (response) {
|
|
@@ -247,6 +367,7 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
247
367
|
var newChat = new ChatSessionStore_1.ChatSessionStore({
|
|
248
368
|
data: {
|
|
249
369
|
sessionId: data === null || data === void 0 ? void 0 : data.sessionId,
|
|
370
|
+
sessionEndTime: data === null || data === void 0 ? void 0 : data.sessionEndTime,
|
|
250
371
|
},
|
|
251
372
|
stores: {
|
|
252
373
|
storage: this.storage,
|
|
@@ -293,64 +414,55 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
293
414
|
});
|
|
294
415
|
};
|
|
295
416
|
ChatStore.prototype.addFacet = function (facet) {
|
|
296
|
-
var
|
|
297
|
-
(
|
|
298
|
-
type: 'facet',
|
|
299
|
-
key: facet.key,
|
|
300
|
-
facetLabel: facet.facetLabel,
|
|
301
|
-
value: facet.value,
|
|
302
|
-
label: facet.label,
|
|
303
|
-
count: facet.count,
|
|
304
|
-
});
|
|
417
|
+
var value = parseFacetValue(facet.value);
|
|
418
|
+
this.urlManager.merge("filter.".concat(facet.key), Array.isArray(value) ? value : value).go();
|
|
305
419
|
};
|
|
306
420
|
ChatStore.prototype.removeFacet = function (key, value) {
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
return item.type === 'facet' &&
|
|
310
|
-
item.key === key &&
|
|
311
|
-
item.value === value &&
|
|
312
|
-
(item.state === 'active' || item.state === 'attached');
|
|
313
|
-
});
|
|
314
|
-
if (facetAttachment) {
|
|
315
|
-
var index = (_b = this.currentChat) === null || _b === void 0 ? void 0 : _b.attachments.items.indexOf(facetAttachment);
|
|
316
|
-
if (index !== undefined && index !== -1) {
|
|
317
|
-
(_c = this.currentChat) === null || _c === void 0 ? void 0 : _c.attachments.items.splice(index, 1);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
421
|
+
var parsed = parseFacetValue(value);
|
|
422
|
+
this.urlManager.remove("filter.".concat(key), parsed).go();
|
|
320
423
|
};
|
|
321
424
|
ChatStore.prototype.clearPendingFacets = function () {
|
|
322
|
-
|
|
323
|
-
var _a;
|
|
324
|
-
var facetAttachments = ((_a = this.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.items.filter(function (item) { return item.type === 'facet' && (item.state === 'active' || item.state === 'attached'); })) || [];
|
|
325
|
-
facetAttachments.forEach(function (item) {
|
|
326
|
-
var _a, _b;
|
|
327
|
-
var index = (_a = _this.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.items.indexOf(item);
|
|
328
|
-
if (index !== undefined && index !== -1) {
|
|
329
|
-
(_b = _this.currentChat) === null || _b === void 0 ? void 0 : _b.attachments.items.splice(index, 1);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
425
|
+
this.urlManager.remove('filter').go();
|
|
332
426
|
};
|
|
333
427
|
ChatStore.prototype.isFacetSelected = function (key, value) {
|
|
334
428
|
var _a;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
429
|
+
// touch the version so mobx re-runs this when urlManager state changes (the
|
|
430
|
+
// underlying UrlManager isn't a mobx observable, so we mirror its updates here)
|
|
431
|
+
void this.urlVersion;
|
|
432
|
+
var filterState = (_a = this.urlManager.state) === null || _a === void 0 ? void 0 : _a.filter;
|
|
433
|
+
if (!filterState || !filterState[key])
|
|
434
|
+
return false;
|
|
435
|
+
var stored = Array.isArray(filterState[key]) ? filterState[key] : [filterState[key]];
|
|
436
|
+
var parsed = parseFacetValue(value);
|
|
437
|
+
return stored.some(function (entry) { return facetValueEquals(entry, parsed); });
|
|
341
438
|
};
|
|
342
439
|
ChatStore.prototype.request = function (request) {
|
|
343
440
|
var _this = this;
|
|
344
|
-
var _a, _b
|
|
345
|
-
|
|
346
|
-
//
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
var
|
|
350
|
-
|
|
351
|
-
|
|
441
|
+
var _a, _b;
|
|
442
|
+
// snapshot facet labels (field + per-value) from the active facets display so the
|
|
443
|
+
// outgoing user message can render "Filter by Color Red" rather than raw keys
|
|
444
|
+
var filterLabels = {};
|
|
445
|
+
var _loop_1 = function (facet) {
|
|
446
|
+
var valueFacet = facet;
|
|
447
|
+
var values = {};
|
|
448
|
+
(valueFacet.values || []).forEach(function (v) {
|
|
449
|
+
var _a, _b;
|
|
450
|
+
if (typeof v.low !== 'undefined' || typeof v.high !== 'undefined') {
|
|
451
|
+
values["".concat((_a = v.low) !== null && _a !== void 0 ? _a : '*', ":").concat((_b = v.high) !== null && _b !== void 0 ? _b : '*')] = v.label;
|
|
452
|
+
}
|
|
453
|
+
else if (typeof v.value !== 'undefined') {
|
|
454
|
+
values[v.value] = v.label;
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
filterLabels[valueFacet.field] = { facetLabel: valueFacet.label || valueFacet.field, values: values };
|
|
458
|
+
};
|
|
459
|
+
for (var _i = 0, _c = this.facets; _i < _c.length; _i++) {
|
|
460
|
+
var facet = _c[_i];
|
|
461
|
+
_loop_1(facet);
|
|
462
|
+
}
|
|
463
|
+
(_a = this.currentChat) === null || _a === void 0 ? void 0 : _a.request(request, filterLabels);
|
|
352
464
|
// remove any productSimilar attachments after request
|
|
353
|
-
var productSimilarAttachments = ((
|
|
465
|
+
var productSimilarAttachments = ((_b = this.currentChat) === null || _b === void 0 ? void 0 : _b.attachments.attached.filter(function (item) { return item.type === 'product' && item.requestType === 'productSimilar'; })) || [];
|
|
354
466
|
productSimilarAttachments.forEach(function (item) {
|
|
355
467
|
var _a;
|
|
356
468
|
(_a = _this.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id);
|
|
@@ -377,3 +489,51 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
377
489
|
return ChatStore;
|
|
378
490
|
}(AbstractStore_1.AbstractStore));
|
|
379
491
|
exports.ChatStore = ChatStore;
|
|
492
|
+
/** Deterministic JSON.stringify — sorts object keys recursively so equality comparisons
|
|
493
|
+
* aren't sensitive to insertion order. */
|
|
494
|
+
function stableStringify(value) {
|
|
495
|
+
if (value === null || value === undefined)
|
|
496
|
+
return 'null';
|
|
497
|
+
if (typeof value !== 'object')
|
|
498
|
+
return JSON.stringify(value);
|
|
499
|
+
if (Array.isArray(value)) {
|
|
500
|
+
return "[".concat(value.map(function (v) { return stableStringify(v); }).join(','), "]");
|
|
501
|
+
}
|
|
502
|
+
var keys = Object.keys(value).sort();
|
|
503
|
+
return "{".concat(keys.map(function (k) { return "".concat(JSON.stringify(k), ":").concat(stableStringify(value[k])); }).join(','), "}");
|
|
504
|
+
}
|
|
505
|
+
/** Convert a chat-facet UI value into the URL-state shape — range buckets arrive as "low:high". */
|
|
506
|
+
function parseFacetValue(value) {
|
|
507
|
+
if (typeof value === 'string' && value.includes(':')) {
|
|
508
|
+
var _a = value.split(':'), low = _a[0], high = _a[1];
|
|
509
|
+
return {
|
|
510
|
+
low: low === '*' ? undefined : Number(low),
|
|
511
|
+
high: high === '*' ? undefined : Number(high),
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
function facetValueEquals(a, b) {
|
|
517
|
+
if (typeof a === 'object' && a !== null && typeof b === 'object' && b !== null) {
|
|
518
|
+
return a.low === b.low && a.high === b.high;
|
|
519
|
+
}
|
|
520
|
+
return a === b;
|
|
521
|
+
}
|
|
522
|
+
/** Build a fresh observable Product from an existing one. Variants are intentionally
|
|
523
|
+
* omitted — `updateProductQuickview` populates them from the products API response. */
|
|
524
|
+
function cloneProductForQuickview(product, meta) {
|
|
525
|
+
var _a, _b, _c;
|
|
526
|
+
var result = {
|
|
527
|
+
id: product.id,
|
|
528
|
+
responseId: product.responseId,
|
|
529
|
+
mappings: JSON.parse(JSON.stringify(product.mappings || {})),
|
|
530
|
+
attributes: JSON.parse(JSON.stringify(product.attributes || {})),
|
|
531
|
+
badges: ((_b = (_a = product.badges) === null || _a === void 0 ? void 0 : _a.all) === null || _b === void 0 ? void 0 : _b.map(function (b) { return ({ tag: b.tag }); })) || [],
|
|
532
|
+
};
|
|
533
|
+
return new SearchResultStore_1.Product({
|
|
534
|
+
config: {},
|
|
535
|
+
data: { result: result, meta: meta || {} },
|
|
536
|
+
position: (_c = product.position) !== null && _c !== void 0 ? _c : 0,
|
|
537
|
+
responseId: product.responseId,
|
|
538
|
+
});
|
|
539
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatAttachmentStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatAttachmentStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatAttachmentStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatAttachmentStore.ts"],"names":[],"mappings":"AAMA,KAAK,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC7E,KAAK,eAAe,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,yBAAyB,GAAG,2BAA2B,GAAG,yBAAyB,CAAC;AAE9H,qBAAa,mBAAmB;IACxB,KAAK,EAAE,eAAe,EAAE,CAAM;;IAUrC,IAAI,QAAQ,sBAEX;IAED,IAAI,QAAQ,4BAKX;IAED,GAAG,CAAC,CAAC,SAAS,eAAe,EAAE,UAAU,EAAE,2BAA2B,GAAG,CAAC;IAgG1E,MAAM,CAAC,EAAE,EAAE,MAAM;IAajB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI5C,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,WAAW,EAAE,2BAA2B,EAAE,GAAG,IAAI;CAezD;AAID,KAAK,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAEzF,uB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QACF,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,eAAe,CAAC;KACxB,KAAG,OAAO,CAAC,IAAI,CAAC,CAUf;CACF"}
|
|
@@ -56,6 +56,7 @@ exports.ChatAttachmentImage = exports.ChatAttachmentFacet = exports.ChatAttachme
|
|
|
56
56
|
// how should localStorage be handled for attachments?
|
|
57
57
|
var uuid_1 = require("uuid");
|
|
58
58
|
var mobx_1 = require("mobx");
|
|
59
|
+
var ChatCompareStore_1 = require("./ChatCompareStore");
|
|
59
60
|
var ChatAttachmentStore = /** @class */ (function () {
|
|
60
61
|
function ChatAttachmentStore() {
|
|
61
62
|
this.items = [];
|
|
@@ -123,9 +124,10 @@ var ChatAttachmentStore = /** @class */ (function () {
|
|
|
123
124
|
existingProductAttachment.requestType = attachment.requestType; // changes existing attachments to the incoming requestType
|
|
124
125
|
return existingProductAttachment;
|
|
125
126
|
}
|
|
126
|
-
//
|
|
127
|
+
// productComparison supports up to CHAT_COMPARISON_MAX products (matches ChatCompareStore.maxItems);
|
|
128
|
+
// trim oldest active/attached product attachments to keep total below the cap.
|
|
127
129
|
var productAttachments = this.items.filter(function (item) { return item.type === 'product' && (item.state === 'active' || item.state === 'attached'); });
|
|
128
|
-
while (productAttachments.length >=
|
|
130
|
+
while (productAttachments.length >= ChatCompareStore_1.CHAT_COMPARISON_MAX) {
|
|
129
131
|
var toRemove = productAttachments.pop();
|
|
130
132
|
if (toRemove) {
|
|
131
133
|
this.remove(toRemove.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatCompareStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatCompareStore.ts"],"names":[],"mappings":"AAEA,qBAAa,gBAAgB;IACrB,KAAK,EAAE,GAAG,EAAE,CAAM;IAClB,cAAc,EAAE,GAAG,EAAE,CAAM;IAC3B,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ChatCompareStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatCompareStore.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,qBAAa,gBAAgB;IACrB,KAAK,EAAE,GAAG,EAAE,CAAM;IAClB,cAAc,EAAE,GAAG,EAAE,CAAM;IAC3B,QAAQ,EAAE,MAAM,CAAuB;;IAa9C,GAAG,CAAC,IAAI,EAAE,GAAG;IAYb,MAAM,CAAC,MAAM,EAAE,MAAM;IAIrB,KAAK;IAIL,cAAc;IAKd,MAAM;IAON,IAAI,QAAQ,UAEX;IAED,IAAI,SAAS,UAEZ;CACD"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChatCompareStore = void 0;
|
|
3
|
+
exports.ChatCompareStore = exports.CHAT_COMPARISON_MAX = void 0;
|
|
4
4
|
var mobx_1 = require("mobx");
|
|
5
|
+
/** Maximum number of products that can be added to a chat comparison. */
|
|
6
|
+
exports.CHAT_COMPARISON_MAX = 4;
|
|
5
7
|
var ChatCompareStore = /** @class */ (function () {
|
|
6
8
|
function ChatCompareStore() {
|
|
7
9
|
this.items = [];
|
|
8
10
|
this.committedItems = [];
|
|
9
|
-
this.maxItems =
|
|
11
|
+
this.maxItems = exports.CHAT_COMPARISON_MAX;
|
|
10
12
|
(0, mobx_1.makeObservable)(this, {
|
|
11
13
|
items: mobx_1.observable,
|
|
12
14
|
committedItems: mobx_1.observable,
|