feat(share): Add history title to share modal
Adds the title of the current chat history to the share modal. This makes it easier for users to share their conversations with others, as the title provides context for the conversation. The title is fetched from the database and displayed in the share modal.
This commit is contained in:
@@ -81,6 +81,12 @@ export class PageAssitDatabase {
|
||||
})
|
||||
}
|
||||
|
||||
async getChatHistoryTitleById(id: string): Promise<string> {
|
||||
const chatHistories = await this.getChatHistories()
|
||||
const chatHistory = chatHistories.find((history) => history.id === id)
|
||||
return chatHistory?.title || ""
|
||||
}
|
||||
|
||||
async addChatHistory(history: HistoryInfo) {
|
||||
const chatHistories = await this.getChatHistories()
|
||||
const newChatHistories = [history, ...chatHistories]
|
||||
@@ -482,4 +488,11 @@ export const getRecentChatFromCopilot = async () => {
|
||||
const messages = await db.getChatHistory(history.id)
|
||||
|
||||
return { history, messages }
|
||||
}
|
||||
|
||||
|
||||
export const getTitleById = async (id: string) => {
|
||||
const db = new PageAssitDatabase()
|
||||
const title = await db.getChatHistoryTitleById(id)
|
||||
return title
|
||||
}
|
||||
Reference in New Issue
Block a user