Skip to content

Conversation

@nicodh
Copy link
Contributor

@nicodh nicodh commented Jan 20, 2026

There is no need to have different names for the same props in chat and chat_list_item. So let's rename them:

  • is_self_in_group → self_in_group
  • is_archived → archived
  • is_pinned → pinned
  • avatar_path → profile_image
  • is_device_chat → is_device_talk

There is no need to have different names for the same props in chat and
chatListItem. So let's rename them:
- is_self_in_group → self_in_group
- is_archived → archived
- is_pinned → pinned
- avatar_path → profile_image
- is_device_chat → is_device_talk
@nicodh
Copy link
Contributor Author

nicodh commented Jan 20, 2026

clippy recommends to box the enum to avoid the linting error. So would ChatListItem(Box) with a pub struct ChatListItemData holding all the fields would be the way to go here?

Or just add #[allow(clippy::large_enum_variant)] like it is done in lot.rs ?

@iequidoo
Copy link
Collaborator

Or just add #[allow(clippy::large_enum_variant)] like it is done in lot.rs ?

#[expect(clippy::large_enum_variant)] then to not forget to remove it. It's fine, this is a temporary problem anyway.

@Hocuri
Copy link
Collaborator

Hocuri commented Jan 22, 2026

Why is it a temporary problem? The struct is only going to get larger, not smaller. But the good thing is that the vast majority of ChatListItemFetchResult will be ChatListItem, and only a very small part of them are ArchiveLink or Error (at least I assume so - @nicodh is this true?) So, we don't waste too much memory by not boxing and adding #[expect(clippy::large_enum_variant)].

The problem with boxing is that the serialized JSON could change. Maybe not, maybe it's fine.

But, as I said, just adding #[expect(clippy::large_enum_variant)] is fine.

Comment on lines 166 to 176
is_self_in_group: chat.is_self_in_chat(ctx).await?,
self_in_group: chat.is_self_in_chat(ctx).await?,
Copy link
Collaborator

Choose a reason for hiding this comment

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

chat.is_self_in_chat(ctx).await? is quite an expensive call, as it does a database request (just as most async functions). So, you should put let self_in_group = chat.is_self_in_chat(ctx).await?; above, and then use the variable here.

Copy link
Contributor

@r10s r10s Jan 22, 2026

Choose a reason for hiding this comment

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

i am wondering if [is]_self_in_group field is needed at all, esp. when it comes at costs.

[is]_self_in_group is currently only used to check whether to show the "N members" subtitle or "...", but that is probably not the ChalistItem then. and even if, it could be done by checking the anyway loaded contact list for CONTACT_ID_SELF (android code, desktop code)

(as a rule of thumb, we should try to avoid database calls needed to set a property that is not always needed - otherwise we have for the chatlist lots of never needed database calls, cffi is pretty strict on that, jsonrpc less in the past, resulting in hard to get slownesses, we're getting better there, but we should avoid that in the future)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on that property we show the "leave group" context menu item, In chatlist where don't have the contact IDs of each listed group so we can't check if CONTACT_ID_SELF is in that list.

This precalculated property should avoid that we have to load the full chat when opening the context menu.

But in the end an extra DB call for each group item in the chat list (which is shown all the time) might be more expensive than the less frequent case, when the context menu item is opened. I would say it's fine to load the full chat when the context menu is opened (which I just introduced in the last refactoring) and then check in the contact list.

So let's get rid of self_in_group

@iequidoo
Copy link
Collaborator

Why is it a temporary problem? The struct is only going to get larger, not smaller.

When the deprected fields are removed eventually, clippy will stop to complain (but we should recheck). So i think suppressing the clippy error is fine for now, let's not optimize too early.

allow clippy::large_enum_variant
Co-authored-by: iequidoo <117991069+iequidoo@users.noreply.github.com>
is_self_talk: bool,
is_device_talk: bool,
is_sending_location: bool,
/// deprecated 2026-01
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// deprecated 2026-01
/// deprecated 2026-01, load the chat and check `self_in_group` instead

is_device_chat: bool,
/// Note that this is different from
/// [`ChatListItem::is_self_in_group`](`crate::api::types::chat_list::ChatListItemFetchResult::ChatListItem::is_self_in_group`).
/// [`ChatListItem::self_in_group`](`crate::api::types::chat_list::ChatListItemFetchResult::ChatListItem::self_in_group`).
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is wrong, then (apparently cargo doctest doesn't run in CI for deltachat-jsonrpc? Otherwise, it would have caught that).

Can just revert to the previous comment

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.

5 participants