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
c7e70236
Commit
c7e70236
authored
Apr 07, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly clear user settings
by first waiting until the model has been set up.
parent
727ddc29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
src/converse-muc-views.js
src/converse-muc-views.js
+1
-1
src/headless/converse-core.js
src/headless/converse-core.js
+18
-8
No files found.
src/converse-muc-views.js
View file @
c7e70236
...
...
@@ -703,7 +703,7 @@ converse.plugins.add('converse-muc-views', {
this
.
listenTo
(
this
.
model
.
notifications
,
'
change
'
,
this
.
renderNotifications
);
this
.
listenTo
(
this
.
model
.
session
,
'
change:connection_status
'
,
this
.
onConnectionStatusChanged
);
const
user_settings
=
_converse
.
api
.
user
.
settings
.
getModel
();
const
user_settings
=
await
_converse
.
api
.
user
.
settings
.
getModel
();
this
.
listenTo
(
user_settings
,
'
change:mucs_with_hidden_subject
'
,
this
.
renderHeading
);
this
.
listenTo
(
this
.
model
,
'
change
'
,
debounce
(()
=>
this
.
renderHeading
(),
250
));
...
...
src/headless/converse-core.js
View file @
c7e70236
...
...
@@ -276,7 +276,7 @@ pluggable.enable(_converse, '_converse', 'pluggable');
// Populated via the _converse.api.users.settings API
const
user_settings
=
new
Model
()
;
let
user_settings
;
function
initUserSettings
()
{
if
(
!
_converse
.
bare_jid
)
{
...
...
@@ -284,9 +284,10 @@ function initUserSettings () {
log
.
error
(
msg
);
throw
Error
(
msg
);
}
if
(
!
user_settings
.
fetched
)
{
if
(
!
user_settings
?
.
fetched
)
{
const
id
=
`converse.user-settings.
${
_converse
.
bare_jid
}
`
;
user_settings
.
browserStorage
=
_converse
.
createStore
(
id
,
"
session
"
);
user_settings
=
new
Model
({
id
});
user_settings
.
browserStorage
=
_converse
.
createStore
(
id
);
user_settings
.
fetched
=
user_settings
.
fetch
({
'
promise
'
:
true
});
}
return
user_settings
.
fetched
;
...
...
@@ -562,10 +563,11 @@ const api = _converse.api = {
/**
* Returns the user settings model. Useful when you want to listen for change events.
* @method _converse.api.user.settings.getModel
* @returns {
Model
}
* @example
_converse.api.user.settings.getModel
* @returns {
Promise<Model>
}
* @example
const settings = await _converse.api.user.settings.getModel();
*/
getModel
()
{
async
getModel
()
{
await
initUserSettings
();
return
user_settings
;
},
...
...
@@ -605,6 +607,15 @@ const api = _converse.api = {
o
[
key
]
=
val
;
return
user_settings
.
save
(
o
,
{
'
promise
'
:
true
});
}
},
/**
* Clears all the user settings
* @method _converse.api.user.settings.clear
*/
async
clear
()
{
await
initUserSettings
();
user_settings
.
clear
();
}
}
},
...
...
@@ -1132,8 +1143,7 @@ function clearSession () {
delete
_converse
.
session
;
}
if
(
_converse
.
shouldClearCache
())
{
const
model
=
_converse
.
api
.
user
.
settings
.
getModel
();
model
.
clear
();
_converse
.
api
.
user
.
settings
.
clear
();
}
/**
* Synchronouse event triggered once the user session has been cleared,
...
...
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