forked from rDrama/rDrama
1
0
Fork 0

add "saves" and "subscriptions" sorts everywhere

master
Aevann 2023-06-08 04:56:12 +03:00
parent 9c6c264307
commit d7d44606ac
5 changed files with 9 additions and 1 deletions

View File

@ -870,6 +870,7 @@ def save_post(pid, v):
if not save:
new_save=SaveRelationship(user_id=v.id, post_id=p.id)
g.db.add(new_save)
cache.delete_memoized(userpagelisting)
return {"message": "Post saved!"}
@ -887,6 +888,7 @@ def unsave_post(pid, v):
if save:
g.db.delete(save)
cache.delete_memoized(userpagelisting)
return {"message": "Post unsaved!"}

View File

@ -508,6 +508,7 @@ def subscribe(v, post_id):
if not existing:
new_sub = Subscription(user_id=v.id, post_id=post_id)
g.db.add(new_sub)
cache.delete_memoized(userpagelisting)
return {"message": "Subscribed to post successfully!"}
@app.post("/unsubscribe/<int:post_id>")
@ -520,6 +521,7 @@ def unsubscribe(v, post_id):
existing = g.db.query(Subscription).filter_by(user_id=v.id, post_id=post_id).one_or_none()
if existing:
g.db.delete(existing)
cache.delete_memoized(userpagelisting)
return {"message": "Unsubscribed from post successfully!"}
@app.post("/@<username>/message")

View File

@ -297,6 +297,7 @@
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
{% if sort=="old" %}<i class="fas fa-book mr-1"></i>{% endif %}
{% if sort=="controversial" %}<i class="fas fa-bullhorn mr-1"></i>{% endif %}
{% if sort=="saves" %}<i class="fas fa-save mr-1"></i>{% endif %}
{{sort | capitalize}}
</button>
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
@ -306,6 +307,7 @@
{% if sort != "new" %}<a class="dropdown-item" href="?sort=new"><i class="fas fa-sparkles mr-2"></i>New</a>{% endif %}
{% if sort != "old" %}<a class="dropdown-item" href="?sort=old"><i class="fas fa-book mr-2"></i>Old</a>{% endif %}
{% if sort != "controversial" %}<a class="dropdown-item" href="?sort=controversial"><i class="fas fa-bullhorn mr-2"></i>Controversial</a>{% endif %}
{% if sort != "saves" %}<a class="dropdown-item" href="?sort=saves"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
</div>
</div>
</div>

View File

@ -137,7 +137,7 @@
{% if sort != "controversial" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=controversial&t={{t}}"><i class="fas fa-bullhorn mr-2"></i>Controversial</a>{% endif %}
{% if sort != "comments" and "/posts" in request.path %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=comments&t={{t}}"><i class="fas fa-comments mr-2"></i>Comments</a>{% endif %}
{% if sort != "subscriptions" and "/posts" in request.path %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=subscriptions&t={{t}}"><i class="fas fa-bell mr-2"></i>Subscriptions</a>{% endif %}
{% if sort != "saves" and "/posts" in request.path %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=saves&t={{t}}"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
{% if sort != "saves" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=saves&t={{t}}"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
</div>
</div>
</div>

View File

@ -67,6 +67,8 @@
{% if sort != "new" %}<a class="dropdown-item" href="?sort=new&t={{t}}"><i class="fas fa-sparkles mr-2"></i>New</a>{% endif %}
{% if sort != "old" %}<a class="dropdown-item" href="?sort=old&t={{t}}"><i class="fas fa-book mr-2"></i>Old</a>{% endif %}
{% if sort != "controversial" %}<a class="dropdown-item" href="?sort=controversial&t={{t}}"><i class="fas fa-bullhorn mr-2"></i>Controversial</a>{% endif %}
{% if sort != "subscriptions" and "/posts" in request.path %}<a class="dropdown-item" href="?sort=subscriptions&t={{t}}"><i class="fas fa-bell mr-2"></i>Subscriptions</a>{% endif %}
{% if sort != "saves" %}<a class="dropdown-item" href="?sort=saves&t={{t}}"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
</div>
</div>
</div>