convos icon indicating copy to clipboard operation
convos copied to clipboard

Can't update/delete connection from connection settings of left sidebar

Open asdofindia opened this issue 1 year ago • 0 comments

Describe the bug I am able to edit/update/delete a connection using ConnectionSettings component sidebar that can be loaded from within a chat. But, when I use the main navigation leading to ConnectionSettings page, all connections are being detected as "new" with "Add" being the only option. I think this is related to https://github.com/convos-chat/convos/commit/5f69a031590ea6d52304e18b5f1ccbe5aa559c75 where ConnectionForm started expecting

To Reproduce Steps to reproduce the behavior:

  1. Go to /settings/connections
  2. Click on any connection
  3. Try to update/delete

Expected behavior Update button and delete button should be available.

Screenshots Only add button is available

Additional context

diff --git a/assets/page/ConnectionSettings.svelte b/assets/page/ConnectionSettings.svelte
index c9aafbd9..b4deb859 100644
--- a/assets/page/ConnectionSettings.svelte
+++ b/assets/page/ConnectionSettings.svelte
@@ -1,4 +1,5 @@
 <script>
+import {getContext} from 'svelte';
 import ChatHeader from '../components/ChatHeader.svelte';
 import ConnectionForm from '../components/ConnectionForm.svelte';
 import Icon from '../components/Icon.svelte';
@@ -8,6 +9,8 @@ import {nbsp} from '../js/util';
 
 export let connection_id = 'add';
 export const title = connection_id === 'add' ? 'Add connection' : 'Edit connection';
+const user = getContext('user');
+$: connection = connection_id !== 'add' ? user.findConversation({connection_id}) : {};
 </script>
 
 <ChatHeader>
@@ -19,5 +22,5 @@ export const title = connection_id === 'add' ? 'Add connection' : 'Edit connecti
 </ChatHeader>
 
 <main class="main">
-  <ConnectionForm is_page="{true}"/>
+  <ConnectionForm {connection} is_page="{true}"/>
 </main>

Something like this seems to work.

But as soon as DELETE request is made, a POST request is made again which seems to be recreating deleted connection

asdofindia avatar Jan 15 '24 14:01 asdofindia