Skip to content

Commit

Permalink
[chore] Bump changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhanus3133 committed Sep 7, 2024
1 parent b37fce5 commit 2f802be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@ function updateSubscription(subscribe) {
if (subscribe) {
statusMessage.textContent = gettext('You are currently subscribed to notifications.');
toggleBtn.textContent = gettext('Unsubscribe');
confirmationMsg.textContent = data.message;
toggleBtn.setAttribute('data-hasSubscribe', 'true');
confirmationMsg.textContent = 'Successfully subscribed!';
} else {
statusMessage.textContent = gettext('You are currently unsubscribed from notifications.');
toggleBtn.textContent = gettext('Subscribe');
confirmationMsg.textContent = data.message;
toggleBtn.setAttribute('data-hasSubscribe', 'false');
confirmationMsg.textContent = 'Successfully unsubscribed!';
}

confirmationMsg.style.display = 'block';
} else {
window.alert(data.message);
}
})
.catch(error => {
console.error('Error:', error);
});
}

document.addEventListener('DOMContentLoaded', function() {
const toggleBtn = document.getElementById('toggle-btn');
toggleBtn.addEventListener('click', function() {
const currentStatus = toggleBtn.textContent.trim().toLowerCase();
const subscribe = currentStatus === gettext('subscribe').toLowerCase();
const isSubscribed = toggleBtn.getAttribute('data-hasSubscribe') === 'true';
const subscribe = !isSubscribed;
updateSubscription(subscribe);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>{% trans 'Manage Notification Preferences' %}</h1>
{% trans 'You are currently unsubscribed from notifications.' %}
{% endif %}
</p>
<button id="toggle-btn">
<button id="toggle-btn" data-hasSubscribe="{% if is_subscribed %}true{% else %}false{% endif %}">
{% if is_subscribed %}
{% trans 'Unsubscribe' %}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion openwisp_notifications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def post(self, request, *args, **kwargs):
try:
if request.content_type == 'application/json':
data = json.loads(request.body)
subscribe = data.get('subscribe', False)
subscribe = data.get('subscribe', False) is True
else:
# Unsubscribe by default
subscribe = False
Expand Down

0 comments on commit 2f802be

Please sign in to comment.