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
c9207258
Commit
c9207258
authored
May 18, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a `clearSession` event to avoid using overrides.
parent
2508ef0e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
42 deletions
+42
-42
docs/source/events.rst
docs/source/events.rst
+5
-0
spec/chatbox.js
spec/chatbox.js
+0
-4
src/converse-bookmarks.js
src/converse-bookmarks.js
+8
-9
src/converse-controlbox.js
src/converse-controlbox.js
+14
-13
src/converse-core.js
src/converse-core.js
+3
-3
src/converse-roster.js
src/converse-roster.js
+12
-13
No files found.
docs/source/events.rst
View file @
c9207258
...
...
@@ -149,6 +149,11 @@ When a chatbox has been minimized or maximized. Relevant to converse-chatview.js
``_converse.api.listen.on('chatBoxToggled', function (chatbox) { ... });``
clearSession
~~~~~~~~~~~~
Called when the user is logging out and provides the opportunity to remove session data.
connected
~~~~~~~~~
...
...
spec/chatbox.js
View file @
c9207258
...
...
@@ -105,10 +105,6 @@
expect
(
$
(
view
.
el
).
find
(
'
.chat-msg-text:last
'
).
text
()).
toBe
(
'
wrote a 3rd person message
'
);
expect
(
$
(
view
.
el
).
find
(
'
.chat-msg-author:last
'
).
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
u
.
hasClass
(
'
chat-msg-followup
'
,
message_el
)).
toBeFalsy
();
message
=
'
This a normal message
'
;
done
();
});
});
...
...
src/converse-bookmarks.js
View file @
c9207258
...
...
@@ -51,15 +51,6 @@
//
// New functions which don't exist yet can also be added.
clearSession
()
{
if
(
!
_
.
isUndefined
(
this
.
bookmarks
))
{
this
.
bookmarks
.
reset
();
this
.
bookmarks
.
browserStorage
.
_clear
();
window
.
sessionStorage
.
removeItem
(
this
.
bookmarks
.
fetched_flag
);
}
this
.
__super__
.
clearSession
.
apply
(
this
,
arguments
);
},
ChatRoomView
:
{
events
:
{
'
click .toggle-bookmark
'
:
'
toggleBookmark
'
...
...
@@ -575,6 +566,14 @@
{
'
object
'
:
_converse
,
'
event
'
:
'
roomsPanelRendered
'
}
],
initBookmarks
);
_converse
.
on
(
'
clearSession
'
,
()
=>
{
if
(
!
_
.
isUndefined
(
_converse
.
bookmarks
))
{
_converse
.
bookmarks
.
browserStorage
.
_clear
();
window
.
sessionStorage
.
removeItem
(
_converse
.
bookmarks
.
fetched_flag
);
}
});
_converse
.
on
(
'
reconnected
'
,
initBookmarks
);
_converse
.
on
(
'
connected
'
,
()
=>
{
...
...
src/converse-controlbox.js
View file @
c9207258
...
...
@@ -104,19 +104,6 @@
}
},
clearSession
()
{
this
.
__super__
.
clearSession
.
apply
(
this
,
arguments
);
const
chatboxes
=
_
.
get
(
this
,
'
chatboxes
'
,
null
);
if
(
!
_
.
isNil
(
chatboxes
))
{
const
controlbox
=
chatboxes
.
get
(
'
controlbox
'
);
if
(
controlbox
&&
controlbox
.
collection
&&
controlbox
.
collection
.
browserStorage
)
{
controlbox
.
save
({
'
connected
'
:
false
});
}
}
},
ChatBoxes
:
{
chatBoxMayBeShown
(
chatbox
)
{
return
this
.
__super__
.
chatBoxMayBeShown
.
apply
(
this
,
arguments
)
&&
...
...
@@ -590,6 +577,20 @@
}
});
_converse
.
on
(
'
clearSession
'
,
()
=>
{
if
(
_converse
.
trusted
)
{
const
chatboxes
=
_
.
get
(
_converse
,
'
chatboxes
'
,
null
);
if
(
!
_
.
isNil
(
chatboxes
))
{
const
controlbox
=
chatboxes
.
get
(
'
controlbox
'
);
if
(
controlbox
&&
controlbox
.
collection
&&
controlbox
.
collection
.
browserStorage
)
{
controlbox
.
save
({
'
connected
'
:
false
});
}
}
}
});
Promise
.
all
([
_converse
.
api
.
waitUntil
(
'
connectionInitialized
'
),
_converse
.
api
.
waitUntil
(
'
chatBoxesInitialized
'
)
...
...
src/converse-core.js
View file @
c9207258
...
...
@@ -649,13 +649,13 @@
};
this
.
clearSession
=
function
()
{
if
(
!
_
.
isUndefined
(
this
.
session
)
&&
this
.
session
.
browserStorage
)
{
this
.
session
.
browserStorage
.
_clear
();
}
if
(
!
_converse
.
trusted
)
{
window
.
localStorage
.
clear
();
window
.
sessionStorage
.
clear
();
}
else
if
(
!
_
.
isUndefined
(
this
.
session
)
&&
this
.
session
.
browserStorage
)
{
this
.
session
.
browserStorage
.
_clear
();
}
_converse
.
emit
(
'
clearSession
'
);
};
this
.
logOut
=
function
()
{
...
...
src/converse-roster.js
View file @
c9207258
...
...
@@ -16,13 +16,6 @@
dependencies
:
[
"
converse-vcard
"
],
overrides
:
{
clearSession
()
{
this
.
__super__
.
clearSession
.
apply
(
this
,
arguments
);
if
(
!
_
.
isUndefined
(
this
.
roster
))
{
this
.
roster
.
browserStorage
.
_clear
();
}
},
_tearDown
()
{
this
.
__super__
.
_tearDown
.
apply
(
this
,
arguments
);
if
(
this
.
roster
)
{
...
...
@@ -735,6 +728,12 @@
/********** Event Handlers *************/
_converse
.
api
.
listen
.
on
(
'
clearSession
'
,
()
=>
{
if
(
!
_
.
isUndefined
(
this
.
roster
))
{
this
.
roster
.
browserStorage
.
_clear
();
}
});
_converse
.
api
.
listen
.
on
(
'
statusInitialized
'
,
(
reconnecting
)
=>
{
if
(
reconnecting
)
{
// No need to recreate the roster, otherwise we lose our
...
...
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