Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F325878
chat_new.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
chat_new.js
View Options
import
{
mapState
,
mapGetters
}
from
'vuex'
import
BasicUserCard
from
'../basic_user_card/basic_user_card.vue'
import
UserAvatar
from
'../user_avatar/user_avatar.vue'
const
chatNew
=
{
components
:
{
BasicUserCard
,
UserAvatar
},
data
()
{
return
{
suggestions
:
[],
userIds
:
[],
loading
:
false
,
query
:
''
}
},
async
created
()
{
const
{
chats
}
=
await
this
.
backendInteractor
.
chats
()
chats
.
forEach
(
chat
=>
this
.
suggestions
.
push
(
chat
.
account
))
},
computed
:
{
users
()
{
return
this
.
userIds
.
map
(
userId
=>
this
.
findUser
(
userId
))
},
availableUsers
()
{
if
(
this
.
query
.
length
!==
0
)
{
return
this
.
users
}
else
{
return
this
.
suggestions
}
},
...
mapState
({
currentUser
:
state
=>
state
.
users
.
currentUser
,
backendInteractor
:
state
=>
state
.
api
.
backendInteractor
}),
...
mapGetters
([
'findUser'
])
},
methods
:
{
goBack
()
{
this
.
$emit
(
'cancel'
)
},
goToChat
(
user
)
{
this
.
$router
.
push
({
name
:
'chat'
,
params
:
{
recipient_id
:
user
.
id
}
})
},
onInput
()
{
this
.
search
(
this
.
query
)
},
addUser
(
user
)
{
this
.
selectedUserIds
.
push
(
user
.
id
)
this
.
query
=
''
},
removeUser
(
userId
)
{
this
.
selectedUserIds
=
this
.
selectedUserIds
.
filter
(
id
=>
id
!==
userId
)
},
search
(
query
)
{
if
(
!
query
)
{
this
.
loading
=
false
return
}
this
.
loading
=
true
this
.
userIds
=
[]
this
.
$store
.
dispatch
(
'search'
,
{
q
:
query
,
resolve
:
true
,
type
:
'accounts'
})
.
then
(
data
=>
{
this
.
loading
=
false
this
.
userIds
=
data
.
accounts
.
map
(
a
=>
a
.
id
)
})
}
}
}
export
default
chatNew
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 24, 4:26 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
95014
Default Alt Text
chat_new.js (1 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline
Log In to Comment