(newSession)
| 15 | } |
| 16 | |
| 17 | export 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 | |
| 36 | export const deleteSession = async (sessionId) => { |
| 37 | const currentSessions = await getSessions() |
no test coverage detected