mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 07:13:52 -05:00
Add 'filter notifications" option
This reduces the number of notifications in both your tab bar and your notifications page, by showing only mentions and new subscribers (i.e., things that are actionable by you).
This commit is contained in:
parent
21af4a0ef8
commit
c7fb38b57c
@ -26,7 +26,8 @@ class PreferencesForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Preference
|
||||
fields = ['theme', 'filter_replies', 'filter_boosts', 'timezone',
|
||||
'no_javascript', 'notifications', 'click_to_load', 'lightbox', 'poll_frequency']
|
||||
'no_javascript', 'notifications', 'click_to_load', 'lightbox',
|
||||
'filter_notifications', 'poll_frequency']
|
||||
|
||||
class PostForm(forms.Form):
|
||||
"""def status_post(self, status, in_reply_to_id=None, media_ids=None,
|
||||
|
18
brutaldon/migrations/0018_preference_filter_notifications.py
Normal file
18
brutaldon/migrations/0018_preference_filter_notifications.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1.5 on 2019-01-14 13:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('brutaldon', '0017_preference_poll_frequency'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='preference',
|
||||
name='filter_notifications',
|
||||
field=models.BooleanField(default=False, help_text='Exclude boosts and favs from your notifications.'),
|
||||
),
|
||||
]
|
@ -41,6 +41,8 @@ class Preference(models.Model):
|
||||
help_text=_("""Use a JavaScript lightbox to display media."""))
|
||||
poll_frequency = models.IntegerField(default=300,
|
||||
help_text=_("""Number of seconds to wait between checking notifications. Default: 300"""))
|
||||
filter_notifications = models.BooleanField(default=False,
|
||||
help_text=_("""Exclude boosts and favs from your notifications."""))
|
||||
|
||||
class Account(models.Model):
|
||||
username = models.EmailField(unique=True)
|
||||
|
@ -85,6 +85,16 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label checkbox" for="click_to_load">
|
||||
{% render_field form.filter_notifications class+="checkbox" %}
|
||||
{{ form.filter_notifications.label }}
|
||||
</label>
|
||||
<p class="notification is-info preferences-help">
|
||||
{{ form.filter_notifications.help_text }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="poll_frequency">{{ form.poll_frequency.label }}</label>
|
||||
<div class="control">
|
||||
|
@ -43,8 +43,10 @@ def _notes_count(account, mastodon):
|
||||
if not mastodon:
|
||||
return ""
|
||||
notes = mastodon.notifications(limit=40)
|
||||
if account.preferences.filter_notifications:
|
||||
notes = [ note for note in notes if note.type == 'mention' or note.type == 'follow']
|
||||
for index, item in enumerate(notes):
|
||||
if item.id == account.note_seen:
|
||||
if item.id <= account.note_seen:
|
||||
break
|
||||
else:
|
||||
index = "40+"
|
||||
@ -325,6 +327,8 @@ def note(request, next=None, prev=None):
|
||||
account.save()
|
||||
|
||||
notes = mastodon.notifications(limit=100, max_id=next, since_id=prev)
|
||||
if account.preferences.filter_notifications:
|
||||
notes = [ note for note in notes if note.type == 'mention' or note.type == 'follow']
|
||||
try:
|
||||
prev = notes[0]._pagination_prev
|
||||
if len(mastodon.notifications(since_id=prev['since_id'])) == 0:
|
||||
@ -402,6 +406,7 @@ def settings(request):
|
||||
account.preferences.notifications = form.cleaned_data['notifications']
|
||||
account.preferences.click_to_load = form.cleaned_data['click_to_load']
|
||||
account.preferences.lightbox = form.cleaned_data['lightbox']
|
||||
account.preferences.filter_notifications = form.cleaned_data['filter_notifications']
|
||||
request.session['timezone'] = account.preferences.timezone
|
||||
account.preferences.save()
|
||||
account.save()
|
||||
@ -838,4 +843,3 @@ def emoji_reference(request):
|
||||
"emojos": sorted(emojos, key=lambda x: x['shortcode']),
|
||||
"notifications": notifications,
|
||||
'own_acct' : request.session['user']})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user