Skip to content

Prepare for updating accounts in database #526

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

Merged
merged 15 commits into from
Feb 22, 2024

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Feb 21, 2024

Currently we insert Account records into the database on login, and never update them. We'll need to update them in order to do:

and other things.

This branch doesn't yet make any new changes in the database, but it does some refactoring on PerAccountStore and friends which we'll need in order to do so. It also takes care of various things that became noticeable along the way:

The main commit is this one near the beginning:


store [nfc]: Keep just one copy of Account object

We're going to want to update these, when things like
the server version or the acked push token change.
To avoid endless bugs, it'll then be important that there
be just one copy to be updated.

@gnprice
Copy link
Member Author

gnprice commented Feb 21, 2024

The CI failure is a pair of analyzer failures that appear with a Flutter update today. Chris noticed them earlier today and is working on a PR:
https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20some.20.60ColorScheme.60.20fields.20deprecated/near/1741410

So this PR is otherwise ready, and should pass CI once it's rebased atop that upcoming other PR.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Thanks! Just one comment below.

Comment on lines -733 to +739
child: RealmContentNetworkImage(
resolvedSrc,
filterQuality: FilterQuality.medium,
width: size,
height: size,
)),
child: resolvedSrc == null ? const SizedBox.shrink() // TODO(log)
: RealmContentNetworkImage(
resolvedSrc,
filterQuality: FilterQuality.medium,
width: size,
height: size,
)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

For emoji reactions, if the src doesn't parse, we fall back to showing the emoji name. (We use the same fallback if the src parses but the image fails to load.) This would be nice to do, or we could add a TODO for it.

I wonder if it would be hard to factor the emoji-reaction widget code into something to also use in content. Another thing I notice is that _UnicodeEmoji in widgets/emoji_reaction.dart has careful logic so that the emoji isn't awkwardly small on iOS. (In content, unicode emojis are awkwardly small on iOS.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it'd be good to reuse the work that went into those reaction emoji so that emoji in content also get the benefit of it. It looks like features that would bring include:

  • making Unicode emoji bigger on iOS, counteracting that Flutter-and/or-iOS bug;
  • disabling animations based on the platform setting;
  • text fallbacks based on the user's emojiset choice;
  • text fallbacks when an image doesn't work out.

At the moment we don't have an implementation of emoji-as-text-name at all for content, so I think doing that as a fallback is out of scope for this PR. The URL failing to parse should happen rarely to never — it'd be a bug in the server, and doesn't seem like a real likely kind of bug.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense.

@gnprice gnprice force-pushed the pr-account-update-prep branch from a91b6da to 9990caf Compare February 22, 2024 03:26
We're going to want to update these, when things like
the server version or the acked push token change.
To avoid endless bugs, it'll then be important that there
be just one copy to be updated.
These have been gradually proliferating, and it's time for another
round of giving more structure to the list.

Also remove a couple of TODO comments that are better expressed
in the tracker; and an admonition about handleEvent that is
probably no longer helpful because there are enough of these fields
that a developer isn't likely to be looking at it when they go to
add another one.
The field docs get helpfully propagated by Drift from the
table class to the corresponding fields on the record class,
which is the one most widely found around the codebase.
This makes use sites a bit shorter and more explicit.

We could have made it a getter, but storing the answer directly
here on the PerAccountStore is a space-for-time tradeoff: this
is something we look up frequently, so the extra word of memory
to have a copy directly here seems worth it to save the hash-map
lookup each time.
The `message` passed to MessageContent should have the same content
that was parsed to produce `content`.

In the app we don't insert a Directionality widget of our own,
and the GlobalStoreWidget is outside the MaterialApp, not inside.
Now that the caller is getting the Account object by looking
it up on the GlobalStore anyway, there's no checking to be gained
from passing the whole Account here.
@gnprice gnprice force-pushed the pr-account-update-prep branch from 9990caf to abc65a2 Compare February 22, 2024 03:38
@chrisbobbe
Copy link
Collaborator

Did you mean to comment further or merge this? I see you force-pushed after the discussion above.

@gnprice
Copy link
Member Author

gnprice commented Feb 22, 2024

Ah, those pushes were just rebasing and resolving conflicts. I didn't make any changes in content, just replied to your comment above. Shall we merge this?

@chrisbobbe
Copy link
Collaborator

Sure, please go ahead!

@gnprice gnprice merged commit abc65a2 into zulip:main Feb 22, 2024
@gnprice gnprice deleted the pr-account-update-prep branch February 22, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants