fix(mobile): 新建任务输入内容返回后保留 - #1100
Open
weed33834 wants to merge 1 commit into
Open
Conversation
新建任务页在返回首页/任务列表后会被卸载,本地 useState 丢失用户已输入的任务描述。增加模块级草稿缓存,保存 content / repoKey / manualRepo,返回再进入时恢复上次输入, 对齐网页版体验;任务创建成功后清空草稿。 Fixes chaitin#851
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
App 新建任务页输入框输入内容后,返回首页再回到任务列表,之前输入的内容丢失;网页版可保留(#851)。
根因
new-task.tsx的任务描述content(以及repoKey/manualRepo)都是组件本地useState。返回首页/任务列表时该屏幕被卸载,再次进入时组件重新挂载,状态重置为空。修复
新增模块级草稿缓存
mobile/src/new-task-draft.ts,在应用会话内缓存草稿:useState(() => getNewTaskDraft().content ?? '')(repoKey、manualRepo同理)useEffect监听content/repoKey/manualRepo变化并写回缓存clearNewTaskDraft()清空草稿仅覆盖应用会话内的导航往返场景,与 #851 描述的「返回再进入」一致,不做持久化落盘。
改动
mobile/src/new-task-draft.tsmobile/app/new-task.tsxFixes #851