From f66b505d1a8a058c1ca86a1a0714bce7d642fa26 Mon Sep 17 00:00:00 2001 From: James Mills Date: Sat, 2 Apr 2022 22:27:05 +0000 Subject: [PATCH] Fix GetState() (#129) Should return `-1` if no state is found. Co-authored-by: James Mills Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/129 --- internal/web/app.wasm | 4 ++-- state.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/web/app.wasm b/internal/web/app.wasm index 5fbb1c9..c191bc8 100755 --- a/internal/web/app.wasm +++ b/internal/web/app.wasm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dd33c8166e24934aa8fb5e75d47fae78adfe88acb6596df56fe8f5b078900b9e -size 28571927 +oid sha256:4f36963d6c7744e1a470336f6b0ed62360d43baa4451672e6e2cdce4b6333507 +size 28571892 diff --git a/state.go b/state.go index e79e9d2..d4ae2c1 100644 --- a/state.go +++ b/state.go @@ -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) {