# 试图将反应改为仅点赞会导致它被完全删除

**URL:** <https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466>\
**Category:** Bug\
**Tags:** reactions\
**Created:** [2024年七月21日 18:34 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466 "2024-07-21T18:34:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)\
**Post date:** [2024年七月21日 18:34 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/1 "2024-07-21T18:34:41Z")

</div>

我猜这与新的反应被计为点赞有关，重现步骤：

1. 添加任何被计为点赞的反应
2. 将你的反应更改为点赞
3. 注意你的反应已被完全移除

---

<div class="post-metadata">

**Author:** ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)\
**Post date:** [2024年七月22日 09:13 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/2 "2024-07-22T09:13:21Z")

</div>

感谢您的报告。

目前没有预计完成时间，但我正在重构 reactions 功能，这可能会一并修复此问题。在此之前，我没有计划投入时间处理 reactions。

---

<div class="post-metadata">

**Author:** ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)\
**Post date:** [2024年七月27日 08:56 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/3 "2024-07-27T08:56:44Z")

</div>



---

<div class="post-metadata">

**Author:** ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)\
**Post date:** [2024年十月1日 09:56 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/4 "2024-10-01T09:56:52Z")

</div>

此主题在 66 天后自动开启。

---

<div class="post-metadata">

**Author:** ![lindsey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lindsey/32/318210_2.png) [@lindsey](https://meta.discourse.org/u/lindsey)\
**Post date:** [2024年十月8日 15:54 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/5 "2024-10-08T15:54:03Z")

</div>

我无法重现此问题 — @Firepup650 你能再试一次你的步骤，然后告诉我你是否仍然遇到此行为吗？如果不是，我将继续关闭此问题。

---

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2024年十月8日 17:36 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/6 "2024-10-08T17:36:57Z")

</div>

我仍然可以重现此问题

---

<div class="post-metadata">

**Author:** ![lindsey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lindsey/32/318210_2.png) [@lindsey](https://meta.discourse.org/u/lindsey)\
**Post date:** [2024年十月8日 17:48 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/7 "2024-10-08T17:48:57Z")

</div>

谢谢你的视频，我现在也能看到了。我不知道之前测试时是不是没等够时间，或者为什么当时没看到——但现在我肯定能看到了。

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2024年十月19日 08:23 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/8 "2024-10-19T08:23:32Z")

</div>

我也能重现。@j.jaffeux 你的反应重构会修复这个问题吗？

---

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2026年一月23日 18:59 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/11 "2026-01-23T18:59:58Z")

</div>

修复了 🎉

> <https://github.com/discourse/discourse/pull/36778>
>
> \# Overview
> 
> Toggling from a previous (non-default) reaction to a default react…ion would not persist the default reaction
> 
> \_preview from meta\_
> 
> https://github.com/user-attachments/assets/8f6971f3-0630-4992-ad50-68a0006291ce
> 
> 
> \# Problem
> 
> When changing from a non like reaction (eg "heart") to the \`reaction\_for\_like\` (eg "+1"), this caused an issue:
> 
> 1. \`remove\_reaction\` was called, which destroyed the old heart \`ReactionUser\`
> 2. \`remove\_reaction\` also called \`remove\_shadow\_like\` → \`delete\_like\_reaction\`, which destroyed the thumps up reaction from the db
> 3. Then only a shadow like was added, but no new \`ReactionUser\` was created
> 4. The thumbs up reaction disappeared from the UI because there was no \`ReactionUser\` to display it
> 
> \# Fix
> 
> I updated \`toggle\_like\` to match the pattern in \`toggle\_reaction\`:
> 
> \- After \`remove\_reaction\`, we recreate \`@reaction\` using \`reaction\_scope&.first\_or\_create\` (since the old one was destroyed)
> \- Then call \`add\_reaction\` to create a new \`ReactionUser\` with the proper reaction id

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2026年一月27日 21:00 UTC](https://meta.discourse.org/t/trying-to-change-a-reaction-to-just-a-like-causes-it-to-be-removed-entirely/317466/12 "2026-01-27T21:00:50Z")

</div>

此主题在 14 小时后自动关闭。不再允许回复。
