dmitri.shuralyov.com/app/changes

Add support for leaving reactions on change comments.

Regenerate.

Follows https://dmitri.shuralyov.com/service/change/...$commit/5f99232c79a97ad039852df6993da46e9cff24d2.
dmitshur committed 6 years ago commit 03e5f6220bfd3d71ec69ee2bd4ff0dbd68efdd4a
Showing partial commit. Full Commit
Collapse all
display.go
@@ -49,11 +49,11 @@ func (i timelineItem) CreatedAt() time.Time {
	default:
		panic(fmt.Errorf("unknown item type %T", i))
	}
}

func (i timelineItem) ID() uint64 {
func (i timelineItem) ID() string {
	switch i := i.TimelineItem.(type) {
	case change.Comment:
		return i.ID
	case change.Review:
		return i.ID
main.go
@@ -57,10 +57,16 @@ import (
// 	http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
// 		req = req.WithContext(context.WithValue(req.Context(), changes.RepoSpecContextKey, string(...)))
// 		req = req.WithContext(context.WithValue(req.Context(), changes.BaseURIContextKey, string(...)))
// 		changesApp.ServeHTTP(w, req)
// 	})
//
// An HTTP API must be available (currently, only EditComment endpoint is used):
//
// 	// Register HTTP API endpoints.
// 	apiHandler := httphandler.Change{Change: service}
// 	http.Handle(httproute.EditComment, errorHandler(apiHandler.EditComment))
func New(service change.Service, users users.Service, opt Options) http.Handler {
	static, err := loadTemplates(common.State{}, opt.BodyPre)
	if err != nil {
		log.Fatalln("loadTemplates failed:", err)
	}
@@ -312,11 +318,11 @@ func (h *handler) MockHandler(w http.ResponseWriter, req *http.Request) error {
		state
		Review change.Review
	}{
		state: st,
		Review: change.Review{
			ID:        0,
			ID:        "0",
			User:      users.User{Login: "Eric Grosse", AvatarURL: "https://lh6.googleusercontent.com/-_sdEtv2PRxk/AAAAAAAAAAI/AAAAAAAAAAA/aE1Q66Cuvb4/s100-p/photo.jpg"},
			CreatedAt: time.Now().UTC(),
			Edited:    nil,
			State:     change.Approved,
			Body:      "",
@@ -590,12 +596,12 @@ func loadTemplates(state common.State, bodyPre string) (*template.Template, erro
		"gfm":              func(s string) template.HTML { return template.HTML(github_flavored_markdown.Markdown([]byte(s))) },
		"reactionPosition": func(emojiID reactions.EmojiID) string { return reactions.Position(":" + string(emojiID) + ":") },
		"equalUsers": func(a, b users.User) bool {
			return a.UserSpec == b.UserSpec
		},
		"reactableID": func(commentID uint64) string {
			return fmt.Sprintf("%d/%d", state.ChangeID, commentID)
		"reactableID": func(commentID string) string {
			return fmt.Sprintf("%d/%s", state.ChangeID, commentID)
		},
		"reactionsBar": func(reactions []reactions.Reaction, reactableID string) htmlg.Component {
			return reactionscomponent.ReactionsBar{
				Reactions:   reactions,
				CurrentUser: state.CurrentUser,