thesis v0.3.4 Thesis.Notifications
Builds a map of Notifications that is passed to the client side. The key should be a representation of the category/type of notification (this is used to determine where and how it's displayed). The value is a list of notification strings.
Example of final map: %{ "page-settings": [], "add-page": [], "import-export-restore": [], "other": [] }
Link to this section Summary
Functions
Adds notifications provided by the host app to the accumulator
Verifies that the notifications provided by the host app are in the correct format
Link to this section Functions
Link to this function
all(conn)
Link to this function
notifications_from_host_app(acc, conn, notifications)
Adds notifications provided by the host app to the accumulator.
iex> notifications_from_host_app(%{"page-settings" => []}, nil, [page_settings: ["notif"]])
%{"page-settings" => ["notif"]}
iex> notifications_from_host_app(%{"page-settings" => []}, nil, [page_settings: :invalid])
%{"page-settings" => []}
iex> notifications_from_host_app(%{"page-settings" => ["notif1"]}, nil, [page_settings: ["notif2"]])
%{"page-settings" => ["notif2", "notif1"]}
iex> notifications_from_host_app(%{"other" => [], "add-page" => ["notif"]}, nil, [other: ["notif"]])
%{"other" => ["notif"], "add-page" => ["notif"]}
iex> notifications_from_host_app(%{"other" => []}, nil, nil)
%{"other" => []}
Link to this function
notifications_regarding_env(acc, arg2)
Link to this function
notifications_regarding_page(acc, arg2)
Link to this function
verify_notifications_structure(conn, notifications)
Verifies that the notifications provided by the host app are in the correct format.
iex> verify_notifications_structure(nil, [:invalid])
false
iex> verify_notifications_structure(nil, %{})
false
iex> verify_notifications_structure(nil, %{invalid_key: []})
false
iex> verify_notifications_structure(nil, %{add_page: "invalid value"})
false
iex> verify_notifications_structure(nil, %{add_page: ["notif", "notif", :atom]})
false
iex> verify_notifications_structure(nil, [add_page: [], page_settings: ["notif"]])
false