This commit is contained in:
m15o 2021-11-27 10:56:12 +01:00
parent ea7088f8c0
commit d480796fd3
2 changed files with 6 additions and 2 deletions

View file

@ -175,7 +175,11 @@ func (s *Storage) DeleteStatus(id int64, author string) error {
var newId int64
if err := tx.QueryRowContext(ctx, `select id from statuses where author = $1 order by created_at desc limit 1;`,
author).Scan(&newId); err != nil {
tx.Rollback()
if _, err := tx.ExecContext(ctx, `UPDATE users set status_id=$1 where name=$2`, nil, author); err != nil {
tx.Rollback()
return err
}
err = tx.Commit()
return err
}
if _, err := tx.ExecContext(ctx, `UPDATE users set status_id=$1 where name=$2`, newId, author); err != nil {

View file

@ -198,7 +198,7 @@ Are you sure you you want to delete the following status?
<article class="status">
{{ template "status" . }}
{{ if eq $.logged .User }}
<nav><a href="/status-remove?id={{ .Id }}">Delete</a> <a href="/status-edit?id={{ .Id }}">Edit</a></nav>
<nav><a href="/status-remove?id={{ .Id }}">Delete</a> <a href="/statuses/{{ .Id }}/edit">Edit</a></nav>
{{ end }}
</article>
{{ end }}