diff --git a/tildes/tildes/templates/includes/topic_tags.jinja2 b/tildes/tildes/templates/includes/topic_tags.jinja2
new file mode 100644
index 0000000..55b3472
--- /dev/null
+++ b/tildes/tildes/templates/includes/topic_tags.jinja2
@@ -0,0 +1,9 @@
+
diff --git a/tildes/tildes/templates/intercooler/topic_tags.jinja2 b/tildes/tildes/templates/intercooler/topic_tags.jinja2
index 292d8be..58ba1df 100644
--- a/tildes/tildes/templates/intercooler/topic_tags.jinja2
+++ b/tildes/tildes/templates/intercooler/topic_tags.jinja2
@@ -1,5 +1 @@
-
+{% include 'includes/topic_tags.jinja2' %}
diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2
index 15b7a20..6859134 100644
--- a/tildes/tildes/templates/topic.jinja2
+++ b/tildes/tildes/templates/topic.jinja2
@@ -204,15 +204,7 @@
- Tags
-
-
+ {% include 'includes/topic_tags.jinja2' %}
- Comments
diff --git a/tildes/tildes/views/api/web/topic.py b/tildes/tildes/views/api/web/topic.py
index b97d565..6e33b66 100644
--- a/tildes/tildes/views/api/web/topic.py
+++ b/tildes/tildes/views/api/web/topic.py
@@ -14,7 +14,7 @@ from tildes.models.log import LogTopic
from tildes.models.topic import Topic, TopicVote
from tildes.schemas.group import GroupSchema
from tildes.schemas.topic import TopicSchema
-from tildes.views import IC_EMPTY, IC_NOOP
+from tildes.views import IC_NOOP
from tildes.views.decorators import ic_view_config
@@ -160,28 +160,23 @@ def tag_topic(request: Request, tags: str) -> dict:
"""Apply tags to a topic with Intercooler."""
topic = request.context
- if not tags:
- request.db_session.add(
- LogTopic(
- LogEventType.TOPIC_TAG,
- request,
- topic,
- info={'old': topic.tags, 'new': []},
- ),
- )
- topic.tags = []
- return IC_EMPTY
-
- # split the tag string on commas
- split_tags = tags.split(',')
+ if tags:
+ # split the tag string on commas
+ new_tags = tags.split(',')
+ else:
+ new_tags = []
old_tags = topic.tags
try:
- topic.tags = split_tags
+ topic.tags = new_tags
except ValidationError:
raise ValidationError({'tags': ['Invalid tags']})
+ # if tags weren't changed, don't add a log entry or update page
+ if set(topic.tags) == set(old_tags):
+ return IC_NOOP
+
request.db_session.add(
LogTopic(
LogEventType.TOPIC_TAG,