Skip to content

Commit

Permalink
Merge pull request #26 from iceljc/bugfix/fix-conv-dropdown
Browse files Browse the repository at this point in the history
end conversation
  • Loading branch information
Oceania2018 authored Jan 25, 2024
2 parents 0129f86 + 3617d40 commit 4b7bcb3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/scss/custom/pages/_conversation.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.conv-delete-modal {
.delete-modal {
button {
outline: none !important;
box-shadow: none !important;
Expand Down
26 changes: 23 additions & 3 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import ContentLog from './content-log.svelte';
import { replaceNewLine } from '$lib/helpers/http';
import _ from "lodash";
import Swal from 'sweetalert2/dist/sweetalert2.js';
import "sweetalert2/src/sweetalert2.scss";
const options = {
scrollbars: {
Expand Down Expand Up @@ -148,8 +150,26 @@
await sendMessageToHub(params.agentId, params.conversationId, text);
}
function close() {
window.parent.postMessage({ action: "close" }, "*");
function endChat() {
if (window.location === window.parent.location) {
// @ts-ignore
Swal.fire({
title: 'Are you sure?',
text: "You will exit this conversation.",
icon: 'warning',
customClass: 'delete-modal',
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No'
// @ts-ignore
}).then((result) => {
if (result.value) {
window.close();
}
});
} else {
window.parent.postMessage({ action: "close" }, "*");
}
}
function closeLog() {
Expand Down Expand Up @@ -188,7 +208,7 @@
<li class="list-inline-item d-sm-inline-block">
<button type="submit" class="btn btn-primary btn-rounded chat-send waves-effect waves-light"
on:click={close}
on:click={() => endChat()}
>
<span class="d-none d-sm-inline-block me-2" >End Conversation</span> <i class="mdi mdi-window-close"></i>
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/page/conversation/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
customClass: 'conv-delete-modal',
customClass: 'delete-modal',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!'
// @ts-ignore
Expand Down
5 changes: 3 additions & 2 deletions src/routes/page/conversation/[conversationId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
});
function handleConversationDeletion() {
// @ts-ignore
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
customClass: 'conv-delete-modal',
customClass: 'delete-modal',
confirmButtonText: 'Yes, delete it!'
// @ts-ignore
}).then(async (result) => {
if (result.value) {
await deleteConversation(conversation.id);
// Swal.fire('Deleted!', 'Your file has been deleted.', 'success');
window.location.href = "/page/conversation";
}
});
Expand Down

0 comments on commit 4b7bcb3

Please sign in to comment.