Skip to content
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

fix: chaning field type #5360 #5366

Merged
merged 1 commit into from
May 20, 2024

Conversation

zoli
Copy link
Contributor

@zoli zoli commented May 19, 2024

Before this changing any field from CellController<String, String> to a CellController<SomeCellDataPB, String> caused an exception. The root of the problem was that _CardContent wasn't getting rebuilt when field type got changed. In CardState it was storing a list of CellContext which contains only field id and row id so on changing field type the state wasn't changing.
I made a new type CellMeta which stores field type alongside row id and field id and now CardState stores list of CellMeta.

Fixes #5360

PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Before this chaning any field from CellController<String, String>
to a CellController<SomeCellDataPB, String> caused exception.
The root of problem was that _CardContent wasn't getting rebuilt
when field type got changed. In CardState it was storing list of
CellContext which contains only field id and row id so on changing
field type the state wasn't changing.
I made a new type CellMeta which stores field type alongside row id
and field id and now CardState stores list of CellMeta.
(cellCtx) => CellMeta(
fieldId: cellCtx.fieldId,
rowId: cellCtx.rowId,
fieldType: fieldController.getField(cellCtx.fieldId)!.fieldType,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A future improvement: We are force unwrapping the value from getField everywhere. This doesn't make sense. If we are sure the value must not be null, we should change the return type of the getField function.

@LucasXu0 LucasXu0 merged commit 9b7ee4b into AppFlowy-IO:main May 20, 2024
13 checks passed
@zoli zoli deleted the fix/change-field-iss5360 branch May 21, 2024 08:42
zoli added a commit to zoli/AppFlowy that referenced this pull request May 21, 2024
* main:
  fix: unable to remove the remote selection when the user close the page on mobile (AppFlowy-IO#5376)
  chore: add limitation when importing csv file (AppFlowy-IO#5381)
  fix: infinite loop when getting ancestor for orphan view (AppFlowy-IO#5375)
  fix: range error raise if heading level >= 6 (AppFlowy-IO#5373)
  fix: use full update states instead of patch update (AppFlowy-IO#5371)
  chore: update translations to consistently use appName instead of AppFlowy (AppFlowy-IO#5354)
  fix: changing field type from text to checkbox causes exception AppFlowy-IO#5360 (AppFlowy-IO#5366)
  fix: heading node validate failed (AppFlowy-IO#5370)
  chore: support Ukrainian language AppFlowy-IO#5350 (AppFlowy-IO#5369)
  chore: do not use the cell of given summary field (AppFlowy-IO#5362)
  chore: update translations with Fink 🐦 (AppFlowy-IO#5322)
  chore: update fr-FR.json (AppFlowy-IO#5356)
  fix: workspace icon displays incorrectly on Linux (AppFlowy-IO#5358)
  feat: support web grid preview (AppFlowy-IO#5353)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] changing field type from text to checkbox causes exception
3 participants