diff --git a/dev/pane/index.ts b/dev/pane/index.ts index 94f0ee20..bc17e67f 100644 --- a/dev/pane/index.ts +++ b/dev/pane/index.ts @@ -1,3 +1,9 @@ -import { longChatPane as Pane } from 'chat-pane' +// import { longChatPane as Pane } from 'chat-pane' +import Pane from '../../src/profile/profile.view' +import * as UI from 'solid-ui' -export default Pane \ No newline at end of file +console.log('Loaded pane into Solid Pane Tester. Check window.Pane and window.UI') +;(window as any).Pane = Pane +;(window as any).UI = UI + +export default Pane diff --git a/package.json b/package.json index b68b98d7..0fb2ac53 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "activitystreams-pane": "^0.5.0", "babel-preset-env": "^1.7.0", "babel-preset-metalab": "^1.0.0", - "chat-pane": "^2.3.2", + "chat-pane": "^2.4.2", "contacts-pane": "^2.3.0", "folder-pane": "^2.3.0", "issue-pane": "^2.3.1", diff --git a/src/profile/profile.view.ts b/src/profile/profile.view.ts index 4fcf747c..018e5416 100644 --- a/src/profile/profile.view.ts +++ b/src/profile/profile.view.ts @@ -15,6 +15,7 @@ import { icons, ns, widgets } from 'solid-ui' import { NamedNode } from 'rdflib' import { paneDiv } from './profile.dom' import { PaneDefinition } from 'pane-registry' +import { getChat, longChatPane } from 'chat-pane' const thisPane: PaneDefinition = { global: false, @@ -79,6 +80,31 @@ const thisPane: PaneDefinition = { // Todo: only show this if there is vcard info heading('Contact') + + const chatContainer = dom.createElement('div') + const exists = await getChat(subject, false) + if (exists) { + chatContainer.appendChild(longChatPane.render(exists, context, {})) + } else { + const button = widgets.button( + dom, + undefined, + 'Chat with me', + async () => { + try { + const chat: NamedNode = await getChat(subject) + chatContainer.innerHTML = '' + chatContainer.appendChild(longChatPane.render(chat, context, {})) + } catch (e) { + chatContainer.appendChild(widgets.errorMessageBlock(dom, e.message)) + } + }, + { needsBorder: true } + ) + chatContainer.appendChild(button) + } + main.appendChild(chatContainer) + const contactDisplay = paneDiv(context, subject, 'contact') contactDisplay.style.border = '0em' // override form main.appendChild(contactDisplay)