##// END OF EJS Templates
Don't check new posts in the archived threads
neko259 -
r1344:efdda723 default
parent child Browse files
Show More
@@ -19,6 +19,8 b" SETTING_LAST_NOTIFICATION_ID = 'last_not"
19 19 SETTING_IMAGE_VIEWER = 'image_viewer'
20 20 SETTING_TRIPCODE = 'tripcode'
21 21
22 FAV_THREAD_NO_UPDATES = -1
23
22 24 DEFAULT_THEME = 'md'
23 25
24 26
@@ -124,8 +126,13 b' class SettingsManager:'
124 126
125 127 def add_or_read_fav_thread(self, opening_post):
126 128 threads = self.get_fav_threads()
127 threads[str(opening_post.id)] = opening_post.get_thread().get_replies()\
128 .last().id
129 thread = opening_post.get_thread()
130 # Don't check for new posts if the thread is archived already
131 if thread.is_archived():
132 last_id = FAV_THREAD_NO_UPDATES
133 else:
134 last_id = thread.get_replies().last().id
135 threads[str(opening_post.id)] = last_id
129 136 self.set_setting(SETTING_FAVORITE_THREADS, threads)
130 137
131 138 def del_fav_thread(self, opening_post):
@@ -116,7 +116,7 b' class Thread(models.Model):'
116 116 Checks if the thread can be bumped by replying to it.
117 117 """
118 118
119 return self.bumpable and not self.archived
119 return self.bumpable and not self.is_archived()
120 120
121 121 def get_last_replies(self) -> QuerySet:
122 122 """
@@ -233,3 +233,6 b' class Thread(models.Model):'
233 233 def get_replies_newer(self, post_id):
234 234 return self.get_replies().filter(id__gt=post_id)
235 235
236 def is_archived(self):
237 return self.archived
238
@@ -6,7 +6,8 b' from django.db import transaction'
6 6 from django.http import HttpResponse
7 7 from django.shortcuts import get_object_or_404
8 8 from django.core import serializers
9 from boards.abstracts.settingsmanager import get_settings_manager
9 from boards.abstracts.settingsmanager import get_settings_manager,\
10 FAV_THREAD_NO_UPDATES
10 11
11 12 from boards.forms import PostForm, PlainErrorList
12 13 from boards.models import Post, Thread, Tag
@@ -256,8 +257,13 b' def api_get_new_posts(request):'
256 257
257 258 for op in fav_thread_ops:
258 259 last_read_post = fav_threads[str(op.id)]
259 new_posts = op.get_thread().get_replies_newer(last_read_post)
260 new_post_count = new_posts.count()
260
261 if last_read_post == FAV_THREAD_NO_UPDATES:
262 new_post_count = 0
263 else:
264 new_posts = op.get_thread().get_replies_newer(last_read_post)
265 new_post_count = new_posts.count()
266
261 267 fav_thread_dict = dict()
262 268 fav_thread_dict['id'] = op.id
263 269 fav_thread_dict['new_post_count'] = new_post_count
General Comments 0
You need to be logged in to leave comments. Login now