Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(store): make sure serialization contains hl tags
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrutjes committed Jul 21, 2017
1 parent 1606b98 commit 4e8a7de
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ export class Store {
// without trigger multiple queries.
this._stoppedCounter = 1;

this.algoliaHelper = helper;
this._highlightPreTag = '<em>';
this._highlightPostTag = '</em>';

this.algoliaHelper = helper;
}

set algoliaHelper(helper) {
Expand All @@ -72,7 +73,7 @@ export class Store {
this._helper.setPage(page);

if (this._helper.lastResults) {
onHelperResult(this._helper.lastResults);
onHelperResult.apply(this, [this._helper.lastResults]);
} else {
this._results = [];
}
Expand Down Expand Up @@ -362,7 +363,11 @@ export class Store {
}

serialize() {
return serializeHelper(this._helper);
return {
helper: serializeHelper(this._helper),
highlightPreTag: this.highlightPreTag,
highlightPostTag: this.highlightPostTag,
};
}

// Todo: find a better name for this function.
Expand Down Expand Up @@ -405,7 +410,11 @@ export const createFromAlgoliaClient = client => {
};

export const createFromSerialized = data => {
const helper = unserializeHelper(data);
const helper = unserializeHelper(data.helper);

return new Store(helper);
const store = new Store(helper);
store.highlightPreTag = data.highlightPreTag;
store.highlightPostTag = data.highlightPostTag;

return store;
};

0 comments on commit 4e8a7de

Please sign in to comment.