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">
|
||||
import Text from '../components/Text.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 { onMount } from 'svelte'
|
||||
|
@ -22,6 +24,10 @@
|
|||
let chatListEl
|
||||
let composeBox
|
||||
|
||||
// Whether the options menu is visible or not
|
||||
let optionsMenuVisible = false
|
||||
|
||||
|
||||
$: title = chatbox?.attributes?.nickname || chatbox?.attributes?.id || params.chatID || 'Convo'
|
||||
$: titleStore.update(() => title)
|
||||
|
||||
|
@ -90,7 +96,9 @@
|
|||
}
|
||||
|
||||
k.right.label = 'Options'
|
||||
k.right.callback = () => {}
|
||||
k.right.callback = () => {
|
||||
optionsMenuVisible = !optionsMenuVisible
|
||||
}
|
||||
|
||||
return k
|
||||
})
|
||||
|
@ -183,6 +191,14 @@
|
|||
onComposeBoxUpdate()
|
||||
}
|
||||
|
||||
// Function to close a conversation
|
||||
function closeChat() {
|
||||
chatbox.close().then(() => {
|
||||
push('/messages')
|
||||
})
|
||||
}
|
||||
|
||||
// Get it all running!
|
||||
onMount(() => {
|
||||
// Initialise the chatbox
|
||||
chatbox = _converse.chatboxes.get(params.chatID)
|
||||
|
@ -223,6 +239,15 @@
|
|||
/>
|
||||
</div>
|
||||
|
||||
{#if optionsMenuVisible}
|
||||
<OptionsMenu title="Options">
|
||||
<ListItem
|
||||
text="Close conversation"
|
||||
onclick={closeChat}
|
||||
/>
|
||||
</OptionsMenu>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.compose-box {
|
||||
height: 8rem;
|
||||
|
|
Loading…
Reference in a new issue