Allow user to close a conversation (chatbox)
One step ahead in the memory game! This commit closes #12 (closes, get it? :P)
This commit is contained in:
parent
26e344e28c
commit
86c5489f19
1 changed files with 26 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Text from '../components/Text.svelte'
|
import Text from '../components/Text.svelte'
|
||||||
import ChatMessage from '../components/ChatMessage.svelte'
|
import ChatMessage from '../components/ChatMessage.svelte'
|
||||||
|
import OptionsMenu from '../components/OptionsMenu.svelte'
|
||||||
|
import ListItem from '../components/ListItem.svelte'
|
||||||
import Input from '../components/Input.svelte'
|
import Input from '../components/Input.svelte'
|
||||||
|
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
@ -22,6 +24,10 @@
|
||||||
let chatListEl
|
let chatListEl
|
||||||
let composeBox
|
let composeBox
|
||||||
|
|
||||||
|
// Whether the options menu is visible or not
|
||||||
|
let optionsMenuVisible = false
|
||||||
|
|
||||||
|
|
||||||
$: title = chatbox?.attributes?.nickname || chatbox?.attributes?.id || params.chatID || 'Convo'
|
$: title = chatbox?.attributes?.nickname || chatbox?.attributes?.id || params.chatID || 'Convo'
|
||||||
$: titleStore.update(() => title)
|
$: titleStore.update(() => title)
|
||||||
|
|
||||||
|
@ -90,7 +96,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
k.right.label = 'Options'
|
k.right.label = 'Options'
|
||||||
k.right.callback = () => {}
|
k.right.callback = () => {
|
||||||
|
optionsMenuVisible = !optionsMenuVisible
|
||||||
|
}
|
||||||
|
|
||||||
return k
|
return k
|
||||||
})
|
})
|
||||||
|
@ -183,6 +191,14 @@
|
||||||
onComposeBoxUpdate()
|
onComposeBoxUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to close a conversation
|
||||||
|
function closeChat() {
|
||||||
|
chatbox.close().then(() => {
|
||||||
|
push('/messages')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get it all running!
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
// Initialise the chatbox
|
// Initialise the chatbox
|
||||||
chatbox = _converse.chatboxes.get(params.chatID)
|
chatbox = _converse.chatboxes.get(params.chatID)
|
||||||
|
@ -223,6 +239,15 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if optionsMenuVisible}
|
||||||
|
<OptionsMenu title="Options">
|
||||||
|
<ListItem
|
||||||
|
text="Close conversation"
|
||||||
|
onclick={closeChat}
|
||||||
|
/>
|
||||||
|
</OptionsMenu>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.compose-box {
|
.compose-box {
|
||||||
height: 8rem;
|
height: 8rem;
|
||||||
|
|
Loading…
Reference in a new issue