Skip to content

Commit

Permalink
refactor: rename hasSemantics state
Browse files Browse the repository at this point in the history
  • Loading branch information
diegopf committed Mar 11, 2024
1 parent 3b261c6 commit d52e0dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/x-components/src/x-modules/tagging/store/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const taggingXStoreModule: TaggingXStoreModule = {
clickedResultStorageTTLMs: null
},
consent: null,
hasSemantics: false,
semanticQueriesModuleRegistered: false,
queryTaggingInfo: null
}),
getters: {},
Expand All @@ -28,9 +28,9 @@ export const taggingXStoreModule: TaggingXStoreModule = {
setQueryTaggingInfo(state, queryTaggingInfo: TaggingRequest) {
state.queryTaggingInfo = queryTaggingInfo;
},
setHasSemantics(state, module) {
setSemanticQueriesModuleRegistered(state, module) {
if (module === 'semanticQueries') {
state.hasSemantics = true;
state.semanticQueriesModuleRegistered = true;
}
},
setConfig,
Expand Down
6 changes: 3 additions & 3 deletions packages/x-components/src/x-modules/tagging/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface TaggingState {
/**
* Value to know if Semantics module is register.
*/
hasSemantics: boolean;
semanticQueriesModuleRegistered: boolean;
/**
* Configuration for the `Tagging` module.
*/
Expand Down Expand Up @@ -53,11 +53,11 @@ export interface TaggingMutations extends ConfigMutations<TaggingState> {
*/
setQueryTaggingInfo(queryTaggingInfo: TaggingRequest): void;
/**
* Sets the hasSemantics property.
* Sets the semanticQueriesModuleRegistered property.
*
* @param module - The name of the register module.
*/
setHasSemantics(module: XModuleName): void;
setSemanticQueriesModuleRegistered(module: XModuleName): void;
}

/**
Expand Down
11 changes: 7 additions & 4 deletions packages/x-components/src/x-modules/tagging/wiring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ const clearSessionWire = filter(
export const setConsent = wireCommit('setConsent');

/**
* Sets the tagging state `hasSemantics`.
* Sets the tagging state `semanticQueriesModuleRegistered`.
*
* @public
*/
export const setHasSemantics = wireCommit('setHasSemantics');
export const setSemanticQueriesModuleRegisteredWire = wireCommit(
'setSemanticQueriesModuleRegistered'
);

/**
* Sets the tagging config state.
Expand All @@ -114,7 +116,8 @@ export const setTaggingConfig = wireCommit('mergeConfig');
export const trackQueryWire = filter(
wireDispatch('track'),
({ eventPayload, store }) =>
(eventPayload as TaggingRequest).params.totalHits > 0 || !store.state.x.tagging.hasSemantics
(eventPayload as TaggingRequest).params.totalHits > 0 ||
!store.state.x.tagging.semanticQueriesModuleRegistered
);

/**
Expand Down Expand Up @@ -325,6 +328,6 @@ export const taggingWiring = createWiring({
trackNoResultsQueryWithSemanticsWireDebounced
},
ModuleRegistered: {
setHasSemantics
setSemanticQueriesModuleRegisteredWire
}
});

0 comments on commit d52e0dc

Please sign in to comment.