File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 140140 }
141141 };
142142
143+ let deleting = false ;
144+
143145 const deleteChatHandler = async (id ) => {
146+ if (deleting ) return ;
147+ deleting = true ;
148+
144149 const res = await deleteChatById (localStorage .token , id ).catch ((error ) => {
145150 toast .error (` ${error } ` );
146151 return null ;
157162
158163 dispatch (' change' );
159164 }
165+
166+ deleting = false ;
160167 };
161168
169+ let archiving = false ;
170+
162171 const archiveChatHandler = async (id ) => {
172+ if (archiving ) return ;
173+ archiving = true ;
174+
163175 try {
164176 await archiveChatById (localStorage .token , id );
165177
173185 } catch (error ) {
174186 console .error (' Error archiving chat:' , error );
175187 toast .error ($i18n .t (' Failed to archive chat.' ));
188+ } finally {
189+ archiving = false ;
176190 }
177191 };
178192
537551 <div class =" flex items-center self-center space-x-1.5" >
538552 <Tooltip content ={$i18n .t (' Archive' )} className =" flex items-center" >
539553 <button
540- class =" self-center dark:hover:text-white transition"
554+ class =" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
555+ disabled ={archiving }
541556 on:click ={() => {
542557 archiveChatHandler (id );
543558 }}
549564
550565 <Tooltip content ={$i18n .t (' Delete' )}>
551566 <button
552- class =" self-center dark:hover:text-white transition"
567+ class =" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
568+ disabled ={deleting }
553569 on:click ={() => {
554570 deleteChatHandler (id );
555571 }}
You can’t perform that action at this time.
0 commit comments