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
6af02904
Commit
6af02904
authored
Jul 11, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $.Deferred with ES2015 promises
parent
16d62bf9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
31 deletions
+40
-31
spec/bookmarks.js
spec/bookmarks.js
+21
-11
src/converse-bookmarks.js
src/converse-bookmarks.js
+3
-4
src/utils.js
src/utils.js
+16
-16
No files found.
spec/bookmarks.js
View file @
6af02904
...
...
@@ -430,8 +430,13 @@
'
jid
'
:
'
another@conference.shakespeare.lit
'
}).
c
(
'
nick
'
).
t
(
'
JC
'
).
up
().
up
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
$
(
'
#chatrooms dl.bookmarks dd
'
).
length
).
toBe
(
3
);
done
();
test_utils
.
waitUntil
(
function
()
{
return
$
(
'
#chatrooms dl.bookmarks dd
'
).
length
;
},
300
).
then
(
function
()
{
expect
(
$
(
'
#chatrooms dl.bookmarks dd
'
).
length
).
toBe
(
3
);
done
();
});
}));
it
(
"
remembers the toggle state of the bookmarks list
"
,
mock
.
initConverseWithPromises
(
...
...
@@ -472,15 +477,20 @@
'
nick
'
:
''
});
test_utils
.
openControlBox
().
openRoomsPanel
(
_converse
);
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
1
);
expect
(
_converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
_converse
.
OPENED
);
$
(
'
#chatrooms .bookmarks-toggle
'
).
click
();
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
_converse
.
CLOSED
);
$
(
'
#chatrooms .bookmarks-toggle
'
).
click
();
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
1
);
expect
(
_converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
_converse
.
OPENED
);
done
();
test_utils
.
waitUntil
(
function
()
{
return
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
;
},
300
).
then
(
function
()
{
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
1
);
expect
(
_converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
_converse
.
OPENED
);
$
(
'
#chatrooms .bookmarks-toggle
'
).
click
();
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
_converse
.
CLOSED
);
$
(
'
#chatrooms .bookmarks-toggle
'
).
click
();
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
1
);
expect
(
_converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
_converse
.
OPENED
);
done
();
});
}));
});
});
...
...
src/converse-bookmarks.js
View file @
6af02904
...
...
@@ -229,8 +229,7 @@
},
fetchBookmarks
()
{
const
deferred
=
new
$
.
Deferred
();
const
promise
=
deferred
.
promise
();
const
deferred
=
utils
.
getWrappedPromise
();
if
(
this
.
browserStorage
.
records
.
length
>
0
)
{
this
.
fetch
({
'
success
'
:
_
.
bind
(
this
.
onCachedBookmarksFetched
,
this
,
deferred
),
...
...
@@ -245,7 +244,7 @@
}
else
{
deferred
.
resolve
();
}
return
promise
;
return
deferred
.
promise
;
},
onCachedBookmarksFetched
(
deferred
)
{
...
...
@@ -482,7 +481,7 @@
return
;
}
_converse
.
bookmarks
=
new
_converse
.
Bookmarks
();
_converse
.
bookmarks
.
fetchBookmarks
().
always
(
function
()
{
_converse
.
bookmarks
.
fetchBookmarks
().
then
(
function
()
{
_converse
.
bookmarksview
=
new
_converse
.
BookmarksView
(
{
'
model
'
:
_converse
.
bookmarks
}
);
...
...
src/utils.js
View file @
6af02904
...
...
@@ -69,22 +69,22 @@
};
var
isImage
=
function
(
url
)
{
var
deferred
=
new
$
.
Deferred
();
var
img
=
new
Image
();
var
timer
=
window
.
setTimeout
(
function
()
{
deferred
.
reject
(
);
img
=
null
;
},
3000
);
img
.
onerror
=
img
.
onabort
=
function
()
{
clearTimeout
(
timer
);
deferred
.
reject
(
);
};
img
.
onload
=
function
()
{
clearTimeout
(
timer
);
deferred
.
resolve
(
img
);
};
img
.
src
=
url
;
return
deferred
.
promise
(
);
return
new
Promise
((
resolve
,
reject
)
=>
{
var
img
=
new
Image
();
var
timer
=
window
.
setTimeout
(
function
()
{
reject
(
new
Error
(
"
Could not determine whether it's an image
"
)
);
img
=
null
;
},
3000
);
img
.
onerror
=
img
.
onabort
=
function
()
{
clearTimeout
(
timer
);
reject
(
new
Error
(
"
Could not determine whether it's an image
"
)
);
};
img
.
onload
=
function
()
{
clearTimeout
(
timer
);
resolve
(
img
);
};
img
.
src
=
url
;
}
);
};
$
.
fn
.
hasScrollBar
=
function
()
{
...
...
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