dmails: allow marking dmails as unread.

* Add ability to mark dmails as unread.
* Fix users.unread_dmail_count to not count deleted dmails.
* Fix show action so that API calls don't mark dmails as read.
* Don't show the unread dmail notice on the /dmails page itself.
* Stop using users.has_mail flag.
This commit is contained in:
evazion
2020-01-31 15:47:58 -06:00
parent 067c6a10e7
commit 6468df6d44
12 changed files with 107 additions and 50 deletions

View File

@@ -25,11 +25,18 @@
<%= link_to dmail.title, dmail_path(dmail) %>
<% end %>
<% t.column do |dmail| %>
<% if dmail.is_read? %>
<%= link_to "Unread", dmail_path(dmail, format: :js), remote: true, method: :put, "data-params": "dmail[is_read]=false" %>
<% else %>
<%= link_to "Read", dmail_path(dmail, format: :js), remote: true, method: :put, "data-params": "dmail[is_read]=true" %>
<% end %>
|
<% if dmail.is_deleted? %>
<%= link_to "Undelete", dmail_path(dmail, format: :js), remote: true, method: :put, "data-params": "dmail[is_deleted]=false" %>
<% else %>
<%= link_to "Delete", dmail_path(dmail, format: :js), remote: true, method: :put, "data-params": "dmail[is_deleted]=true", "data-confirm": "Are you sure you want to delete this dmail?" %>
<% end %>
<% if dmail.reportable_by?(CurrentUser.user) %>
| <%= link_to "Report", new_moderation_report_path(moderation_report: { model_type: "Dmail", model_id: dmail.id }), remote: true, title: "Report this dmail to the moderators" %>
<% end %>