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
e06a34a9
Commit
e06a34a9
authored
Jun 22, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some initial work on show messages with type "error"
parent
9e8674ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
19 deletions
+50
-19
src/converse-chatview.js
src/converse-chatview.js
+11
-1
src/converse-core.js
src/converse-core.js
+39
-18
No files found.
src/converse-chatview.js
View file @
e06a34a9
...
...
@@ -366,6 +366,14 @@
}
},
handleErrorMessage
:
function
(
message
)
{
var
$message
=
$
(
'
[data-msgid=
'
+
message
.
get
(
'
msgid
'
)
+
'
]
'
);
if
(
$message
.
length
)
{
$message
.
after
(
$
(
'
<div class="chat-error"></div>
'
).
text
(
message
.
get
(
'
message
'
)));
this
.
scrollDown
();
}
},
onMessageAdded
:
function
(
message
)
{
/* Handler that gets called when a new message object is created.
*
...
...
@@ -376,7 +384,9 @@
window
.
clearTimeout
(
this
.
clear_status_timeout
);
delete
this
.
clear_status_timeout
;
}
if
(
!
message
.
get
(
'
message
'
))
{
if
(
message
.
get
(
'
type
'
)
===
'
error
'
)
{
this
.
handleErrorMessage
(
message
);
}
else
if
(
!
message
.
get
(
'
message
'
))
{
this
.
handleChatStateMessage
(
message
);
}
else
{
this
.
handleTextMessage
(
message
);
...
...
src/converse-core.js
View file @
e06a34a9
...
...
@@ -1255,16 +1255,22 @@
getMessageAttributes
:
function
(
$message
,
$delay
,
original_stanza
)
{
$delay
=
$delay
||
$message
.
find
(
'
delay
'
);
var
body
=
$message
.
children
(
'
body
'
).
text
(),
delayed
=
$delay
.
length
>
0
,
var
type
=
$message
.
attr
(
'
type
'
),
body
,
stamp
,
time
,
sender
,
from
;
if
(
type
===
'
error
'
)
{
body
=
$message
.
find
(
'
error
'
).
children
(
'
text
'
).
text
();
}
else
{
body
=
$message
.
children
(
'
body
'
).
text
();
}
var
delayed
=
$delay
.
length
>
0
,
fullname
=
this
.
get
(
'
fullname
'
),
is_groupchat
=
$message
.
attr
(
'
type
'
)
===
'
groupchat
'
,
is_groupchat
=
type
===
'
groupchat
'
,
chat_state
=
$message
.
find
(
converse
.
COMPOSING
).
length
&&
converse
.
COMPOSING
||
$message
.
find
(
converse
.
PAUSED
).
length
&&
converse
.
PAUSED
||
$message
.
find
(
converse
.
INACTIVE
).
length
&&
converse
.
INACTIVE
||
$message
.
find
(
converse
.
ACTIVE
).
length
&&
converse
.
ACTIVE
||
$message
.
find
(
converse
.
GONE
).
length
&&
converse
.
GONE
,
stamp
,
time
,
sender
,
from
;
$message
.
find
(
converse
.
GONE
).
length
&&
converse
.
GONE
;
if
(
is_groupchat
)
{
from
=
Strophe
.
unescapeNode
(
Strophe
.
getResourceFromJid
(
$message
.
attr
(
'
from
'
)));
...
...
@@ -1286,13 +1292,14 @@
sender
=
'
them
'
;
}
return
{
chat_state
:
chat_state
,
delayed
:
delayed
,
fullname
:
fullname
,
message
:
body
||
undefined
,
msgid
:
$message
.
attr
(
'
id
'
),
sender
:
sender
,
time
:
time
'
type
'
:
type
,
'
chat_state
'
:
chat_state
,
'
delayed
'
:
delayed
,
'
fullname
'
:
fullname
,
'
message
'
:
body
||
undefined
,
'
msgid
'
:
$message
.
attr
(
'
id
'
),
'
sender
'
:
sender
,
'
time
'
:
time
};
},
...
...
@@ -1306,11 +1313,8 @@
comparator
:
'
time_opened
'
,
registerMessageHandler
:
function
()
{
converse
.
connection
.
addHandler
(
function
(
message
)
{
this
.
onMessage
(
message
);
return
true
;
}.
bind
(
this
),
null
,
'
message
'
,
'
chat
'
);
converse
.
connection
.
addHandler
(
this
.
onMessage
.
bind
(
this
),
null
,
'
message
'
,
'
chat
'
);
converse
.
connection
.
addHandler
(
this
.
onErrorMessage
.
bind
(
this
),
null
,
'
message
'
,
'
error
'
);
},
chatBoxMayBeShown
:
function
(
chatbox
)
{
...
...
@@ -1341,6 +1345,24 @@
});
},
onErrorMessage
:
function
(
message
)
{
/* Handler method for all incoming error message stanzas
*/
// TODO: we can likely just reuse "onMessage" below
var
$message
=
$
(
message
),
from_jid
=
Strophe
.
getBareJidFromJid
(
$message
.
attr
(
'
from
'
));
if
(
from_jid
===
converse
.
bare_jid
)
{
return
true
;
}
// Get chat box, but only create a new one when the message has a body.
var
chatbox
=
this
.
getChatBox
(
from_jid
);
if
(
!
chatbox
)
{
return
true
;
}
chatbox
.
createMessage
(
$message
,
null
,
message
);
return
true
;
},
onMessage
:
function
(
message
)
{
/* Handler method for all incoming single-user chat "message"
* stanzas.
...
...
@@ -1380,7 +1402,6 @@
from_resource
=
Strophe
.
getResourceFromJid
(
from_jid
);
is_me
=
from_bare_jid
===
converse
.
bare_jid
;
msgid
=
$message
.
attr
(
'
id
'
);
if
(
is_me
)
{
// I am the sender, so this must be a forwarded message...
contact_jid
=
Strophe
.
getBareJidFromJid
(
to_jid
);
...
...
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