feat(gallery): image detail view
This commit is contained in:
1 parent
bca93f6c6c
commit
c62153ecf6
5 files changed
+96
-53
No files matched your search
@@ -129,7 +129,7 @@ func (s *Service) GetImages(ctx context.Context) (images []Image, err error) {
|
||||
func (s *Service) GetPrevAndNext(ctx context.Context, uid string) (previous *Image, next *Image, err error) {
|
||||
imgs, err := s.GetImages(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
for i := range imgs {
|
||||
@@ -137,20 +137,20 @@ func (s *Service) GetPrevAndNext(ctx context.Context, uid string) (previous *Ima
|
||||
continue
|
||||
}
|
||||
|
||||
if i-1 >= 0 {
|
||||
previous = &imgs[i-1]
|
||||
if i > 0 {
|
||||
prevImg := imgs[i-1]
|
||||
previous = &prevImg
|
||||
}
|
||||
if i+1 >= len(imgs) {
|
||||
next = &imgs[i+1]
|
||||
if i+1 < len(imgs) {
|
||||
nextImg := imgs[i+1]
|
||||
next = &nextImg
|
||||
}
|
||||
|
||||
return
|
||||
return previous, next, nil
|
||||
}
|
||||
|
||||
err = &rest.Error{
|
||||
return nil, nil, &rest.Error{
|
||||
Type: rest.ErrorTypeNotFound,
|
||||
Message: "could not find image with uid",
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in new issue
Block a user