Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7892152
State.qml
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
State.qml
View Options
/*
* Copyright (C) 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
import
QtQuick
2.2
import
QtQuick
.
Layouts
1.15
import
QtQuick
.
Controls
2.15
import
org
.
kde
.
kirigami
2.13
as
Kirigami
import
'.'
as
Types
Types
.
TextTemplate
{
id: upper
text:
getText
()
Label
{
text:
'->'
}
function
getText
()
{
switch
(
event
.
type
)
{
case
'm.room.member'
:
return
getMemberChange
();
default:
return
event
.
content
.
body
;
}
}
function
getMemberChange
()
{
const
newState
=
event
.
content
.
membership
;
// If there were no previous content, we consider that the room
// never knew this member.
const
prevContent
=
event
.
unsignedData
.
prev_content
||
{};
const
oldState
=
prevContent
.
membership
||
'leave'
;
// Someone changing their own member state
const
isSelfSent
=
event
.
stateKey
===
event
.
sender
;
const
gender
=
'neutral'
;
if
(
newState
===
'join'
)
{
if
(
oldState
!==
'join'
)
{
return
l10n
.
get
(
'member-state-joined-room'
);
}
else
{
const
nameChanged
=
event
.
content
.
displayname
!==
prevContent
.
displayname
;
const
avatarChanged
=
event
.
content
.
avatar_url
!==
prevContent
.
avatar_url
;
if
(
nameChanged
&&
avatarChanged
)
{
return
l10n
.
get
(
'member-state-changed-name-and-avatar'
,
{
gender
});
}
else
if
(
nameChanged
)
{
return
l10n
.
get
(
'member-state-changed-name'
,
{
gender
});
}
else
if
(
avatarChanged
)
{
return
l10n
.
get
(
'member-state-changed-avatar'
,
{
gender
});
}
else
{
return
''
;
// stayed in the room without name/avatar change. should not happen
}
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 2, 4:13 AM (9 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
487230
Default Alt Text
State.qml (2 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment