aboutsummaryrefslogtreecommitdiffstats
path: root/cache/identity_cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'cache/identity_cache.go')
-rw-r--r--cache/identity_cache.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/cache/identity_cache.go b/cache/identity_cache.go
index 3b7bb818..a6c929ad 100644
--- a/cache/identity_cache.go
+++ b/cache/identity_cache.go
@@ -2,6 +2,7 @@ package cache
import (
"github.com/MichaelMure/git-bug/entities/identity"
+ "github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/repository"
)
@@ -9,19 +10,22 @@ var _ identity.Interface = &IdentityCache{}
// IdentityCache is a wrapper around an Identity for caching.
type IdentityCache struct {
+ entityUpdated func(id entity.Id) error
+ repo repository.ClockedRepo
+
*identity.Identity
- repoCache *RepoCache
}
-func NewIdentityCache(repoCache *RepoCache, id *identity.Identity) *IdentityCache {
+func NewIdentityCache(subcache *RepoCacheIdentity, id *identity.Identity) *IdentityCache {
return &IdentityCache{
- Identity: id,
- repoCache: repoCache,
+ entityUpdated: subcache.entityUpdated,
+ repo: subcache.repo,
+ Identity: id,
}
}
func (i *IdentityCache) notifyUpdated() error {
- return i.repoCache.identityUpdated(i.Identity.Id())
+ return i.entityUpdated(i.Identity.Id())
}
func (i *IdentityCache) Mutate(repo repository.RepoClock, f func(*identity.Mutator)) error {
@@ -33,7 +37,7 @@ func (i *IdentityCache) Mutate(repo repository.RepoClock, f func(*identity.Mutat
}
func (i *IdentityCache) Commit() error {
- err := i.Identity.Commit(i.repoCache.repo)
+ err := i.Identity.Commit(i.repo)
if err != nil {
return err
}
@@ -41,7 +45,7 @@ func (i *IdentityCache) Commit() error {
}
func (i *IdentityCache) CommitAsNeeded() error {
- err := i.Identity.CommitAsNeeded(i.repoCache.repo)
+ err := i.Identity.CommitAsNeeded(i.repo)
if err != nil {
return err
}