Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
82b19173
Commit
82b19173
authored
Dec 17, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rosterview: Import individual lodash methods
parent
565283b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
src/converse-rosterview.js
src/converse-rosterview.js
+13
-12
No files found.
src/converse-rosterview.js
View file @
82b19173
...
@@ -10,6 +10,7 @@ import "@converse/headless/converse-chatboxes";
...
@@ -10,6 +10,7 @@ import "@converse/headless/converse-chatboxes";
import
"
@converse/headless/converse-roster
"
;
import
"
@converse/headless/converse-roster
"
;
import
"
converse-modal
"
;
import
"
converse-modal
"
;
import
"
formdata-polyfill
"
;
import
"
formdata-polyfill
"
;
import
{
compact
,
debounce
,
has
,
isString
,
uniq
,
without
}
from
"
lodash
"
;
import
{
OrderedListView
}
from
"
backbone.overview
"
;
import
{
OrderedListView
}
from
"
backbone.overview
"
;
import
SHA1
from
'
strophe.js/src/sha1
'
;
import
SHA1
from
'
strophe.js/src/sha1
'
;
import
converse
from
"
@converse/headless/converse-core
"
;
import
converse
from
"
@converse/headless/converse-core
"
;
...
@@ -22,7 +23,7 @@ import tpl_roster from "templates/roster.html";
...
@@ -22,7 +23,7 @@ import tpl_roster from "templates/roster.html";
import
tpl_roster_filter
from
"
templates/roster_filter.html
"
;
import
tpl_roster_filter
from
"
templates/roster_filter.html
"
;
import
tpl_roster_item
from
"
templates/roster_item.html
"
;
import
tpl_roster_item
from
"
templates/roster_item.html
"
;
const
{
Backbone
,
Strophe
,
_
}
=
converse
.
env
;
const
{
Backbone
,
Strophe
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
@@ -82,7 +83,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -82,7 +83,7 @@ converse.plugins.add('converse-rosterview', {
},
},
afterRender
()
{
afterRender
()
{
if
(
_converse
.
xhr_user_search_url
&&
_
.
isString
(
_converse
.
xhr_user_search_url
))
{
if
(
_converse
.
xhr_user_search_url
&&
isString
(
_converse
.
xhr_user_search_url
))
{
this
.
initXHRAutoComplete
();
this
.
initXHRAutoComplete
();
}
else
{
}
else
{
this
.
initJIDAutoComplete
();
this
.
initJIDAutoComplete
();
...
@@ -99,7 +100,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -99,7 +100,7 @@ converse.plugins.add('converse-rosterview', {
this
.
jid_auto_complete
=
new
_converse
.
AutoComplete
(
el
,
{
this
.
jid_auto_complete
=
new
_converse
.
AutoComplete
(
el
,
{
'
data
'
:
(
text
,
input
)
=>
`
${
input
.
slice
(
0
,
input
.
indexOf
(
"
@
"
))}
@
${
text
}
`
,
'
data
'
:
(
text
,
input
)
=>
`
${
input
.
slice
(
0
,
input
.
indexOf
(
"
@
"
))}
@
${
text
}
`
,
'
filter
'
:
_converse
.
FILTER_STARTSWITH
,
'
filter
'
:
_converse
.
FILTER_STARTSWITH
,
'
list
'
:
_
.
uniq
(
_converse
.
roster
.
map
(
item
=>
Strophe
.
getDomainFromJid
(
item
.
get
(
'
jid
'
))))
'
list
'
:
uniq
(
_converse
.
roster
.
map
(
item
=>
Strophe
.
getDomainFromJid
(
item
.
get
(
'
jid
'
))))
});
});
},
},
...
@@ -124,7 +125,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -124,7 +125,7 @@ converse.plugins.add('converse-rosterview', {
}
}
};
};
const
input_el
=
this
.
el
.
querySelector
(
'
input[name="name"]
'
);
const
input_el
=
this
.
el
.
querySelector
(
'
input[name="name"]
'
);
input_el
.
addEventListener
(
'
input
'
,
_
.
debounce
(()
=>
{
input_el
.
addEventListener
(
'
input
'
,
debounce
(()
=>
{
xhr
.
open
(
"
GET
"
,
`
${
_converse
.
xhr_user_search_url
}
q=
${
encodeURIComponent
(
input_el
.
value
)}
`
,
true
);
xhr
.
open
(
"
GET
"
,
`
${
_converse
.
xhr_user_search_url
}
q=
${
encodeURIComponent
(
input_el
.
value
)}
`
,
true
);
xhr
.
send
()
xhr
.
send
()
}
,
300
));
}
,
300
));
...
@@ -158,7 +159,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -158,7 +159,7 @@ converse.plugins.add('converse-rosterview', {
validateSubmission
(
jid
)
{
validateSubmission
(
jid
)
{
const
el
=
this
.
el
.
querySelector
(
'
.invalid-feedback
'
);
const
el
=
this
.
el
.
querySelector
(
'
.invalid-feedback
'
);
if
(
!
jid
||
_
.
compact
(
jid
.
split
(
'
@
'
)).
length
<
2
)
{
if
(
!
jid
||
compact
(
jid
.
split
(
'
@
'
)).
length
<
2
)
{
u
.
addClass
(
'
is-invalid
'
,
this
.
el
.
querySelector
(
'
input[name="jid"]
'
));
u
.
addClass
(
'
is-invalid
'
,
this
.
el
.
querySelector
(
'
input[name="jid"]
'
));
u
.
addClass
(
'
d-block
'
,
el
);
u
.
addClass
(
'
d-block
'
,
el
);
return
false
;
return
false
;
...
@@ -182,7 +183,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -182,7 +183,7 @@ converse.plugins.add('converse-rosterview', {
const
data
=
new
FormData
(
ev
.
target
),
const
data
=
new
FormData
(
ev
.
target
),
jid
=
(
data
.
get
(
'
jid
'
)
||
''
).
trim
();
jid
=
(
data
.
get
(
'
jid
'
)
||
''
).
trim
();
if
(
!
jid
&&
_converse
.
xhr_user_search_url
&&
_
.
isString
(
_converse
.
xhr_user_search_url
))
{
if
(
!
jid
&&
_converse
.
xhr_user_search_url
&&
isString
(
_converse
.
xhr_user_search_url
))
{
const
input_el
=
this
.
el
.
querySelector
(
'
input[name="name"]
'
);
const
input_el
=
this
.
el
.
querySelector
(
'
input[name="name"]
'
);
this
.
xhr
.
open
(
"
GET
"
,
`
${
_converse
.
xhr_user_search_url
}
q=
${
encodeURIComponent
(
input_el
.
value
)}
`
,
true
);
this
.
xhr
.
open
(
"
GET
"
,
`
${
_converse
.
xhr_user_search_url
}
q=
${
encodeURIComponent
(
input_el
.
value
)}
`
,
true
);
this
.
xhr
.
send
()
this
.
xhr
.
send
()
...
@@ -261,7 +262,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -261,7 +262,7 @@ converse.plugins.add('converse-rosterview', {
}
}
},
},
liveFilter
:
_
.
debounce
(
function
()
{
liveFilter
:
debounce
(
function
()
{
this
.
model
.
save
({
this
.
model
.
save
({
'
filter_text
'
:
this
.
el
.
querySelector
(
'
.roster-filter
'
).
value
'
filter_text
'
:
this
.
el
.
querySelector
(
'
.roster-filter
'
).
value
});
});
...
@@ -415,7 +416,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -415,7 +416,7 @@ converse.plugins.add('converse-rosterview', {
);
);
}
else
if
(
subscription
===
'
both
'
||
subscription
===
'
to
'
)
{
}
else
if
(
subscription
===
'
both
'
||
subscription
===
'
to
'
)
{
this
.
el
.
classList
.
add
(
'
current-xmpp-contact
'
);
this
.
el
.
classList
.
add
(
'
current-xmpp-contact
'
);
this
.
el
.
classList
.
remove
(
_
.
without
([
'
both
'
,
'
to
'
],
subscription
)[
0
]);
this
.
el
.
classList
.
remove
(
without
([
'
both
'
,
'
to
'
],
subscription
)[
0
]);
this
.
el
.
classList
.
add
(
subscription
);
this
.
el
.
classList
.
add
(
subscription
);
this
.
renderRosterItem
(
this
.
model
);
this
.
renderRosterItem
(
this
.
model
);
}
}
...
@@ -820,7 +821,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -820,7 +821,7 @@ converse.plugins.add('converse-rosterview', {
this
.
filter_view
.
model
.
fetch
();
this
.
filter_view
.
model
.
fetch
();
},
},
updateFilter
:
_
.
debounce
(
function
()
{
updateFilter
:
debounce
(
function
()
{
/* Filter the roster again.
/* Filter the roster again.
* Called whenever the filter settings have been changed or
* Called whenever the filter settings have been changed or
* when contacts have been added, removed or changed.
* when contacts have been added, removed or changed.
...
@@ -886,17 +887,17 @@ converse.plugins.add('converse-rosterview', {
...
@@ -886,17 +887,17 @@ converse.plugins.add('converse-rosterview', {
onContactChange
(
contact
)
{
onContactChange
(
contact
)
{
this
.
update
();
this
.
update
();
if
(
_
.
has
(
contact
.
changed
,
'
subscription
'
))
{
if
(
has
(
contact
.
changed
,
'
subscription
'
))
{
if
(
contact
.
changed
.
subscription
===
'
from
'
)
{
if
(
contact
.
changed
.
subscription
===
'
from
'
)
{
this
.
addContactToGroup
(
contact
,
_converse
.
HEADER_PENDING_CONTACTS
);
this
.
addContactToGroup
(
contact
,
_converse
.
HEADER_PENDING_CONTACTS
);
}
else
if
([
'
both
'
,
'
to
'
].
includes
(
contact
.
get
(
'
subscription
'
)))
{
}
else
if
([
'
both
'
,
'
to
'
].
includes
(
contact
.
get
(
'
subscription
'
)))
{
this
.
addExistingContact
(
contact
);
this
.
addExistingContact
(
contact
);
}
}
}
}
if
(
_
.
has
(
contact
.
changed
,
'
ask
'
)
&&
contact
.
changed
.
ask
===
'
subscribe
'
)
{
if
(
has
(
contact
.
changed
,
'
ask
'
)
&&
contact
.
changed
.
ask
===
'
subscribe
'
)
{
this
.
addContactToGroup
(
contact
,
_converse
.
HEADER_PENDING_CONTACTS
);
this
.
addContactToGroup
(
contact
,
_converse
.
HEADER_PENDING_CONTACTS
);
}
}
if
(
_
.
has
(
contact
.
changed
,
'
subscription
'
)
&&
contact
.
changed
.
requesting
===
'
true
'
)
{
if
(
has
(
contact
.
changed
,
'
subscription
'
)
&&
contact
.
changed
.
requesting
===
'
true
'
)
{
this
.
addContactToGroup
(
contact
,
_converse
.
HEADER_REQUESTING_CONTACTS
);
this
.
addContactToGroup
(
contact
,
_converse
.
HEADER_REQUESTING_CONTACTS
);
}
}
this
.
updateFilter
();
this
.
updateFilter
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment