Skip to content

Commit

Permalink
fix: main page nil announcement bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoCoelho2003 committed Sep 24, 2024
1 parent fac57ec commit 424175a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/atomic/organizations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,11 @@ defmodule Atomic.Organizations do
{:error, %Ecto.Changeset{}}
"""
def update_announcement(%Announcement{} = announcement, attrs, _after_save \\ &{:ok, &1}) do
def update_announcement(%Announcement{} = announcement, attrs, after_save \\ &{:ok, &1}) do
announcement
|> Announcement.changeset(attrs)
|> Repo.update()
|> after_save(after_save)
end

@doc """
Expand All @@ -624,7 +625,10 @@ defmodule Atomic.Organizations do
"""
def delete_announcement(%Announcement{} = announcement) do
Repo.delete(announcement)
Ecto.Multi.new()
|> Ecto.Multi.delete(:announcement, announcement)
|> Ecto.Multi.delete(:post, Repo.get!(Post, announcement.post_id))
|> Repo.transaction()
end

@doc """
Expand Down

0 comments on commit 424175a

Please sign in to comment.