Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat with me button on profile #245

Merged
merged 9 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dev/pane/index.ts
Original file line number Diff line number Diff line change
@@ -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
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
8 changes: 5 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"activitystreams-pane": "^0.3.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",
Expand Down
26 changes: 26 additions & 0 deletions src/profile/profile.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, {}))
michielbdejong marked this conversation as resolved.
Show resolved Hide resolved
} 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) {
window.alert(e.message)
michielbdejong marked this conversation as resolved.
Show resolved Hide resolved
}
},
{ needsBorder: true }
)
chatContainer.appendChild(button)
}
main.appendChild(chatContainer)

const contactDisplay = paneDiv(context, subject, 'contact')
contactDisplay.style.border = '0em' // override form
main.appendChild(contactDisplay)
Expand Down