feat(StatusChatList): introduce `profileImageFn` property

This property enables users to pass as factory function to `StatusChatList`
component that determines the profile image of a given chat id.

Usage:

```qml
import StatusQ.Components 0.1

StatusChatList {
    ...
    profileImageFn: function (id) {
        // `id` is the model id of the current chat item iterator
        return ... // has to return a profile image url
    }
}
```

In addition to this property, this commit also makes the component
expect an optional `model.identityImage` in case it's already provided.
That way, `profileImageFn` can be omitted.

Closes #174
This commit is contained in:
Pascal Precht 2021-06-24 14:34:45 +02:00 committed by Pascal Precht
parent baa663cea6
commit cfacd5be6d
1 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,7 @@ Column {
property Component popupMenu
property var filterFn
property var profileImageFn
signal chatItemSelected(string id)
signal chatItemUnmuted(string id)
@ -42,7 +43,13 @@ Column {
selected: model.chatId === statusChatList.selectedChatId
icon.color: model.color || ""
image.source: model.identicon || ""
image.source: {
let profileImage = ""
if (typeof statusChatList.profileImageFn === "function") {
profileImage = statusChatList.profileImageFn(model.chatId || model.id)
}
return profileImage || model.identityImage || model.identicon || ""
}
onClicked: {
if (mouse.button === Qt.RightButton && !!statusChatList.popupMenu) {