6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-24 07:48:19 +00:00

Fix GetState() (#129)

Should return `-1` if no state is found.

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/129
This commit is contained in:
James Mills 2022-04-02 22:27:05 +00:00
parent 01b1408e62
commit f66b505d1a
2 changed files with 7 additions and 3 deletions

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dd33c8166e24934aa8fb5e75d47fae78adfe88acb6596df56fe8f5b078900b9e
size 28571927
oid sha256:4f36963d6c7744e1a470336f6b0ed62360d43baa4451672e6e2cdce4b6333507
size 28571892

@ -30,7 +30,11 @@ func (s *State) GetIndex(name string) int {
s.RLock()
defer s.RUnlock()
return s.Indicies[name]
index, ok := s.Indicies[name]
if !ok {
return -1 // -1 is a special value meaning start from the beginning
}
return index
}
func (s *State) SetIndex(name string, index int) {