ticketOverviewStorage.ts 734 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { useSessionStore } from '#shared/stores/session.ts'
  3. export const getTicketOverviewStorage = () => {
  4. const session = useSessionStore()
  5. const LOCAL_STORAGE_NAME = session.user?.id
  6. ? `ticket-overviews-${session.user.id}`
  7. : null
  8. const getOverviews = (): string[] => {
  9. if (!LOCAL_STORAGE_NAME) return []
  10. return JSON.parse(localStorage.getItem(LOCAL_STORAGE_NAME) || '[]')
  11. }
  12. const saveOverviews = (overviews: string[]) => {
  13. if (!LOCAL_STORAGE_NAME) return
  14. return localStorage.setItem(LOCAL_STORAGE_NAME, JSON.stringify(overviews))
  15. }
  16. return {
  17. getOverviews,
  18. saveOverviews,
  19. LOCAL_STORAGE_NAME,
  20. }
  21. }