Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112702
matrix-sticker-pack-list.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
matrix-sticker-pack-list.cpp
View Options
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include
<kazv-defs.hpp>
#include
<lager/lenses/optional.hpp>
#include
<lager/lenses/at.hpp>
#include
"matrix-sticker-pack.hpp"
#include
"matrix-sticker-pack-list.hpp"
using
namespace
Kazv
;
static
const
std
::
string
accountDataEventType
=
"im.ponies.user_emotes"
;
lager
::
reader
<
immer
::
flex_vector
<
MatrixStickerPackSource
>>
getEventsFromClient
(
Client
client
)
{
lager
::
reader
<
Event
>
userEmotes
=
client
.
accountData
()[
accountDataEventType
][
lager
::
lenses
::
or_default
];
return
userEmotes
.
map
([](
Event
e
)
{
return
immer
::
flex_vector
<
MatrixStickerPackSource
>
{
{
MatrixStickerPackSource
::
AccountData
,
accountDataEventType
,
e
},
};
});
}
MatrixStickerPackList
::
MatrixStickerPackList
(
Client
client
,
QObject
*
parent
)
:
KazvAbstractListModel
(
parent
)
,
m_client
(
client
)
,
m_events
(
getEventsFromClient
(
m_client
))
{
initCountCursor
(
m_events
.
map
([](
const
auto
&
events
)
{
return
static_cast
<
int
>
(
events
.
size
());
}));
}
MatrixStickerPackList
::~
MatrixStickerPackList
()
=
default
;
MatrixStickerPack
*
MatrixStickerPackList::at
(
int
index
)
const
{
return
new
MatrixStickerPack
(
m_events
.
map
([
index
](
const
auto
&
events
)
{
if
(
events
.
size
()
>
std
::
size_t
(
index
))
{
return
events
[
index
];
}
else
{
return
MatrixStickerPackSource
{
MatrixStickerPackSource
::
AccountData
,
accountDataEventType
,
Event
(),
};
}
}));
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, Nov 23, 10:17 PM (1 d, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39162
Default Alt Text
matrix-sticker-pack-list.cpp (1 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment