diff --git a/client/css/style.css b/client/css/style.css
index a1f6908..a0327cb 100644
--- a/client/css/style.css
+++ b/client/css/style.css
@@ -812,4 +812,10 @@ a:-webkit-any-link {
--clr-card-bg: hsl(209 50% 5%);
--colour-3: hsl(209 50% 90%);
--conversations: hsl(209 50% 80%);
-}
\ No newline at end of file
+}
+
+.trash-icon {
+ position: absolute;
+ top: 20px;
+ right: 20px;
+}
diff --git a/client/js/chat.js b/client/js/chat.js
index cff0be5..0c16893 100644
--- a/client/js/chat.js
+++ b/client/js/chat.js
@@ -85,6 +85,7 @@ const ask_gpt = async (message) => {
+ ${
+ item.role == "user"
+ ? `
`
+ : `
`
+ }
${
item.role == "assistant"
? markdown.render(item.content)
: item.content
}
+ ${
+ item.role == "user"
+ ? `
`
+ : ''
+ }
`;
}
@@ -358,7 +368,7 @@ const add_conversation = async (conversation_id, title) => {
}
};
-const add_message = async (conversation_id, role, content) => {
+const add_message = async (conversation_id, role, content, token) => {
before_adding = JSON.parse(
localStorage.getItem(`conversation:${conversation_id}`)
);
@@ -366,6 +376,7 @@ const add_message = async (conversation_id, role, content) => {
before_adding.items.push({
role: role,
content: content,
+ token: token,
});
localStorage.setItem(
@@ -564,4 +575,19 @@ colorThemes.forEach((themeOption) => {
});
});
+function deleteMessage(token) {
+ const messageDivUser = document.getElementById(`user_${token}`)
+ const messageDivGpt = document.getElementById(`gpt_${token}`)
+ if (messageDivUser) messageDivUser.parentNode.remove();
+ if (messageDivGpt) messageDivGpt.parentNode.remove();
+ const conversation = JSON.parse(localStorage.getItem(`conversation:${window.conversation_id}`));
+ conversation.items = conversation.items.filter(item => item.token !== token);
+ localStorage.setItem(`conversation:${window.conversation_id}`, JSON.stringify(conversation));
+
+ const messages = document.getElementsByClassName("message");
+ if (messages.length === 0) {
+ delete_conversation(window.conversation_id);
+ };
+}
+
document.onload = setTheme();