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
74f9952b
Commit
74f9952b
authored
Apr 22, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `sendChatState` methods to the models
parent
2850ef04
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
37 deletions
+40
-37
src/converse-chatboxes.js
src/converse-chatboxes.js
+16
-0
src/converse-chatview.js
src/converse-chatview.js
+1
-15
src/converse-muc-views.js
src/converse-muc-views.js
+0
-22
src/converse-muc.js
src/converse-muc.js
+23
-0
No files found.
src/converse-chatboxes.js
View file @
74f9952b
...
...
@@ -207,6 +207,8 @@
}
});
this
.
on
(
'
change:chat_state
'
,
this
.
sendChatState
,
this
);
this
.
save
({
// The chat_state will be set to ACTIVE once the chat box is opened
// and we listen for change:chat_state, so shouldn't set it to ACTIVE here.
...
...
@@ -287,6 +289,20 @@
this
.
sendMessageStanza
(
this
.
messages
.
create
(
attrs
));
},
sendChatState
()
{
/* Sends a message with the status of the user in this chat session
* as taken from the 'chat_state' attribute of the chat box.
* See XEP-0085 Chat State Notifications.
*/
_converse
.
connection
.
send
(
$msg
({
'
to
'
:
this
.
get
(
'
jid
'
),
'
type
'
:
'
chat
'
})
.
c
(
this
.
get
(
'
chat_state
'
),
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
()
.
c
(
'
no-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
}).
up
()
.
c
(
'
no-permanent-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
})
);
},
sendFiles
(
files
)
{
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
).
then
((
result
)
=>
{
const
item
=
result
.
pop
(),
...
...
src/converse-chatview.js
View file @
74f9952b
...
...
@@ -264,7 +264,6 @@
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
this
.
model
.
on
(
'
destroy
'
,
this
.
remove
,
this
);
// TODO check for changed fullname as well
this
.
model
.
on
(
'
change:chat_state
'
,
this
.
sendChatState
,
this
);
this
.
model
.
on
(
'
change:chat_status
'
,
this
.
onChatStatusChanged
,
this
);
this
.
model
.
on
(
'
showHelpMessages
'
,
this
.
showHelpMessages
,
this
);
this
.
render
();
...
...
@@ -759,19 +758,6 @@
this
.
model
.
sendMessage
(
attrs
);
},
sendChatState
()
{
/* Sends a message with the status of the user in this chat session
* as taken from the 'chat_state' attribute of the chat box.
* See XEP-0085 Chat State Notifications.
*/
_converse
.
connection
.
send
(
$msg
({
'
to
'
:
this
.
model
.
get
(
'
jid
'
),
'
type
'
:
'
chat
'
})
.
c
(
this
.
model
.
get
(
'
chat_state
'
),
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
()
.
c
(
'
no-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
}).
up
()
.
c
(
'
no-permanent-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
})
);
},
setChatState
(
state
,
no_save
)
{
/* Mutator for setting the chat state of this chat session.
* Handles clearing of any chat state notification timeouts and
...
...
@@ -957,7 +943,7 @@
// Immediately sending the chat state, because the
// model is going to be destroyed afterwards.
this
.
setChatState
(
_converse
.
INACTIVE
);
this
.
sendChatState
();
this
.
model
.
sendChatState
();
}
try
{
this
.
model
.
destroy
();
...
...
src/converse-muc-views.js
View file @
74f9952b
...
...
@@ -520,7 +520,6 @@
this
.
model
.
messages
.
on
(
'
rendered
'
,
this
.
scrollDown
,
this
);
this
.
model
.
on
(
'
change:affiliation
'
,
this
.
renderHeading
,
this
);
this
.
model
.
on
(
'
change:chat_state
'
,
this
.
sendChatState
,
this
);
this
.
model
.
on
(
'
change:connection_status
'
,
this
.
afterConnected
,
this
);
this
.
model
.
on
(
'
change:description
'
,
this
.
renderHeading
,
this
);
this
.
model
.
on
(
'
change:name
'
,
this
.
renderHeading
,
this
);
...
...
@@ -732,27 +731,6 @@
}
},
sendChatState
()
{
/* Sends a message with the status of the user in this chat session
* as taken from the 'chat_state' attribute of the chat box.
* See XEP-0085 Chat State Notifications.
*/
if
(
this
.
model
.
get
(
'
connection_status
'
)
!==
converse
.
ROOMSTATUS
.
ENTERED
)
{
return
;
}
const
chat_state
=
this
.
model
.
get
(
'
chat_state
'
);
if
(
chat_state
===
_converse
.
GONE
)
{
// <gone/> is not applicable within MUC context
return
;
}
_converse
.
connection
.
send
(
$msg
({
'
to
'
:
this
.
model
.
get
(
'
jid
'
),
'
type
'
:
'
groupchat
'
})
.
c
(
chat_state
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
()
.
c
(
'
no-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
}).
up
()
.
c
(
'
no-permanent-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
})
);
},
sendChatRoomMessage
(
text
)
{
/* Constuct a message stanza to be sent to this chat room,
* and send it to the server.
...
...
src/converse-muc.js
View file @
74f9952b
...
...
@@ -191,6 +191,8 @@
this
.
constructor
.
__super__
.
initialize
.
apply
(
this
,
arguments
);
this
.
occupants
=
new
_converse
.
ChatRoomOccupants
();
this
.
registerHandlers
();
this
.
on
(
'
change:chat_state
'
,
this
.
sendChatState
,
this
);
},
registerHandlers
()
{
...
...
@@ -349,6 +351,27 @@
_converse
.
connection
.
send
(
stanza
);
},
sendChatState
()
{
/* Sends a message with the status of the user in this chat session
* as taken from the 'chat_state' attribute of the chat box.
* See XEP-0085 Chat State Notifications.
*/
if
(
this
.
get
(
'
connection_status
'
)
!==
converse
.
ROOMSTATUS
.
ENTERED
)
{
return
;
}
const
chat_state
=
this
.
get
(
'
chat_state
'
);
if
(
chat_state
===
_converse
.
GONE
)
{
// <gone/> is not applicable within MUC context
return
;
}
_converse
.
connection
.
send
(
$msg
({
'
to
'
:
this
.
get
(
'
jid
'
),
'
type
'
:
'
groupchat
'
})
.
c
(
chat_state
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
()
.
c
(
'
no-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
}).
up
()
.
c
(
'
no-permanent-store
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
HINTS
})
);
},
directInvite
(
recipient
,
reason
)
{
/* Send a direct invitation as per XEP-0249
*
...
...
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