@@ -130,7 +130,10 @@ export class MainUI {
130130 // Need to dispatch a resize event so that the top_bar can pick it up
131131 globalThis . dispatchEvent ( new Event ( "resize" ) ) ;
132132 } , [ viewState . panels ] ) ;
133-
133+ const actionButtons = client . config . get < ActionButton [ ] > (
134+ "actionButtons" ,
135+ [ ] ,
136+ ) ;
134137 return (
135138 < >
136139 { viewState . showPageNavigator && (
@@ -335,15 +338,20 @@ export class MainUI {
335338 } ]
336339 : [ ] ,
337340 // Custom action buttons
338- ...client . config . get < ActionButton [ ] > (
339- "actionButtons" ,
340- [ ] ,
341- ) . filter ( (
341+ ...actionButtons . filter ( ( // Filter out buttons without icons (invalid) and mobile buttons when not in mobile mode
342342 button ,
343343 ) =>
344- ( typeof button . mobile === "undefined" ) ||
345- ( button . mobile === viewState . isMobile )
344+ button . icon && (
345+ ( typeof button . mobile === "undefined" ) ||
346+ ( button . mobile === viewState . isMobile )
347+ )
346348 )
349+ // Then ensure all buttons have a priority set (by default based on array index)
350+ . map ( ( button , index ) => ( {
351+ ...button ,
352+ priority : button . priority ?? actionButtons . length - index ,
353+ } ) )
354+ . sort ( ( a , b ) => b . priority - a . priority )
347355 . map ( ( button ) => {
348356 const mdiIcon = ( mdi as any ) [ kebabToCamel ( button . icon ) ] ;
349357 let featherIcon =
@@ -356,7 +364,7 @@ export class MainUI {
356364 description : button . description || "" ,
357365 callback : button . run || ( ( ) => {
358366 client . flashNotification (
359- "Legacy actionButton definition detected, please define a run() callback" ,
367+ "actionButton did not specify a run() callback" ,
360368 "error" ,
361369 ) ;
362370 } ) ,
@@ -427,6 +435,7 @@ type ActionButton = {
427435 icon : string ;
428436 description ?: string ;
429437 mobile ?: boolean ;
438+ priority ?: number ;
430439 run : ( ) => void ;
431440} ;
432441
0 commit comments