package svc

import (
	"sync"

	"juwan-backend/app/chat/rpc/pb"
)

type ChatStore struct {
	Mu sync.RWMutex

	nextSessionID int64
	nextMessageID int64

	Sessions        map[int64]*pb.ChatSessions
	Messages        map[int64]*pb.ChatMessages
	SessionMessages map[int64][]int64
}

func NewChatStore() *ChatStore {
	return &ChatStore{
		nextSessionID:   1000,
		nextMessageID:   1000,
		Sessions:        make(map[int64]*pb.ChatSessions),
		Messages:        make(map[int64]*pb.ChatMessages),
		SessionMessages: make(map[int64][]int64),
	}
}

func (s *ChatStore) NextSession() int64 {
	s.nextSessionID++
	return s.nextSessionID
}

func (s *ChatStore) NextMessage() int64 {
	s.nextMessageID++
	return s.nextMessageID
}
