MCPcopy Create free account
hub / github.com/ChatGPTBox-dev/chatGPTBox / createSession

Function createSession

src/services/local-session.mjs:17–34  ·  view source on GitHub ↗
(newSession)

Source from the content-addressed store, hash-verified

15}
16
17export const createSession = async (newSession) => {
18 let currentSessions
19 if (newSession) {
20 const ret = await getSession(newSession.sessionId)
21 currentSessions = ret.currentSessions
22 if (ret.session)
23 currentSessions[
24 currentSessions.findIndex((session) => session.sessionId === newSession.sessionId)
25 ] = newSession
26 else currentSessions.unshift(newSession)
27 } else {
28 newSession = await initDefaultSession()
29 currentSessions = await getSessions()
30 currentSessions.unshift(newSession)
31 }
32 await Browser.storage.local.set({ sessions: currentSessions })
33 return { session: newSession, currentSessions }
34}
35
36export const deleteSession = async (sessionId) => {
37 const currentSessions = await getSessions()

Callers 2

ConversationCardFunction · 0.90
createNewChatFunction · 0.90

Calls 3

getSessionFunction · 0.85
initDefaultSessionFunction · 0.85
getSessionsFunction · 0.85

Tested by

no test coverage detected