Skip to content

Commit 2429df9

Browse files
authored
Merge pull request #86 from iceljc/features/refine-chat-window
refine conversation search
2 parents f37c86e + 16ee0f9 commit 2429df9

6 files changed

Lines changed: 162 additions & 56 deletions

File tree

src/lib/common/StateModal.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,19 @@
122122
<div class="state-input">
123123
<FormGroup>
124124
{#if idx === 0}
125-
<label for="key">Key</label>
125+
<label for="key">
126+
{`Key ${validateKey ? '(Required)' : '(Optional)'}`}
127+
</label>
126128
{/if}
127129
<Input class={`${!state.key.isValid ? 'invalid' : ''}`} placeholder="Enter a key" value={state.key.data} maxlength={50} on:input={(e) => changeKey(e, idx)} />
128130
</FormGroup>
129131
</div>
130132
<div class="state-input">
131133
<FormGroup>
132134
{#if idx === 0}
133-
<label for="value">Value</label>
135+
<label for="value">
136+
{`Value ${validateValue ? '(Required)' : '(Optional)'}`}
137+
</label>
134138
{/if}
135139
<Input class={`${!state.value.isValid ? 'invalid' : ''}`} placeholder="Enter a value" value={state.value.data} maxlength={1000} on:input={(e) => changeValue(e, idx)} />
136140
</FormGroup>

src/lib/helpers/store.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { browser } from '$app/environment';
44

55
const conversationKey = "conversation";
66
const conversationUserStatesKey = "conversation_user_states";
7-
const conversationSearchStatesKey = "conversation_search_states";
7+
const conversationSearchOptionKey = "conversation_search_option";
88
const conversationUserMessageKey = "conversation_user_messages";
99

1010
/** @type {Writable<import('$types').UserModel>} */
@@ -95,22 +95,22 @@ const createConversationUserStateStore = () => {
9595

9696
export const conversationUserStateStore = createConversationUserStateStore();
9797

98-
const createConversationSearchStateStore = () => {
98+
const createConversationSearchOptionStore = () => {
9999
return {
100100
reset: () => {
101-
localStorage.removeItem(conversationSearchStatesKey);
101+
localStorage.removeItem(conversationSearchOptionKey);
102102
},
103103
get: () => {
104-
const json = localStorage.getItem(conversationSearchStatesKey);
105-
return json ? JSON.parse(json) : [];
104+
const json = localStorage.getItem(conversationSearchOptionKey);
105+
return json ? JSON.parse(json) : {};
106106
},
107107
put: (value) => {
108-
localStorage.setItem(conversationSearchStatesKey, JSON.stringify(value));
108+
localStorage.setItem(conversationSearchOptionKey, JSON.stringify(value));
109109
}
110110
}
111111
};
112112

113-
export const conversationSearchStateStore = createConversationSearchStateStore();
113+
export const conversationSearchOptionStore = createConversationSearchOptionStore();
114114

115115

116116
const createConversationUserMessageStore = () => {

src/lib/helpers/types.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
* @property {string} value - The value.
3030
*/
3131

32+
/**
33+
* @typedef {Object} IdName
34+
* @property {string} id - The id.
35+
* @property {string} name - The name.
36+
*/
37+
3238
/**
3339
* @template T
3440
* @typedef {Object} PagedItems<T>
@@ -181,10 +187,10 @@
181187
/**
182188
* @typedef {Object} ConversationFilter
183189
* @property {Pagination} pager - Pagination
184-
* @property {string} [agentId] - The agent id.
185-
* @property {string} [channel] - The conversation channel.
186-
* @property {string} [status] - The conversation status.
187-
* @property {string} [taskId] - The task id.
190+
* @property {string?} [agentId] - The agent id.
191+
* @property {string?} [channel] - The conversation channel.
192+
* @property {string?} [status] - The conversation status.
193+
* @property {string?} [taskId] - The task id.
188194
* @property {KeyValuePair[]} [states] - The conversation status.
189195
*/
190196

src/routes/(authentication)/login/+page.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
PUBLIC_ALLOW_SIGNUP
3030
} from '$env/static/public';
3131
import { onMount } from 'svelte';
32+
import {
33+
conversationSearchOptionStore,
34+
conversationUserMessageStore,
35+
conversationUserStateStore
36+
} from '$lib/helpers/store';
3237
3338
let username = PUBLIC_ADMIN_USERNAME;
3439
let password = PUBLIC_ADMIN_PASSWORD;
@@ -67,6 +72,7 @@
6772
goto('page/dashboard');
6873
}
6974
isSubmitting = false;
75+
resetStorage();
7076
});
7177
isSubmitting = false;
7278
}
@@ -83,6 +89,12 @@
8389
icon.className = 'mdi mdi-eye-outline';
8490
}
8591
}
92+
93+
function resetStorage() {
94+
conversationUserStateStore.reset();
95+
conversationSearchOptionStore.reset();
96+
conversationUserMessageStore.reset();
97+
}
8698
</script>
8799

88100
<Headtitle title="Login" />

src/routes/page/agent/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
};
7878
7979
filter = {
80-
...filter,
80+
...filter,
8181
pager: pager
8282
};
8383

0 commit comments

Comments
 (0)