forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatPane.js
More file actions
84 lines (72 loc) · 2.46 KB
/
Copy pathchatPane.js
File metadata and controls
84 lines (72 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Lazy-loaded chat pane wrappers
*
* Only loads chat-pane (and its UI.messageArea/infiniteMessageArea deps)
* when the pane is actually rendered. This allows chat to be code-split
* into a separate chunk.
*/
import * as UI from 'solid-ui-jss'
const ns = UI.ns
/**
* Long Chat Pane - lazy wrapper
* Used for LongChat, Thread, and message types
*/
export const longChatPane = {
icon: UI.icons.iconBase + 'noun_1689339.svg',
name: 'long chat',
// Label determines if pane is relevant - must be sync
label: function (subject, context) {
const kb = context.session.store
if (kb.holds(subject, ns.rdf('type'), ns.meeting('LongChat'))) {
return 'Chat channel'
}
if (kb.holds(subject, ns.rdf('type'), ns.sioc('Thread'))) {
return 'Thread'
}
// Message detection
if (kb.any(subject, ns.sioc('content')) && kb.any(subject, ns.dct('created'))) {
return 'message'
}
return null
},
// Lazy render - loads chat-pane chunk only when needed
render: async function (subject, context) {
const { longChatPane: realPane } = await import(/* webpackChunkName: "chat-pane" */ 'chat-pane')
return realPane.render(subject, context)
},
// Lazy mintNew
mintNew: async function (context, newPaneOptions) {
const { longChatPane: realPane } = await import(/* webpackChunkName: "chat-pane" */ 'chat-pane')
return realPane.mintNew(context, newPaneOptions)
},
mintClass: ns.meeting('LongChat')
}
/**
* Short Chat Pane - lazy wrapper
* Used for wf:message based chats and meeting chats
*/
export const shortChatPane = {
icon: UI.icons.iconBase + 'noun_346319.svg',
name: 'chat',
label: function (subject, context) {
const kb = context.session.store
const n = kb.each(subject, ns.wf('message')).length
if (n > 0) return 'Chat (' + n + ')'
if (kb.holds(subject, ns.rdf('type'), ns.meeting('Chat'))) {
return 'Meeting chat'
}
if (kb.holds(undefined, ns.rdf('type'), ns.foaf('ChatChannel'), subject)) {
return 'IRC log'
}
return null
},
render: async function (subject, context) {
const { shortChatPane: realPane } = await import(/* webpackChunkName: "chat-pane" */ 'chat-pane')
return realPane.render(subject, context)
},
mintNew: async function (context, newPaneOptions) {
const { shortChatPane: realPane } = await import(/* webpackChunkName: "chat-pane" */ 'chat-pane')
return realPane.mintNew(context, newPaneOptions)
},
mintClass: ns.meeting('Chat')
}