Skip to content

Commit

Permalink
Export messages constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperengstrom committed Dec 17, 2024
1 parent 56e2489 commit 39d57bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 0 additions & 1 deletion packages/codemirror-lang-lxlquery/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const lxlQueryLanguage = LRLanguage.define({
});

const highlighter = tagHighlighter([
// adding qualifier classes handled by sypersearch/lxlQualifier plugin
{ tag: tags.BooleanQuery, class: 'lxl-boolean-query' },
{ tag: tags.Wildcard, class: 'lxl-wildcard' },
{ tag: tags.Qualifier, class: 'lxl-qualifier' },
Expand Down
17 changes: 9 additions & 8 deletions packages/supersearch/src/lib/components/SuperSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import submitFormOnEnterKey from '$lib/extensions/submitFormOnEnterKey.js';
import preventNewLine from '$lib/extensions/preventNewLine.js';
import useSearchRequest from '$lib/utils/useSearchRequest.svelte.js';
import { messages } from '$lib/constants/messages.js';
import type {
QueryFunction,
PaginationQueryFunction,
Expand Down Expand Up @@ -57,19 +58,19 @@
transformFn
});
const sendMessage = StateEffect.define<{ message: string }>({});
const newDataMessage = { effects: sendMessage.of({ message: messages.NEW_DATA }) };
$effect(() => {
if (value) {
search.debouncedFetchData(value);
if (search.data) {
expandedEditorView?.dispatch(newDataMessage);
collapsedEditorView?.dispatch(newDataMessage);
}
});
const searchStatus = StateEffect.define<{ message: string }>({});
$effect(() => {
if (search.data) {
const effects = { effects: searchStatus.of({ message: 'new_data' }) };
expandedEditorView?.dispatch(effects);
collapsedEditorView?.dispatch(effects);
if (value) {
search.debouncedFetchData(value);
}
});
Expand Down
3 changes: 3 additions & 0 deletions packages/supersearch/src/lib/constants/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const messages = {
NEW_DATA: 'new_response_data'
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { syntaxTree } from '@codemirror/language';
import { mount } from 'svelte';
import QualifierComponent from './QualifierComponent.svelte';
import insertQuotes from './insertQuotes.js';
import { messages } from '$lib/constants/messages.js';

export type Qualifier = {
key: string;
Expand Down Expand Up @@ -153,7 +154,7 @@ function lxlQualifierPlugin(getLabelFn?: GetLabelFunction) {
} else {
for (const tr of update.transactions) {
for (const e of tr.effects) {
if (e.value.message === 'new_data') {
if (e.value.message === messages.NEW_DATA) {
this.qualifiers = getQualifiers(update.view);
}
}
Expand Down

0 comments on commit 39d57bb

Please sign in to comment.