Skip to content

Commit 111e7c1

Browse files
committed
Use turbo
1 parent bb77452 commit 111e7c1

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"twig/extra-bundle": "^2.12|^3.0",
2929
"twig/intl-extra": "^3.5",
3030
"twig/markdown-extra": "^3.5",
31-
"twig/twig": "^2.12|^3.0",
31+
"twig/twig": "^2.12|^3.0"
3232
},
3333
"require-dev": {
3434
"symfony/debug-bundle": "6.2.*",

composer.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Controller/ChatController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function submitAction(Request $request): Response
5050
$form->handleRequest($request);
5151

5252
if (!$form->isSubmitted() || !$form->isValid()) {
53-
return new Response('Invalid form', Response::HTTP_BAD_REQUEST);
53+
return new Response('Invalid form', Response::HTTP_UNPROCESSABLE_ENTITY);
5454
}
5555

5656
/** @var MessageInput $messageInput */

templates/components/chatbox.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</div>
5757

5858
<div class="send-box">
59-
<form action="{{ path('submit') }}" method="post">
59+
<form action="{{ path('submit') }}" method="post" data-turbo-frame="chatbox" data-turbo-action="replace">
6060
{{ form_widget(this.form.message) }}
6161
{{ form_widget(this.form.id) }}
6262
{# @todo would be nice to be able to add an icon. See https://stackoverflow.com/a/31275381/450789 #}

templates/components/chats_list.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="chat-header">
33
<div class="msg-search">
44
<input type="text" class="form-control" id="inlineFormInputGroup" placeholder="Search" aria-label="search" data-model="query">
5-
<a class="add" href="{{ path('index') }}"><img class="img-fluid" src="https://mehedihtml.com/chatbox/assets/img/add.svg" alt="add"></a>
5+
<a class="add" href="{{ path('index') }}" data-turbo-action="replace" data-turbo-frame="chatbox"><img class="img-fluid" src="https://mehedihtml.com/chatbox/assets/img/add.svg" alt="add"></a>
66
</div>
77
</div>
88

@@ -13,7 +13,7 @@
1313
<div class="tab-pane fade show active" id="Open" role="tabpanel" aria-labelledby="Open-tab">
1414
<div class="chat-list">
1515
{% for conversation in this.conversations %}
16-
<a href="{{ path('conversation', { id: conversation.id }) }}" class="d-flex align-items-center" data-loading="addClass(opacity-50)">
16+
<a href="{{ path('conversation', { id: conversation.id }) }}" class="d-flex align-items-center" data-loading="addClass(opacity-50)" data-turbo-action="replace" data-turbo-frame="chatbox">
1717
<div class="flex-shrink-0">
1818
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/commons/0/04/ChatGPT_logo.svg" width="45" height="45" alt="user img">
1919
<!--<span class="active"></span>-->

templates/index.html.twig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
<!-- chatlist -->
1818

1919
<!-- chatbox -->
20-
<div class="chatbox">
21-
<div class="modal-dialog-scrollable">
22-
{{ component('chatbox', { class: 'modal-content', id }) }}
20+
<div class="chatbox">
21+
<div class="modal-dialog-scrollable">
22+
<turbo-frame id="chatbox">
23+
{{ component('chatbox', { class: 'modal-content', id }) }}
24+
</turbo-frame>
25+
</div>
2326
</div>
24-
</div>
2527
</div>
2628
<!-- chatbox -->
2729

0 commit comments

Comments
 (0)