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
c20dbbbb
Commit
c20dbbbb
authored
Mar 31, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store in user settings whether a MUC topic is hidden or not
parent
e4986573
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
36 deletions
+53
-36
spec/bookmarks.js
spec/bookmarks.js
+4
-4
spec/muc.js
spec/muc.js
+8
-5
src/converse-bookmark-views.js
src/converse-bookmark-views.js
+2
-2
src/converse-minimize.js
src/converse-minimize.js
+2
-2
src/converse-muc-views.js
src/converse-muc-views.js
+31
-20
src/headless/converse-core.js
src/headless/converse-core.js
+4
-2
tests/mock.js
tests/mock.js
+2
-1
No files found.
spec/bookmarks.js
View file @
c20dbbbb
...
...
@@ -224,9 +224,9 @@
'
nick
'
:
'
some1
'
});
view
.
model
.
set
(
'
bookmarked
'
,
true
);
expect
(
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)).
not
.
toBe
(
null
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)
!==
null
);
view
.
model
.
set
(
'
bookmarked
'
,
false
);
expect
(
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)).
toBe
(
null
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)
===
null
);
done
();
}));
...
...
@@ -253,12 +253,12 @@
expect
(
_converse
.
bookmarks
.
length
).
toBe
(
1
);
await
u
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
>=
1
);
expect
(
view
.
model
.
get
(
'
bookmarked
'
)).
toBeTruthy
();
expect
(
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)).
not
.
toBe
(
null
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)
!==
null
);
spyOn
(
_converse
.
connection
,
'
getUniqueId
'
).
and
.
callThrough
();
const
bookmark_icon
=
view
.
el
.
querySelector
(
'
.toggle-bookmark
'
);
bookmark_icon
.
click
();
expect
(
view
.
toggleBookmark
).
toHaveBeenCalled
();
expect
(
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)).
toBe
(
null
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chatbox-title__text .fa-bookmark
'
)
===
null
);
expect
(
_converse
.
bookmarks
.
length
).
toBe
(
0
);
// Check that an IQ stanza is sent out, containing no
...
...
spec/muc.js
View file @
c20dbbbb
...
...
@@ -611,6 +611,8 @@
await
u
.
waitUntil
(()
=>
sent_stanzas
.
filter
(
iq
=>
sizzle
(
'
presence history
'
,
iq
).
length
).
pop
());
const
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
await
_converse
.
api
.
waitUntil
(
'
chatRoomViewInitialized
'
);
/* We don't show join/leave messages for existing occupants. We
* know about them because we receive their presences before we
* receive our own.
...
...
@@ -646,8 +648,8 @@
}).
up
()
.
c
(
'
status
'
,
{
code
:
'
110
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
sizzle
(
'
div.chat-info:first
'
,
view
.
content
).
pop
().
textContent
.
trim
())
.
toBe
(
"
some1 has entered the groupchat
"
);
const
text
=
await
u
.
waitUntil
(()
=>
sizzle
(
'
div.chat-info:first
'
,
view
.
content
).
pop
()?.
textContent
);
expect
(
text
.
trim
())
.
toBe
(
"
some1 has entered the groupchat
"
);
await
room_creation_promise
;
await
u
.
waitUntil
(()
=>
(
view
.
model
.
session
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
ENTERED
));
...
...
@@ -664,7 +666,7 @@
'
role
'
:
'
participant
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
content
.
querySelectorAll
(
'
div.chat-info
'
).
length
).
toBe
(
2
);
await
u
.
waitUntil
(()
=>
view
.
content
.
querySelectorAll
(
'
div.chat-info
'
).
length
===
2
);
expect
(
sizzle
(
'
div.chat-info:last
'
,
view
.
content
).
pop
().
textContent
.
trim
())
.
toBe
(
"
newguy has entered the groupchat
"
);
...
...
@@ -2166,7 +2168,8 @@
await
new
Promise
(
resolve
=>
view
.
model
.
once
(
'
change:subject
'
,
resolve
));
expect
(
sizzle
(
'
.chat-event:last
'
,
view
.
el
).
pop
().
textContent
.
trim
()).
toBe
(
'
Topic set by ralphm
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-head__desc
'
).
textContent
.
trim
()).
toBe
(
text
);
const
head_desc
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-head__desc
'
));
expect
(
head_desc
?.
textContent
.
trim
()).
toBe
(
text
);
stanza
=
u
.
toStanza
(
`<message xmlns="jabber:client" to="jc@opkode.com/_converse.js-60429116" type="groupchat" from="jdev@conference.jabber.org/ralphm">
...
...
@@ -2188,7 +2191,7 @@
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
new
Promise
(
resolve
=>
view
.
model
.
once
(
'
change:subject
'
,
resolve
));
expect
(
view
.
el
.
querySelector
(
'
.chat-head__desc
'
)).
toBe
(
null
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-head__desc
'
)
===
null
);
expect
(
view
.
el
.
querySelector
(
'
.chat-info:last-child
'
).
textContent
.
trim
()).
toBe
(
"
Topic cleared by ralphm
"
);
done
();
}));
...
...
src/converse-bookmark-views.js
View file @
c20dbbbb
...
...
@@ -36,9 +36,9 @@ converse.plugins.add('converse-bookmark-views', {
// plugin architecture they will replace existing methods on the
// relevant objects or classes.
ChatRoomView
:
{
getHeadingButtons
()
{
async
getHeadingButtons
()
{
const
{
_converse
}
=
this
.
__super__
;
const
buttons
=
this
.
__super__
.
getHeadingButtons
.
call
(
this
);
const
buttons
=
await
this
.
__super__
.
getHeadingButtons
.
call
(
this
);
if
(
_converse
.
allow_bookmarks
)
{
const
supported
=
_converse
.
checkBookmarksSupport
();
const
bookmarked
=
this
.
model
.
get
(
'
bookmarked
'
);
...
...
src/converse-minimize.js
View file @
c20dbbbb
...
...
@@ -139,9 +139,9 @@ converse.plugins.add('converse-minimize', {
return
result
;
},
getHeadingButtons
()
{
async
getHeadingButtons
()
{
const
{
_converse
}
=
this
.
__super__
;
const
buttons
=
this
.
__super__
.
getHeadingButtons
.
call
(
this
);
const
buttons
=
await
this
.
__super__
.
getHeadingButtons
.
call
(
this
);
const
data
=
{
'
a_class
'
:
'
toggle-chatbox-button
'
,
'
handler
'
:
ev
=>
this
.
minimize
(
ev
),
...
...
src/converse-muc-views.js
View file @
c20dbbbb
...
...
@@ -725,7 +725,7 @@ converse.plugins.add('converse-muc-views', {
this
.
onMouseMove
=
this
.
onMouseMove
.
bind
(
this
);
this
.
onMouseUp
=
this
.
onMouseUp
.
bind
(
this
);
this
.
render
();
await
this
.
render
();
this
.
createSidebarView
();
await
this
.
updateAfterMessagesFetched
();
this
.
onConnectionStatusChanged
();
...
...
@@ -739,13 +739,13 @@ converse.plugins.add('converse-muc-views', {
api
.
trigger
(
'
chatRoomViewInitialized
'
,
this
);
},
render
()
{
async
render
()
{
this
.
el
.
setAttribute
(
'
id
'
,
this
.
model
.
get
(
'
box_id
'
));
render
(
tpl_chatroom
({
'
muc_show_logs_before_join
'
:
_converse
.
muc_show_logs_before_join
,
'
show_send_button
'
:
_converse
.
show_send_button
}),
this
.
el
);
this
.
renderHeading
();
await
this
.
renderHeading
();
this
.
renderBottomPanel
();
this
.
content
=
this
.
el
.
querySelector
(
'
.chat-content
'
);
this
.
msgs_container
=
this
.
el
.
querySelector
(
'
.chat-content__messages
'
);
...
...
@@ -802,8 +802,9 @@ converse.plugins.add('converse-muc-views', {
* @method _converse.ChatRoomView#renderHeading
* @param { _converse.ChatRoom } [item]
*/
renderHeading
()
{
render
(
this
.
generateHeadingTemplate
(),
this
.
el
.
querySelector
(
'
.chat-head-chatroom
'
));
async
renderHeading
()
{
const
tpl
=
await
this
.
generateHeadingTemplate
();
render
(
tpl
,
this
.
el
.
querySelector
(
'
.chat-head-chatroom
'
));
},
...
...
@@ -1156,7 +1157,7 @@ converse.plugins.add('converse-muc-views', {
}
},
getHeadingButtons
()
{
async
getHeadingButtons
()
{
const
buttons
=
[{
'
i18n_text
'
:
__
(
'
Details
'
),
'
i18n_title
'
:
__
(
'
Show more information about this groupchat
'
),
...
...
@@ -1212,11 +1213,14 @@ converse.plugins.add('converse-muc-views', {
});
}
const
muc_jid
=
this
.
model
.
get
(
'
jid
'
);
const
jids
=
await
api
.
user
.
settings
.
get
(
'
mucs_with_hidden_subject
'
,
[])
const
subject_hidden
=
jids
.
includes
(
muc_jid
);
const
subject
=
this
.
model
.
get
(
'
subject
'
);
if
(
subject
&&
subject
.
text
)
{
buttons
.
push
({
'
i18n_text
'
:
this
.
model
.
get
(
'
subject_hidden
'
)
?
__
(
'
Show topic
'
)
:
__
(
'
Hide topic
'
),
'
i18n_title
'
:
this
.
model
.
get
(
'
subject_hidden
'
)
?
'
i18n_text
'
:
subject_hidden
?
__
(
'
Show topic
'
)
:
__
(
'
Hide topic
'
),
'
i18n_title
'
:
subject_hidden
?
__
(
'
Show the topic message in the heading
'
)
:
__
(
'
Hide the topic in the heading
'
),
'
handler
'
:
ev
=>
this
.
toggleTopic
(
ev
),
...
...
@@ -1249,8 +1253,8 @@ converse.plugins.add('converse-muc-views', {
* @private
* @method _converse.ChatRoomView#generateHeadingTemplate
*/
generateHeadingTemplate
()
{
const
heading_btns
=
this
.
getHeadingButtons
();
async
generateHeadingTemplate
()
{
const
heading_btns
=
await
this
.
getHeadingButtons
();
const
standalone_btns
=
heading_btns
.
filter
(
b
=>
b
.
standalone
);
const
dropdown_btns
=
heading_btns
.
filter
(
b
=>
!
b
.
standalone
);
return
tpl_chatroom_head
(
...
...
@@ -1262,11 +1266,16 @@ converse.plugins.add('converse-muc-views', {
}));
},
toggleTopic
()
{
this
.
model
.
save
(
'
subject_hidden
'
,
!
this
.
model
.
get
(
'
subject_hidden
'
));
async
toggleTopic
()
{
const
muc_jid
=
this
.
model
.
get
(
'
jid
'
);
const
jids
=
await
api
.
user
.
settings
.
get
(
'
mucs_with_hidden_subject
'
,
[]);
if
(
jids
.
includes
(
this
.
model
.
get
(
'
jid
'
)))
{
api
.
user
.
settings
.
set
(
'
mucs_with_hidden_subject
'
,
jids
.
filter
(
jid
=>
jid
!==
muc_jid
));
}
else
{
api
.
user
.
settings
.
set
(
'
mucs_with_hidden_subject
'
,
[...
jids
,
muc_jid
]);
}
},
showInviteModal
(
ev
)
{
ev
.
preventDefault
();
if
(
this
.
muc_invite_modal
===
undefined
)
{
...
...
@@ -1950,15 +1959,16 @@ converse.plugins.add('converse-muc-views', {
}
},
showJoinNotification
(
occupant
)
{
async
showJoinNotification
(
occupant
)
{
if
(
!
_converse
.
muc_show_join_leave
||
this
.
model
.
session
.
get
(
'
connection_status
'
)
!==
converse
.
ROOMSTATUS
.
ENTERED
)
{
return
;
}
const
nick
=
occupant
.
get
(
'
nick
'
),
stat
=
_converse
.
muc_show_join_leave_status
?
occupant
.
get
(
'
status
'
)
:
null
,
prev_info_el
=
this
.
getPreviousJoinOrLeaveNotification
(
this
.
msgs_container
.
lastElementChild
,
nick
),
data
=
prev_info_el
?.
dataset
||
{};
await
api
.
waitUntil
(
'
chatRoomViewInitialized
'
);
const
nick
=
occupant
.
get
(
'
nick
'
);
const
stat
=
_converse
.
muc_show_join_leave_status
?
occupant
.
get
(
'
status
'
)
:
null
;
const
prev_info_el
=
this
.
getPreviousJoinOrLeaveNotification
(
this
.
msgs_container
.
lastElementChild
,
nick
);
const
data
=
prev_info_el
?.
dataset
||
{};
if
(
data
.
leave
===
nick
)
{
let
message
;
...
...
@@ -2004,12 +2014,13 @@ converse.plugins.add('converse-muc-views', {
this
.
scrollDown
();
},
showLeaveNotification
(
occupant
)
{
if
(
!
_converse
.
muc_show_join_leave
||
async
showLeaveNotification
(
occupant
)
{
if
(
!
api
.
settings
.
get
(
'
muc_show_join_leave
'
)
||
occupant
.
get
(
'
states
'
).
includes
(
'
303
'
)
||
occupant
.
get
(
'
states
'
).
includes
(
'
307
'
))
{
return
;
}
await
api
.
waitUntil
(
'
chatRoomViewInitialized
'
);
const
nick
=
occupant
.
get
(
'
nick
'
),
stat
=
_converse
.
muc_show_join_leave_status
?
occupant
.
get
(
'
status
'
)
:
null
,
prev_info_el
=
this
.
getPreviousJoinOrLeaveNotification
(
this
.
msgs_container
.
lastElementChild
,
nick
),
...
...
src/headless/converse-core.js
View file @
c20dbbbb
...
...
@@ -532,12 +532,14 @@ const api = _converse.api = {
/**
* Get the value of a particular user setting.
* @method _converse.api.user.settings.get
* @param {String} key - hello world
* @param {*} fallback - An optional fallback value if the user setting is undefined
* @returns {Promise} Promise which resolves with the value of the particular configuration setting.
* @example _converse.api.user.settings.get("foo");
*/
async
get
(
key
)
{
async
get
(
key
,
fallback
)
{
await
initUserSettings
();
return
user_settings
.
get
(
key
);
return
user_settings
.
get
(
key
)
===
undefined
?
fallback
:
user_settings
.
get
(
key
)
;
},
/**
...
...
tests/mock.js
View file @
c20dbbbb
...
...
@@ -251,9 +251,10 @@
[
localStorage
,
sessionStorage
].
forEach
(
s
=>
Object
.
keys
(
s
).
forEach
(
k
=>
k
.
match
(
/^converse-test-/
)
&&
s
.
removeItem
(
k
))
);
const
cache_key
=
`converse.room-bookmarksromeo@montague.lit`
;
window
.
sessionStorage
.
removeItem
(
cache_key
+
'
fetched
'
);
}
async
function
initConverse
(
settings
)
{
clearStores
();
await
clearIndexedDB
();
...
...
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