1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 18:20:33 +09:00

unsplash pkg fixes

This commit is contained in:
Roman Khafizianov 2022-01-27 14:05:01 +01:00
parent f70b1b17c5
commit 3ded18c66a
No known key found for this signature in database
GPG key ID: F07A7D55A2684852
2 changed files with 4 additions and 3 deletions

View file

@ -46,7 +46,6 @@ import (
"github.com/anytypeio/go-anytype-middleware/util/linkpreview"
"github.com/anytypeio/go-anytype-middleware/util/ocache"
"github.com/anytypeio/go-anytype-middleware/util/pbtypes"
"github.com/anytypeio/go-anytype-middleware/util/unsplash"
)
const (
@ -252,7 +251,6 @@ type service struct {
sendEvent func(event *pb.Event)
closed bool
linkPreview linkpreview.LinkPreview
unsplash unsplash.Unsplash
process process.Service
doc doc.Service
app *app.App
@ -270,7 +268,6 @@ func (s *service) Init(a *app.App) (err error) {
s.anytype = a.MustComponent(core.CName).(core.Service)
s.status = a.MustComponent(status.CName).(status.Service)
s.linkPreview = a.MustComponent(linkpreview.CName).(linkpreview.LinkPreview)
s.unsplash = a.MustComponent(unsplash.CName).(unsplash.Unsplash)
s.process = a.MustComponent(process.CName).(process.Service)
s.sendEvent = a.MustComponent(event.CName).(event.Sender).Send
s.source = a.MustComponent(source.CName).(source.Service)

View file

@ -18,6 +18,7 @@ import (
"path/filepath"
"regexp"
"strings"
"sync"
"time"
)
@ -36,6 +37,7 @@ type Unsplash interface {
}
type unsplashService struct {
mu sync.Mutex
cache ocache.OCache
client *unsplash.Unsplash
limit int
@ -110,6 +112,8 @@ func newFromPhoto(v unsplash.Photo) (Result, error) {
}
func (l *unsplashService) lazyInitClient() {
l.mu.Lock()
defer l.mu.Unlock()
if l.client != nil {
return
}