Skip to content

Commit

Permalink
hotfix new post/poll adding
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Sep 6, 2024
1 parent 29f008a commit f2b44c5
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions pkg/frontend/post.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package frontend

import (
"log"
"encoding/json"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -229,8 +229,8 @@ func (c *postContent) onClick(ctx app.Context, e app.Event) {
payload = poll
}

response := struct{
Code int `json:"code"`
response := struct {
Code int `json:"code"`
Message string `json:"message"`
}{}

Expand All @@ -241,20 +241,20 @@ func (c *postContent) onClick(ctx app.Context, e app.Event) {
ctx.Dispatch(func(ctx app.Context) {
c.toastText = toastText
c.toastShow = (toastText != "")
c.registerButtonDisabled = false
})
return
}

if err := json.Unmarshal(*resp, &response); err != nil {
toastText = "cannot unmarshal response"

ctx.Dispatch(func(ctx app.Context) {
c.toastText = toastText
c.toastShow = (toastText != "")
c.registerButtonDisabled = false
c.postButtonsDisabled = false
})
return
} else {
if err := json.Unmarshal(*resp, &response); err != nil {
toastText = "cannot unmarshal response"

ctx.Dispatch(func(ctx app.Context) {
c.toastText = toastText
c.toastShow = (toastText != "")
c.postButtonsDisabled = false
})
return
}
}

if response.Code != 201 {
Expand All @@ -263,7 +263,7 @@ func (c *postContent) onClick(ctx app.Context, e app.Event) {
ctx.Dispatch(func(ctx app.Context) {
c.toastText = toastText
c.toastShow = (toastText != "")
c.registerButtonDisabled = false
c.postButtonsDisabled = false
})
return
}
Expand Down

0 comments on commit f2b44c5

Please sign in to comment.