BetterSessions: Improve Patches
This commit is contained in:
parent
715f29406b
commit
8d33776a96
3 changed files with 23 additions and 14 deletions
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
import { Button } from "@components/Button";
|
||||
import { SessionInfo } from "@plugins/betterSessions/types";
|
||||
import { cl } from "@plugins/betterSessions/utils";
|
||||
import { openModal } from "@webpack/common";
|
||||
|
||||
import { cl } from "../utils";
|
||||
import { RenameModal } from "./RenameModal";
|
||||
|
||||
export function RenameButton({ session, state }: { session: SessionInfo["session"], state: [string, React.Dispatch<React.SetStateAction<string>>]; }) {
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ export default definePlugin({
|
|||
find: "#{intl::AUTH_SESSIONS_OS_UNKNOWN}",
|
||||
replacement: [
|
||||
{
|
||||
match: /Icon:(\i)(?=.{0,85}gap:"xxs",children:\[)/,
|
||||
replace: "Icon:()=>$self.renderIcon({...arguments[0],DeviceIcon:$1})"
|
||||
match: /(?<=#{intl::AUTH_SESSIONS_ACTIVE_RECENTLY}.{0,230}role:"listitem",children:\[.{0,15},\{Icon:)(\i)/,
|
||||
replace: "()=>$self.renderIcon({...arguments[0],DeviceIcon:$1})"
|
||||
},
|
||||
{
|
||||
match: /(\.ICON_MUTED:"currentColor".{0,250}gap:"xs",children:)\[.*?"text-subtle",children:\i\}\)\]/,
|
||||
replace: "$1$self.renderName(arguments[0])"
|
||||
match: /("horizontal",gap:"xs",children:)\[.*?"text-subtle",children:\i\}\)\]\}\),/,
|
||||
replace: "$1$self.renderName(arguments[0])}),"
|
||||
},
|
||||
{
|
||||
match: /("text-muted",children:)\i(?=\}\)\]\}\),\i\])/,
|
||||
match: /("text-muted",children:)\i(?=\}\)\]\}\),.{0,120}\.client_info\?\.location)/,
|
||||
replace: "$1$self.renderDescription({...arguments[0]})"
|
||||
},
|
||||
{
|
||||
match: /:\i\(\i\.approx_last_used_time\).{0,50}\.jsxs?\)\(\i,\{/,
|
||||
match: /:\i\(\i\.approx_last_used_time\).{0,40}\(0,\i\.jsxs?\)\(\i,\{/,
|
||||
replace: "$&session:arguments[0]?.session,"
|
||||
},
|
||||
]
|
||||
|
|
@ -89,18 +89,19 @@ export default definePlugin({
|
|||
// Show a "NEW" badge if the session is seen for the first time
|
||||
return (
|
||||
<>
|
||||
<span>{title}</span>
|
||||
{(savedSession == null || savedSession.isNew) && (
|
||||
<NewButton />
|
||||
)}
|
||||
<RenameButton session={session} state={state} />
|
||||
<Paragraph size="md" weight="semibold" color="text-strong">{title}</Paragraph>
|
||||
<div className={cl("footer-buttons")}>
|
||||
{(savedSession == null || savedSession.isNew) && (
|
||||
<NewButton />
|
||||
)}
|
||||
<RenameButton session={session} state={state} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}, { noop: true }),
|
||||
|
||||
renderDescription: ErrorBoundary.wrap(({ session, description }: { session: Session, description: string; }) => {
|
||||
const label = description.split(" \xb7 ")[0];
|
||||
const timeLabel = description.split(" \xb7 ")[1];
|
||||
const [label, timeLabel] = description.split(" \\xb7 ");
|
||||
|
||||
return (
|
||||
<div className={cl("description")}>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
.vc-betterSessions-footer-buttons {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.vc-betterSessions-rename-btn {
|
||||
margin-left: 4px;
|
||||
translate: 0 -2px;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue