Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Notification Error on empty watch list #2727

Closed
wants to merge 3 commits into from

Conversation

mikebgrep
Copy link

@mikebgrep mikebgrep commented Oct 20, 2024

With this PR, I fix the issue when there are no watched pages on the home screen and the user try to update and test the notification option from settings. Previously error was displayed, now the test notification work.
Notification test was passed also I test manual with empty watch and available watch.

  File "/app/changedetection/changedetectionio/flask_app.py", line 232, in decorated_view
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/changedetection/changedetectionio/flask_app.py", line 549, in ajax_callback_send_notification_test
    watch_uuid = random.choice(list(datastore.data['watching'].keys()))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/random.py", line 347, in choice
    raise IndexError('Cannot choose from an empty sequence')

dgtlmoon added a commit that referenced this pull request Oct 21, 2024
dgtlmoon added a commit that referenced this pull request Oct 21, 2024
@dgtlmoon
Copy link
Owner

Thanks!

This cant be merged without a test, so i've added a test in another branch and merged it there

@mikebgrep
Copy link
Author

Hi, great. I was thinking of looking if the test is needed, but when I rethink, I decide that maybe it is covered.

watch = datastore.data['watching'].get(watch_uuid)
watch = datastore.data['watching'].get(watch_uuid)
else:
watch = None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this broke a lot of stuff that was not tested for, for example, sending a test notification when in restock mode

Copy link
Author

@mikebgrep mikebgrep Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not sending when restock is available? I can take a look tomorrow if you are not in a rush.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants