chat and message date data, begin chat sort opts.
This commit is contained in:
parent
86092afcb0
commit
8835ee1d6e
|
@ -115,6 +115,10 @@
|
||||||
|
|
||||||
chatRequest = new ChatRequest()
|
chatRequest = new ChatRequest()
|
||||||
chatRequest.setChat(chat)
|
chatRequest.setChat(chat)
|
||||||
|
|
||||||
|
chat.lastAccess = Date.now()
|
||||||
|
saveChatStore()
|
||||||
|
|
||||||
// Focus the input on mount
|
// Focus the input on mount
|
||||||
focusInput()
|
focusInput()
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,15 @@ export const imageGenerationSizes = [
|
||||||
|
|
||||||
export const imageGenerationSizeTypes = ['', ...imageGenerationSizes]
|
export const imageGenerationSizeTypes = ['', ...imageGenerationSizes]
|
||||||
|
|
||||||
|
export const chatSortOptions = [
|
||||||
|
{ value: 'name', text: 'Name' },
|
||||||
|
{ value: 'created', text: 'Created' },
|
||||||
|
{ value: 'updated', text: 'Last Use' },
|
||||||
|
{ value: 'lastAccess', text: 'Last View' }
|
||||||
|
]
|
||||||
|
|
||||||
|
export const chatSortOptionsKeys = chatSortOptions.map(o => o.value, [] as string[])
|
||||||
|
|
||||||
const profileSetting: ChatSetting & SettingSelect = {
|
const profileSetting: ChatSetting & SettingSelect = {
|
||||||
key: 'profile',
|
key: 'profile',
|
||||||
name: 'Profile',
|
name: 'Profile',
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import { clickOutside } from 'svelte-use-click-outside'
|
import { clickOutside } from 'svelte-use-click-outside'
|
||||||
import { startNewChatWithWarning } from './Util.svelte'
|
import { startNewChatWithWarning } from './Util.svelte'
|
||||||
|
|
||||||
$: sortedChats = $chatsStorage.sort((a, b) => b.id - a.id)
|
$: sortedChats = $chatsStorage.sort((a, b) => ((b.created || 0) - (a.created || 0)) || (b.id - a.id))
|
||||||
$: activeChatId = $params && $params.chatId ? parseInt($params.chatId) : undefined
|
$: activeChatId = $params && $params.chatId ? parseInt($params.chatId) : undefined
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -52,7 +52,10 @@
|
||||||
messages: [],
|
messages: [],
|
||||||
usage: {} as Record<Model, Usage>,
|
usage: {} as Record<Model, Usage>,
|
||||||
startSession: false,
|
startSession: false,
|
||||||
sessionStarted: false
|
sessionStarted: false,
|
||||||
|
created: Date.now(),
|
||||||
|
updated: Date.now(),
|
||||||
|
lastAccess: Date.now()
|
||||||
})
|
})
|
||||||
chatsStorage.set(chats)
|
chatsStorage.set(chats)
|
||||||
// Apply defaults and prepare it to start
|
// Apply defaults and prepare it to start
|
||||||
|
@ -79,6 +82,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.id = chatId
|
chat.id = chatId
|
||||||
|
chat.created = Date.now()
|
||||||
|
|
||||||
// Make sure images are moved to indexedDB store,
|
// Make sure images are moved to indexedDB store,
|
||||||
// else they would clobber local storage
|
// else they would clobber local storage
|
||||||
|
@ -252,7 +256,9 @@
|
||||||
}, 200)
|
}, 200)
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(setMessagesTimers[chatId])
|
clearTimeout(setMessagesTimers[chatId])
|
||||||
getChat(chatId).messages = messages
|
const chat = getChat(chatId)
|
||||||
|
chat.updated = Date.now()
|
||||||
|
chat.messages = messages
|
||||||
saveChatStore()
|
saveChatStore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,6 +274,7 @@
|
||||||
export const addMessage = (chatId: number, message: Message) => {
|
export const addMessage = (chatId: number, message: Message) => {
|
||||||
const messages = getMessages(chatId)
|
const messages = getMessages(chatId)
|
||||||
if (!message.uuid) message.uuid = uuidv4()
|
if (!message.uuid) message.uuid = uuidv4()
|
||||||
|
if (!message.created) message.created = Date.now()
|
||||||
if (messages.indexOf(message) < 0) {
|
if (messages.indexOf(message) < 0) {
|
||||||
// Don't have message, add it
|
// Don't have message, add it
|
||||||
messages[messages.length] = message
|
messages[messages.length] = message
|
||||||
|
@ -286,7 +293,10 @@
|
||||||
console.error("Couldn't insert after message:", insertAfter)
|
console.error("Couldn't insert after message:", insertAfter)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newMessages.forEach(m => { m.uuid = m.uuid || uuidv4() })
|
newMessages.forEach(m => {
|
||||||
|
m.uuid = m.uuid || uuidv4()
|
||||||
|
m.created = m.created || Date.now()
|
||||||
|
})
|
||||||
messages.splice(index + 1, 0, ...newMessages)
|
messages.splice(index + 1, 0, ...newMessages)
|
||||||
setMessages(chatId, messages.filter(m => true))
|
setMessages(chatId, messages.filter(m => true))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<script context="module" lang="ts">
|
<script context="module" lang="ts">
|
||||||
import { supportedModelKeys } from './Models.svelte'
|
import { supportedModelKeys } from './Models.svelte'
|
||||||
import { imageGenerationSizeTypes } from './Settings.svelte'
|
import { chatSortOptionsKeys, imageGenerationSizeTypes } from './Settings.svelte'
|
||||||
|
|
||||||
export type Model = typeof supportedModelKeys[number];
|
export type Model = typeof supportedModelKeys[number];
|
||||||
|
|
||||||
export type ImageGenerationSizes = typeof imageGenerationSizeTypes[number];
|
export type ImageGenerationSizes = typeof imageGenerationSizeTypes[number];
|
||||||
|
|
||||||
|
export type ChatSortTypes = typeof chatSortOptionsKeys[number];
|
||||||
|
|
||||||
export type ModelDetail = {
|
export type ModelDetail = {
|
||||||
prompt: number;
|
prompt: number;
|
||||||
completion: number;
|
completion: number;
|
||||||
|
@ -37,6 +39,7 @@
|
||||||
finish_reason?: string;
|
finish_reason?: string;
|
||||||
streaming?: boolean;
|
streaming?: boolean;
|
||||||
image?: ChatImage;
|
image?: ChatImage;
|
||||||
|
created?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResponseAlteration = {
|
export type ResponseAlteration = {
|
||||||
|
@ -109,6 +112,9 @@
|
||||||
settings: ChatSettings;
|
settings: ChatSettings;
|
||||||
startSession: boolean;
|
startSession: boolean;
|
||||||
sessionStarted: boolean;
|
sessionStarted: boolean;
|
||||||
|
created: number;
|
||||||
|
updated: number;
|
||||||
|
lastAccess: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ResponseOK = {
|
type ResponseOK = {
|
||||||
|
@ -159,6 +165,7 @@
|
||||||
lastProfile?: string;
|
lastProfile?: string;
|
||||||
defaultProfile?: string;
|
defaultProfile?: string;
|
||||||
hideSummarized?: boolean;
|
hideSummarized?: boolean;
|
||||||
|
chatSort: keyof ChatSortTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SettingNumber = {
|
type SettingNumber = {
|
||||||
|
|
Loading…
Reference in New Issue