-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: edit group reply #426
Conversation
Preview DeploymentStorybook https://pr-426-storybook--bangumi-next.netlify.app |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #426 +/- ##
=======================================
Coverage 83.09% 83.09%
=======================================
Files 93 93
Lines 5388 5390 +2
Branches 427 426 -1
=======================================
+ Hits 4477 4479 +2
Misses 904 904
Partials 7 7
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
https://pr-426-sites--bangumi-next.netlify.app/group/reply/2177421/edit 试了一下发现能用来修改帖子 b38 API的问题,修好了( |
感觉可以改一下 API,直接返回对应的帖子标题,前端就不需要请求两个 API 了 |
@y-young this pull request is now in conflict 😩 |
@y-young this pull request is now in conflict 😩 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
等着改一下API的相应,没必要额外请求一次帖子内容。
才发现 API 3 天前就改好了(bgm38) 然而现在有个问题,如果用 useGroupTopic 的话必定会请求一次帖子数据,如果不用 useGroupTopic 的话似乎没法让主题里的回复内容在返回之前刷新,试了全局的 mutate 和 useSWRMutation 貌似都不行,刚返回的时候先看到还是旧数据。 |
没有fetch过数据的话直接转跳回去不就能自动fetch新数据了吗?SWR应该是这样的吧? |
是这样,只不过会看到旧数据变成新数据的过程 |
useGroupTopic 放在提交成功之后? |
那岂不是得在整个 topic 上加? |
在最后一行加这样?可能得问问设计师( |
Avoid a topic request by not using useGroupTopic Use global mutate to update reply text immediately, revalidate in background
应该搞定了,记录一下过程: 如果使用 useSWRMutation 可以避免请求 topic,但昨天测试时无法及时更新 UI,把全局的 cache 打出来后发现是 cache 没有更新,原因是 populateCache 参数默认为 false,改成 true 就可以了 然而使用 useSWRMutation 还有个问题,在编辑回复页 mutate 时会请求一次帖子数据,在跳转回帖子时还会再请求一次,理论上时间相近的两次请求应该会去重,但不知道这里为什么没有 所以现在的方法是用全局的 mutate(避免调用 useGroupTopic),data 参数可以接收一个 mutate 函数,可以对帖子内容进行乐观更新,这样就省去了一次请求,在跳转回帖子后会在后台 revalidate,有问题会 rollback(如果这个请求不需要的话应该也可以去掉) 此外发现 mutate reply 也会发一次请求,现在把 revalidate 改成 false 就不会了 |
等先合了另一个PR吧,改成error toast |
|
Tracking: #112