File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 435435 </ div >
436436
437437 < div class ="sidebar-footer ">
438+ < button id ="deleteChannelBtn " class ="sidebar-btn "> Delete Channel</ button >
439+ < button id ="deleteServerBtn " class ="sidebar-btn "> Delete Server</ button >
438440 Nebula • realtime chat on Supabase.
439441 </ div >
440442 </ div >
@@ -930,6 +932,46 @@ <h2 style="margin:0 0 8px;">Welcome to Nebula</h2>
930932
931933 await loadServers ( ) ;
932934 } ;
935+
936+ document . getElementById ( "deleteServerBtn" ) . onclick = async ( ) => {
937+ if ( ! activeServer ) return ;
938+
939+ if ( ! confirm ( `Delete "${ activeServer . name } "?` ) ) return ;
940+
941+ const { error } = await supabaseClient
942+ . from ( "servers" )
943+ . delete ( )
944+ . eq ( "id" , activeServer . id ) ;
945+
946+ if ( error ) {
947+ alert ( error . message ) ;
948+ return ;
949+ }
950+
951+ activeServer = null ;
952+ activeChannel = null ;
953+ messagesEl . innerHTML = "" ;
954+ await loadServers ( ) ;
955+ } ;
956+
957+ document . getElementById ( "deleteChannelBtn" ) . onclick = async ( ) => {
958+ if ( ! activeChannel ) return ;
959+
960+ if ( ! confirm ( `Delete #${ activeChannel . name } ?` ) ) return ;
961+
962+ const { error } = await supabaseClient
963+ . from ( "channels" )
964+ . delete ( )
965+ . eq ( "id" , activeChannel . id ) ;
966+
967+ if ( error ) {
968+ alert ( error . message ) ;
969+ return ;
970+ }
971+
972+ activeChannel = null ;
973+ await loadChannels ( ) ;
974+ } ;
933975
934976 document . getElementById ( "createChannelBtn" ) . onclick = async ( ) => {
935977 if ( ! activeServer ) return alert ( "Select a server first." ) ;
You can’t perform that action at this time.
0 commit comments