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
78f8f73f
Commit
78f8f73f
authored
Sep 21, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of `converse-uniview` plugin
Instead of overriding createChatBox, set 'hidden' flag via defaults
parent
f79fd333
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
140 deletions
+83
-140
CHANGES.md
CHANGES.md
+1
-0
package-lock.json
package-lock.json
+12
-5
src/converse-chatboxviews.js
src/converse-chatboxviews.js
+55
-21
src/converse-chatview.js
src/converse-chatview.js
+5
-1
src/converse-uniview.js
src/converse-uniview.js
+0
-106
src/converse.js
src/converse.js
+1
-3
src/headless/converse-chat.js
src/headless/converse-chat.js
+8
-3
src/headless/converse-muc.js
src/headless/converse-muc.js
+1
-1
No files found.
CHANGES.md
View file @
78f8f73f
...
...
@@ -32,6 +32,7 @@ Soon we'll deprecate the latter, so prepare now.
-
#2201: added html to converse.env
-
#2213: added CustomElement to converse.env
-
#2220: fix rendering of emojis in case
`use_system_emojis == false`
(again).
-
The plugin
`converse-uniview`
has been removed and its functionality merged into
`converse-chatboxviews`
-
Removed the mockups from the project. Recommended to use tests instead.
-
The API method
`api.settings.update`
has been deprecated in favor of
`api.settings.extend`
.
-
The API methods under the
`api.user.status`
namespace are now asynchronous and need to be
`await`
ed.
...
...
package-lock.json
View file @
78f8f73f
...
...
@@ -3115,7 +3115,8 @@
"dependencies"
:
{
"filesize"
:
{
"version"
:
"6.1.0"
,
"resolved"
:
false
"resolved"
:
"https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz"
,
"integrity"
:
"sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg=="
},
"fs-extra"
:
{
"version"
:
"8.1.0"
,
...
...
@@ -3171,20 +3172,22 @@
},
"localforage"
:
{
"version"
:
"1.7.3"
,
"resolved"
:
false
,
"resolved"
:
"https://registry.npmjs.org/localforage/-/localforage-1.7.3.tgz"
,
"integrity"
:
"sha512-1TulyYfc4udS7ECSBT2vwJksWbkwwTX8BzeUIiq8Y07Riy7bDAAnxDaPU/tWyOVmQAcWJIEIFP9lPfBGqVoPgQ=="
,
"requires"
:
{
"lie"
:
"3.1.1"
}
},
"pluggable.js"
:
{
"version"
:
"2.0.1"
,
"resolved"
:
false
,
"resolved"
:
"https://registry.npmjs.org/pluggable.js/-/pluggable.js-2.0.1.tgz"
,
"integrity"
:
"sha512-SBt6v6Tbp20Jf8hU0cpcc/+HBHGMY8/Q+yA6Ih0tBQE8tfdZ6U4PRG0iNvUUjLx/hVyOP53n0UfGBymlfaaXCg=="
,
"requires"
:
{
"lodash"
:
"^4.17.11"
}
},
"skeletor.js"
:
{
"version"
:
"
0.0.
1"
,
"version"
:
"
github:skeletorjs/skeletor#bf6d9c86f9fcf224fa9d9af5a25380b77aa4b56
1"
,
"from"
:
"github:skeletorjs/skeletor#bf6d9c86f9fcf224fa9d9af5a25380b77aa4b561"
,
"requires"
:
{
"lodash"
:
"^4.17.14"
...
...
@@ -3192,7 +3195,11 @@
},
"strophe.js"
:
{
"version"
:
"github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f"
,
"from"
:
"strophe.js@github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f"
"from"
:
"strophe.js@github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f"
,
"requires"
:
{
"abab"
:
"^2.0.3"
,
"xmldom"
:
"^0.1.27"
}
},
"twemoji"
:
{
"version"
:
"12.1.5"
,
...
...
src/converse-chatboxviews.js
View file @
78f8f73f
...
...
@@ -109,6 +109,57 @@ const ChatBoxViews = Overview.extend({
});
function
onChatBoxViewsInitialized
()
{
_converse
.
chatboxviews
=
new
_converse
.
ChatBoxViews
({
'
model
'
:
_converse
.
chatboxes
});
/**
* Triggered once the _converse.ChatBoxViews view-colleciton has been initialized
* @event _converse#chatBoxViewsInitialized
* @example _converse.api.listen.on('chatBoxViewsInitialized', () => { ... });
*/
api
.
trigger
(
'
chatBoxViewsInitialized
'
);
}
function
hideChat
(
view
)
{
if
(
view
.
model
.
get
(
'
id
'
)
===
'
controlbox
'
)
{
return
;
}
u
.
safeSave
(
view
.
model
,
{
'
hidden
'
:
true
});
view
.
hide
();
}
function
beforeShowingChatView
(
view
)
{
if
(
_converse
.
isUniView
())
{
/* We only have one chat visible at any one
* time. So before opening a chat, we make sure all other
* chats are hidden.
*/
Object
.
values
(
_converse
.
chatboxviews
.
xget
(
view
.
model
.
get
(
'
id
'
)))
.
filter
(
v
=>
!
v
.
model
.
get
(
'
hidden
'
))
.
forEach
(
hideChat
);
if
(
view
.
model
.
get
(
'
hidden
'
))
{
return
new
Promise
(
resolve
=>
{
u
.
safeSave
(
view
.
model
,
{
'
hidden
'
:
false
},
{
'
success
'
:
resolve
,
'
failure
'
:
resolve
}
);
});
}
}
}
function
calculateViewportHeightUnit
()
{
const
vh
=
window
.
innerHeight
*
0.01
;
document
.
documentElement
.
style
.
setProperty
(
'
--vh
'
,
`
${
vh
}
px`
);
}
converse
.
plugins
.
add
(
'
converse-chatboxviews
'
,
{
dependencies
:
[
"
converse-chatboxes
"
,
"
converse-vcard
"
],
...
...
@@ -135,29 +186,12 @@ converse.plugins.add('converse-chatboxviews', {
_converse
.
ChatBoxViews
=
ChatBoxViews
;
/************************ BEGIN Event Handlers ************************/
api
.
listen
.
on
(
'
beforeShowingChatView
'
,
beforeShowingChatView
);
api
.
listen
.
on
(
'
chatBoxesInitialized
'
,
onChatBoxViewsInitialized
);
api
.
listen
.
on
(
'
cleanup
'
,
()
=>
(
delete
_converse
.
chatboxviews
));
api
.
listen
.
on
(
'
chatBoxesInitialized
'
,
()
=>
{
_converse
.
chatboxviews
=
new
_converse
.
ChatBoxViews
({
'
model
'
:
_converse
.
chatboxes
});
/**
* Triggered once the _converse.ChatBoxViews view-colleciton has been initialized
* @event _converse#chatBoxViewsInitialized
* @example _converse.api.listen.on('chatBoxViewsInitialized', () => { ... });
*/
api
.
trigger
(
'
chatBoxViewsInitialized
'
);
});
api
.
listen
.
on
(
'
clearSession
'
,
()
=>
_converse
.
chatboxviews
.
closeAllChatBoxes
());
function
calculateViewportHeightUnit
()
{
const
vh
=
window
.
innerHeight
*
0.01
;
document
.
documentElement
.
style
.
setProperty
(
'
--vh
'
,
`
${
vh
}
px`
);
}
api
.
listen
.
on
(
'
chatBoxViewsInitialized
'
,
()
=>
calculateViewportHeightUnit
());
window
.
addEventListener
(
'
resize
'
,
()
=>
calculateViewportHeightUnit
());
api
.
listen
.
on
(
'
chatBoxViewsInitialized
'
,
calculateViewportHeightUnit
);
window
.
addEventListener
(
'
resize
'
,
calculateViewportHeightUnit
);
/************************ END Event Handlers ************************/
...
...
src/converse-chatview.js
View file @
78f8f73f
...
...
@@ -451,7 +451,11 @@ export const ChatBoxView = View.extend({
},
shouldShowOnTextMessage
()
{
return
!
u
.
isVisible
(
this
.
el
);
if
(
_converse
.
isUniView
())
{
return
false
;
}
else
{
return
!
u
.
isVisible
(
this
.
el
);
}
},
/**
...
...
src/converse-uniview.js
deleted
100644 → 0
View file @
f79fd333
/**
* @module converse-uniview
* @description
* A plugin which ensures that only one chat (private or groupchat) is
* visible at any one time. All other ongoing chats are hidden and kept in the
* background.
*
* This plugin makes sense in mobile, embedded or fullscreen chat environments
* (as configured by the `view_mode` setting).
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
import
"
converse-chatview
"
;
import
{
converse
}
from
"
@converse/headless/converse-core
"
;
const
u
=
converse
.
env
.
utils
;
function
hideChat
(
view
)
{
if
(
view
.
model
.
get
(
'
id
'
)
===
'
controlbox
'
)
{
return
;
}
u
.
safeSave
(
view
.
model
,
{
'
hidden
'
:
true
});
view
.
hide
();
}
converse
.
plugins
.
add
(
'
converse-uniview
'
,
{
// It's possible however to make optional dependencies non-optional.
// If the setting "strict_plugin_dependencies" is set to true,
// an error will be raised if the plugin is not found.
dependencies
:
[
'
converse-chatboxes
'
,
'
converse-muc-views
'
,
'
converse-controlbox
'
,
'
converse-rosterview
'
],
overrides
:
{
// overrides mentioned here will be picked up by converse.js's
// plugin architecture they will replace existing methods on the
// relevant objects or classes.
//
// new functions which don't exist yet can also be added.
ChatBoxes
:
{
createChatBox
(
jid
,
attrs
)
{
/* Make sure new chat boxes are hidden by default. */
const
{
_converse
}
=
this
.
__super__
;
if
(
_converse
.
isUniView
())
{
attrs
=
attrs
||
{};
attrs
.
hidden
=
true
;
}
return
this
.
__super__
.
createChatBox
.
call
(
this
,
jid
,
attrs
);
}
},
ChatBox
:
{
maybeShow
(
force
)
{
force
&&
u
.
safeSave
(
this
,
{
'
hidden
'
:
false
});
const
{
_converse
}
=
this
.
__super__
;
if
(
_converse
.
isUniView
()
&&
this
.
get
(
'
hidden
'
))
{
return
;
}
else
{
return
this
.
__super__
.
maybeShow
.
apply
(
this
,
arguments
);
}
}
},
ChatBoxView
:
{
shouldShowOnTextMessage
()
{
const
{
_converse
}
=
this
.
__super__
;
if
(
_converse
.
isUniView
())
{
return
false
;
}
else
{
return
this
.
__super__
.
shouldShowOnTextMessage
.
apply
(
this
,
arguments
);
}
}
}
},
initialize
()
{
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
const
{
_converse
}
=
this
;
/************************ BEGIN Event Handlers ************************/
_converse
.
api
.
listen
.
on
(
'
beforeShowingChatView
'
,
(
view
)
=>
{
/* We only have one chat visible at any one
* time. So before opening a chat, we make sure all other
* chats are hidden.
*/
if
(
_converse
.
isUniView
())
{
Object
.
values
(
_converse
.
chatboxviews
.
xget
(
view
.
model
.
get
(
'
id
'
)))
.
filter
(
v
=>
!
v
.
model
.
get
(
'
hidden
'
))
.
forEach
(
hideChat
);
if
(
view
.
model
.
get
(
'
hidden
'
))
{
return
new
Promise
(
resolve
=>
{
u
.
safeSave
(
view
.
model
,
{
'
hidden
'
:
false
},
{
'
success
'
:
resolve
,
'
failure
'
:
resolve
}
);
});
}
}
});
/************************ END Event Handlers ************************/
}
});
src/converse.js
View file @
78f8f73f
...
...
@@ -29,7 +29,6 @@ import "converse-register"; // XEP-0077 In-band registration
import
"
converse-roomslist
"
;
// Show currently open chat rooms
import
"
converse-rosterview
"
;
import
"
converse-singleton
"
;
import
"
converse-uniview
"
;
import
"
./components/converse.js
"
;
/* END: Removable components */
...
...
@@ -57,8 +56,7 @@ const WHITELISTED_PLUGINS = [
'
converse-register
'
,
'
converse-roomslist
'
,
'
converse-rosterview
'
,
'
converse-singleton
'
,
'
converse-uniview
'
'
converse-singleton
'
];
const
initialize
=
converse
.
initialize
;
...
...
src/headless/converse-chat.js
View file @
78f8f73f
...
...
@@ -304,7 +304,7 @@ converse.plugins.add('converse-chat', {
return
{
'
bookmarked
'
:
false
,
'
chat_state
'
:
undefined
,
'
hidden
'
:
[
'
mobile
'
,
'
fullscreen
'
].
includes
(
api
.
settings
.
get
(
"
view_mode
"
)
),
'
hidden
'
:
_converse
.
isUniView
(
),
'
message_type
'
:
'
chat
'
,
'
nickname
'
:
undefined
,
'
num_unread
'
:
0
,
...
...
@@ -1133,8 +1133,13 @@ converse.plugins.add('converse-chat', {
});
},
maybeShow
()
{
return
this
.
trigger
(
"
show
"
);
maybeShow
(
force
)
{
force
&&
u
.
safeSave
(
this
,
{
'
hidden
'
:
false
});
if
(
_converse
.
isUniView
()
&&
this
.
get
(
'
hidden
'
))
{
return
;
}
else
{
return
this
.
trigger
(
"
show
"
);
}
},
/**
...
...
src/headless/converse-muc.js
View file @
78f8f73f
...
...
@@ -370,7 +370,7 @@ converse.plugins.add('converse-muc', {
'
num_unread_general
'
:
0
,
'
bookmarked
'
:
false
,
'
chat_state
'
:
undefined
,
'
hidden
'
:
[
'
mobile
'
,
'
fullscreen
'
].
includes
(
api
.
settings
.
get
(
"
view_mode
"
)
),
'
hidden
'
:
_converse
.
isUniView
(
),
'
message_type
'
:
'
groupchat
'
,
'
name
'
:
''
,
'
num_unread
'
:
0
,
...
...
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