@@ -21,20 +21,18 @@ import "./styles.css";
2121import { showNotification } from "@api/Notifications" ;
2222import { definePluginSettings } from "@api/Settings" ;
2323import ErrorBoundary from "@components/ErrorBoundary" ;
24+ import { Paragraph } from "@components/Paragraph" ;
2425import { Devs } from "@utils/constants" ;
2526import definePlugin , { OptionType } from "@utils/types" ;
2627import { findComponentByCodeLazy , findCssClassesLazy , findStoreLazy } from "@webpack" ;
2728import { Constants , React , RestAPI , SettingsRouter , Tooltip } from "@webpack/common" ;
2829
2930import { NewButton , RenameButton } from "./components/RenameButton" ;
3031import { Session , SessionInfo } from "./types" ;
31- import { fetchNamesFromDataStore , getDefaultName , GetOsColor , GetPlatformIcon , savedSessionsCache , saveSessionsToDataStore } from "./utils" ;
32+ import { cl , fetchNamesFromDataStore , getDefaultName , GetOsColor , GetPlatformIcon , savedSessionsCache , saveSessionsToDataStore } from "./utils" ;
3233
3334const AuthSessionsStore = findStoreLazy ( "AuthSessionsStore" ) ;
34-
3535const TimestampClasses = findCssClassesLazy ( "timestamp" , "blockquoteContainer" ) ;
36- const SessionIconClasses = findCssClassesLazy ( "sessionIcon" ) ;
37-
3836const BlobMask = findComponentByCodeLazy ( "!1,lowerBadgeSize:" ) ;
3937
4038const settings = definePluginSettings ( {
@@ -61,57 +59,70 @@ export default definePlugin({
6159
6260 patches : [
6361 {
64- find : "#{intl::AUTH_SESSIONS_SESSION_LOG_OUT }" ,
62+ find : "#{intl::AUTH_SESSIONS_OS_UNKNOWN }" ,
6563 replacement : [
66- // Replace children with a single label with state
6764 {
68- match : / ( { v a r i a n t : " e y e b r o w " , c l a s s N a m e : \i \. \i , c h i l d r e n : ) . { 70 , 110 } { c h i l d r e n : " \\ x b 7 " } \) , \( 0 , \i \. \i \) \( " s p a n " , { children:\i \[ \d + \] } \) \] } \) \] / ,
69- replace : "$1$self.renderName (arguments[0])"
65+ match : / ( # { intl:: A U T H _ S E S S I O N S _ A C T I V E _ R E C E N T L Y } . { 0 , 230 } r o l e : " l i s t i t e m " , c h i l d r e n : \[ . { 0 , 15 } , \{ I c o n : ) \i / ,
66+ replace : "$1()=> $self.renderIcon (arguments[0])"
7067 } ,
7168 {
72- match : / ( { v a r i a n t : " t e x t - s m \/ m e d i u m " , c l a s s N a m e : \i \. \i , c h i l d r e n : . { 70 , 110 } { c h i l d r e n : " \\ x b 7 " } \) , \( 0 , \i \. \i \) \( " s p a n " , { children:) ( \i \[ \d + \] ) } / ,
73- replace : "$1$self.renderTimestamp({... arguments[0],timeLabel:$2})} "
69+ match : / ( " h o r i z o n t a l " , g a p : " x s " , c h i l d r e n : ) \[ . { 0 , 250 } " t e x t - s u b t l e " , c h i l d r e n : \i \} \) \] \} \) , / ,
70+ replace : "$1$self.renderName( arguments[0])}), "
7471 } ,
75- // Replace the icon
7672 {
77- match : / (?< = I c o n : ( \i ) .{ 0 , 250 } c l a s s N a m e : \i \. \i , c h i l d r e n : \[ ) / ,
78- replace : "$self.renderIcon({...arguments[0],DeviceIcon:$1}),false&&"
79- }
73+ match : / ( " t e x t - m u t e d " , c h i l d r e n : ) \i (? = \} \) \] \} \) , .{ 0 , 120 } \. c l i e n t _ i n f o \? \. l o c a t i o n ) / ,
74+ replace : "$1$self.renderDescription(arguments[0])"
75+ } ,
76+ {
77+ match : / : \i \( \i \. a p p r o x _ l a s t _ u s e d _ t i m e \) .{ 0 , 40 } \( 0 , \i \. j s x s ? \) \( \i , \{ / ,
78+ replace : "$&session:arguments[0]?.session,"
79+ } ,
8080 ]
81- }
81+ } ,
8282 ] ,
8383
8484 renderName : ErrorBoundary . wrap ( ( { session } : SessionInfo ) => {
8585 const savedSession = savedSessionsCache . get ( session . id_hash ) ;
8686
8787 const state = React . useState ( savedSession ?. name ? `${ savedSession . name } *` : getDefaultName ( session . client_info ) ) ;
8888 const [ title , setTitle ] = state ;
89-
9089 // Show a "NEW" badge if the session is seen for the first time
9190 return (
9291 < >
93- < span > { title } </ span >
94- { ( savedSession == null || savedSession . isNew ) && (
95- < NewButton />
96- ) }
97- < RenameButton session = { session } state = { state } />
92+ < Paragraph size = "md" weight = "semibold" color = "text-strong" > { title } </ Paragraph >
93+ < div className = { cl ( "footer-buttons" ) } >
94+ { ( savedSession == null || savedSession . isNew ) && (
95+ < NewButton />
96+ ) }
97+ < RenameButton session = { session } state = { state } />
98+ </ div >
9899 </ >
99100 ) ;
100101 } , { noop : true } ) ,
101102
102- renderTimestamp : ErrorBoundary . wrap ( ( { session, timeLabel } : { session : Session , timeLabel : string ; } ) => {
103+ renderDescription : ErrorBoundary . wrap ( ( { session, description } : { session : Session , description : string ; } ) => {
104+ const [ label , timeLabel ] = description . split ( " \xb7 " ) ;
105+
103106 return (
104- < Tooltip text = { session . approx_last_used_time . toLocaleString ( ) } >
105- { props => (
106- < span { ...props } className = { TimestampClasses . timestamp } >
107- { timeLabel }
108- </ span >
107+ < div className = { cl ( "description" ) } >
108+ < Paragraph size = "sm" weight = "normal" color = "text-muted" > { label } </ Paragraph >
109+ { timeLabel && (
110+ < >
111+ { " \xb7 " }
112+ < Tooltip text = { session . approx_last_used_time . toLocaleString ( ) } >
113+ { props => (
114+ < span { ...props } className = { TimestampClasses . timestamp } >
115+ { timeLabel }
116+ </ span >
117+ ) }
118+ </ Tooltip >
119+ </ >
109120 ) }
110- </ Tooltip >
121+ </ div >
111122 ) ;
112123 } , { noop : true } ) ,
113124
114- renderIcon : ErrorBoundary . wrap ( ( { session, DeviceIcon } : { session : Session , DeviceIcon : React . ComponentType < any > ; } ) => {
125+ renderIcon : ErrorBoundary . wrap ( ( { session, icon : DeviceIcon } : { session : Session ; icon : React . ComponentType < any > ; } ) => {
115126 const PlatformIcon = GetPlatformIcon ( session . client_info . platform ) ;
116127
117128 return (
@@ -120,22 +131,8 @@ export default definePlugin({
120131 style = { { cursor : "unset" } }
121132 selected = { false }
122133 lowerBadge = {
123- < div
124- style = { {
125- width : "20px" ,
126- height : "20px" ,
127-
128- display : "flex" ,
129- justifyContent : "center" ,
130- alignItems : "center" ,
131- overflow : "hidden" ,
132-
133- borderRadius : "50%" ,
134- backgroundColor : "var(--interactive-icon-default)" ,
135- color : "var(--background-base-lower)" ,
136- } }
137- >
138- < PlatformIcon width = { 14 } height = { 14 } />
134+ < div className = { cl ( "lowerBadge" ) } >
135+ < PlatformIcon width = { 14 } height = { 14 } className = { cl ( "lowerBadge-icon" ) } />
139136 </ div >
140137 }
141138 lowerBadgeSize = { {
@@ -144,7 +141,7 @@ export default definePlugin({
144141 } }
145142 >
146143 < div
147- className = { SessionIconClasses . sessionIcon }
144+ className = { cl ( "icon" ) }
148145 style = { { backgroundColor : GetOsColor ( session . client_info . os ) } }
149146 >
150147 < DeviceIcon size = "md" color = "currentColor" />
0 commit comments