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
6fe5ac72
Commit
6fe5ac72
authored
Mar 22, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Messages are now also saved and retrieved via backbone.localStorage
parent
b4aada01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
converse.js
converse.js
+14
-6
No files found.
converse.js
View file @
6fe5ac72
...
...
@@ -267,7 +267,6 @@
this
.
messages
=
new
xmppchat
.
Messages
();
this
.
messages
.
localStorage
=
new
Backbone
.
LocalStorage
(
hex_sha1
(
'
converse.messages
'
+
this
.
get
(
'
jid
'
)));
this
.
set
({
'
user_id
'
:
Strophe
.
getNodeFromJid
(
this
.
get
(
'
jid
'
)),
'
box_id
'
:
hex_sha1
(
this
.
get
(
'
jid
'
)),
...
...
@@ -449,18 +448,24 @@
var
message
=
$msg
({
from
:
xmppchat
.
connection
.
bare_jid
,
to
:
bare_jid
,
type
:
'
chat
'
,
id
:
timestamp
})
.
c
(
'
body
'
).
t
(
text
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
});
// Forward the message, so that other connected resources are also aware of it.
// TODO: Forward the message only to other connected resources (inside the browser)
var
forwarded
=
$msg
({
to
:
xmppchat
.
connection
.
bare_jid
,
type
:
'
chat
'
,
id
:
timestamp
})
.
c
(
'
forwarded
'
,
{
xmlns
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
delay
'
,
{
xmns
:
'
urn:xmpp:delay
'
,
stamp
:
timestamp
}).
up
()
.
cnode
(
message
.
tree
());
xmppchat
.
connection
.
send
(
message
);
xmppchat
.
connection
.
send
(
forwarded
);
this
.
appendMessage
(
text
);
// xmppchat.storage.addMessage(bare_jid, text, 'to');
// Add the new message
var
message
=
new
xmppchat
.
Message
({
fullname
:
'
me
'
,
sender
:
'
me
'
,
time
:
(
new
Date
()).
toLocaleTimeString
().
substring
(
0
,
5
),
message
:
text
});
this
.
model
.
messages
.
add
(
message
);
message
.
save
();
},
keyPressed
:
function
(
ev
)
{
...
...
@@ -470,6 +475,7 @@
composing
;
if
(
ev
.
keyCode
==
13
)
{
ev
.
preventDefault
();
message
=
$textarea
.
val
();
$textarea
.
val
(
''
).
focus
();
if
(
message
!==
''
)
{
...
...
@@ -1206,8 +1212,10 @@
xmppchat
.
rosterview
.
initialSort
();
}
else
{
view
=
new
xmppchat
.
ChatBoxView
({
model
:
item
});
// Fetch messages from localstorage
this
.
views
[
item
.
get
(
'
id
'
)]
=
view
.
render
();
view
.
$el
.
appendTo
(
this
.
$el
);
view
.
model
.
messages
.
fetch
({
add
:
true
});
this
.
showChat
(
item
.
get
(
'
id
'
));
}
},
this
);
...
...
@@ -2073,6 +2081,7 @@
this
.
chatboxes
.
localStorage
=
new
Backbone
.
LocalStorage
(
hex_sha1
(
'
converse.chatboxes-
'
+
xmppchat
.
connection
.
bare_jid
));
this
.
xmppstatus
=
new
this
.
XMPPStatus
();
this
.
chatboxesview
.
onConnected
();
this
.
connection
.
addHandler
(
...
...
@@ -2098,7 +2107,6 @@
},
this
),
null
,
'
message
'
,
'
chat
'
);
// XMPP Status
this
.
xmppstatus
=
new
this
.
XMPPStatus
();
this
.
xmppstatusview
=
new
this
.
XMPPStatusView
({
'
model
'
:
this
.
xmppstatus
});
...
...
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