UI - Fixing Watch 'set viewed' by tag #3253 (#3258)

cross-platform-path-fixes
dgtlmoon 2025-06-11 13:06:45 +02:00 zatwierdzone przez GitHub
rodzic 99ca8787ab
commit 5ed596bfa9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 39 dodań i 24 usunięć

Wyświetl plik

@ -159,12 +159,20 @@ def construct_blueprint(datastore: ChangeDetectionStore, update_q, worker_handle
def mark_all_viewed():
# Save the current newest history as the most recently viewed
with_errors = request.args.get('with_errors') == "1"
tag_limit = request.args.get('tag')
logger.debug(f"Limiting to tag {tag_limit}")
now = int(time.time())
for watch_uuid, watch in datastore.data['watching'].items():
if with_errors and not watch.get('last_error'):
continue
datastore.set_last_viewed(watch_uuid, int(time.time()))
return redirect(url_for('watchlist.index'))
if tag_limit and ( not watch.get('tags') or tag_limit not in watch['tags'] ):
logger.debug(f"Skipping watch {watch_uuid}")
continue
datastore.set_last_viewed(watch_uuid, now)
return redirect(url_for('watchlist.index', tag=tag_limit))
@ui_blueprint.route("/delete", methods=['GET'])
@login_optionally_required

Wyświetl plik

@ -214,9 +214,14 @@ document.addEventListener('DOMContentLoaded', function() {
<li id="post-list-mark-views" class="{%- if has_unviewed -%}has-unviewed{%- endif -%}" style="display: none;" >
<a href="{{url_for('ui.mark_all_viewed',with_errors=request.args.get('with_errors',0)) }}" class="pure-button button-tag " id="mark-all-viewed">Mark all viewed</a>
</li>
{%- if active_tag_uuid -%}
<li id="post-list-mark-views-tag">
<a href="{{url_for('ui.mark_all_viewed', tag=active_tag_uuid) }}" class="pure-button button-tag " id="mark-all-viewed">Mark all viewed in '{{active_tag.title}}'</a>
</li>
{%- endif -%}
<li>
<a href="{{ url_for('ui.form_watch_checknow', tag=active_tag_uuid, with_errors=request.args.get('with_errors',0)) }}" class="pure-button button-tag" id="recheck-all">Recheck
all {%- if active_tag_uuid-%} in "{{active_tag.title}}"{%endif%}</a>
all {% if active_tag_uuid %} in '{{active_tag.title}}'{%endif%}</a>
</li>
<li>
<a href="{{ url_for('rss.feed', tag=active_tag_uuid, token=app_rss_token)}}"><img alt="RSS Feed" id="feed-icon" src="{{url_for('static_content', group='images', filename='generic_feed-icon.svg')}}" height="15"></a>

Wyświetl plik

@ -236,39 +236,41 @@ def test_group_tag_notification(client, live_server, measure_memory_usage):
assert b'Deleted' in res.data
def test_limit_tag_ui(client, live_server, measure_memory_usage):
test_url = url_for('test_endpoint', _external=True)
urls=[]
test_url = url_for('test_random_content_endpoint', _external=True)
for i in range(20):
urls.append(test_url+"?x="+str(i)+" test-tag")
for i in range(20):
urls.append(test_url+"?non-grouped="+str(i))
res = client.post(
# A space can label the tag, only the first one will have a tag
client.post(
url_for("imports.import_page"),
data={"urls": "\r\n".join(urls)},
data={"urls": f"{test_url} test-tag\r\n{test_url}"},
follow_redirects=True
)
assert b"40 Imported" in res.data
tag_uuid = get_UUID_for_tag_name(client, name="test-tag")
assert tag_uuid
res = client.get(url_for("watchlist.index"))
assert b'test-tag' in res.data
client.get(url_for("ui.form_watch_checknow"), follow_redirects=True)
wait_for_all_checks(client)
client.get(url_for("ui.form_watch_checknow"), follow_redirects=True)
wait_for_all_checks(client)
# All should be here
assert res.data.count(b'processor-text_json_diff') == 40
# Should be both unviewed
res = client.get(url_for("watchlist.index"))
assert res.data.count(b' unviewed ') == 2
tag_uuid = get_UUID_for_tag_name(client, name="test-tag")
res = client.get(url_for("watchlist.index", tag=tag_uuid))
# Now we recheck only the tag
client.get(url_for('ui.mark_all_viewed', tag=tag_uuid), follow_redirects=True)
wait_for_all_checks(client)
with open('/tmp/fuck.html', 'wb') as f:
f.write(res.data)
# Should be only 1 unviewed
res = client.get(url_for("watchlist.index"))
assert res.data.count(b' unviewed ') == 1
# Just a subset should be here
assert b'test-tag' in res.data
assert res.data.count(b'processor-text_json_diff') == 20
assert b"object at" not in res.data
res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
res = client.get(url_for("tags.delete_all"), follow_redirects=True)