mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-28 13:09:18 +08:00
Finish watch backend
This commit is contained in:
parent
59ea3c0413
commit
ee92fb8635
@ -67,6 +67,12 @@ func GetWatches(repoId int64) ([]Watch, error) {
|
|||||||
return watches, err
|
return watches, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsWatching checks if user has watched given repository.
|
||||||
|
func IsWatching(userId, repoId int64) bool {
|
||||||
|
has, _ := orm.Get(&Watch{0, repoId, userId})
|
||||||
|
return has
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gitInitLocker = sync.Mutex{}
|
gitInitLocker = sync.Mutex{}
|
||||||
LanguageIgns, Licenses []string
|
LanguageIgns, Licenses []string
|
||||||
|
@ -31,6 +31,7 @@ type Context struct {
|
|||||||
Repo struct {
|
Repo struct {
|
||||||
IsValid bool
|
IsValid bool
|
||||||
IsOwner bool
|
IsOwner bool
|
||||||
|
IsWatching bool
|
||||||
Repository *models.Repository
|
Repository *models.Repository
|
||||||
Owner *models.User
|
Owner *models.User
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ func RepoAssignment(redirect bool) martini.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.Repo.IsValid = true
|
ctx.Repo.IsValid = true
|
||||||
|
ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id)
|
||||||
ctx.Repo.Repository = repo
|
ctx.Repo.Repository = repo
|
||||||
|
|
||||||
ctx.Data["IsRepositoryValid"] = true
|
ctx.Data["IsRepositoryValid"] = true
|
||||||
|
Loading…
Reference in New Issue
Block a user