PatchComponentRedo (#5136)

* PatchComponent update specifically for SettingsInterfacePanel
* Fix unrelated lint issues
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Gykes
2024-08-19 21:25:06 -07:00
committed by GitHub
parent 49060e6686
commit 7788a6fd07
5 changed files with 878 additions and 870 deletions

View File

@@ -192,7 +192,7 @@ func (me *contentDirectoryService) Handle(action string, argsXML []byte, r *http
obj, err := me.objectFromID(browse.ObjectID)
if err != nil {
return nil, upnp.Errorf(upnpav.NoSuchObjectErrorCode, err.Error())
return nil, upnp.Errorf(upnpav.NoSuchObjectErrorCode, "cannot find object with id %q: %v", browse.ObjectID, err.Error())
}
switch browse.BrowseFlag {

View File

@@ -76,7 +76,7 @@ func (t *rawPluginTask) Start() error {
if err != nil {
logger.Warnf("error marshalling raw command input")
}
if k, err := io.WriteString(stdin, string(inBytes)); err != nil {
if k, err := stdin.Write(inBytes); err != nil {
logger.Warnf("error writing input to plugins stdin (wrote %v bytes out of %v): %v", k, len(string(inBytes)), err)
}
}()

View File

@@ -1338,7 +1338,7 @@ func (c *Client) submitDraft(ctx context.Context, query string, input interface{
return fmt.Errorf("failed to decode data %s: %w", string(responseBytes), err)
}
if respGQL.Errors != nil && len(respGQL.Errors) > 0 {
if len(respGQL.Errors) > 0 {
// try to parse standard graphql error
errors := &client.GqlErrorList{}
if e := json.Unmarshal(responseBytes, errors); e != nil {

View File

@@ -1,5 +1,6 @@
import React from "react";
import { BooleanSetting } from "../Inputs";
import { PatchComponent } from "src/patch";
interface IItem {
id: string;
@@ -13,12 +14,9 @@ interface ICheckboxGroupProps {
onChange?: (ids: string[]) => void;
}
export const CheckboxGroup: React.FC<ICheckboxGroupProps> = ({
groupId,
items,
checkedIds = [],
onChange,
}) => {
export const CheckboxGroup: React.FC<ICheckboxGroupProps> = PatchComponent(
"CheckboxGroup",
({ groupId, items, checkedIds = [], onChange }) => {
function generateId(itemId: string) {
return `${groupId}-${itemId}`;
}
@@ -58,4 +56,5 @@ export const CheckboxGroup: React.FC<ICheckboxGroupProps> = ({
))}
</>
);
};
}
);

View File

@@ -43,6 +43,7 @@ import {
defaultImageWallMargin,
} from "src/utils/imageWall";
import { defaultMaxOptionsShown } from "src/core/config";
import { PatchComponent } from "src/patch";
const allMenuItems = [
{ id: "scenes", headingID: "scenes" },
@@ -55,7 +56,9 @@ const allMenuItems = [
{ id: "tags", headingID: "tags" },
];
export const SettingsInterfacePanel: React.FC = () => {
export const SettingsInterfacePanel: React.FC = PatchComponent(
"SettingsInterfacePanel",
function SettingsInterfacePanel() {
const intl = useIntl();
const {
@@ -66,7 +69,6 @@ export const SettingsInterfacePanel: React.FC = () => {
loading,
error,
} = useSettings();
// convert old movies menu item to groups
const massageMenuItems = useCallback((menuItems: string[]) => {
return menuItems.map((item) => {
@@ -97,15 +99,13 @@ export const SettingsInterfacePanel: React.FC = () => {
function saveLightboxSettings(v: Partial<GQL.ConfigImageLightboxInput>) {
// save in local forage as well for consistency
setInterfaceLocalForage((prev) => {
return {
setInterfaceLocalForage((prev) => ({
...prev,
imageLightbox: {
...prev.imageLightbox,
...v,
},
};
});
}));
saveInterface({
imageLightbox: {
@@ -189,6 +189,7 @@ export const SettingsInterfacePanel: React.FC = () => {
if (loading) return <LoadingIndicator />;
// https://en.wikipedia.org/wiki/List_of_language_names
return (
<>
<SettingSection headingID="config.ui.basic_settings">
@@ -239,7 +240,9 @@ export const SettingsInterfacePanel: React.FC = () => {
})}
</h3>
<div className="sub-heading">
{intl.formatMessage({ id: "config.ui.menu_items.description" })}
{intl.formatMessage({
id: "config.ui.menu_items.description",
})}
</div>
</div>
<div />
@@ -248,7 +251,9 @@ export const SettingsInterfacePanel: React.FC = () => {
groupId="menu-items"
items={allMenuItems}
checkedIds={massagedMenuItems ?? undefined}
onChange={(v) => saveInterface({ menuItems: massageMenuItems(v) })}
onChange={(v) =>
saveInterface({ menuItems: massageMenuItems(v) })
}
/>
</div>
@@ -301,7 +306,9 @@ export const SettingsInterfacePanel: React.FC = () => {
onChange={(v) => saveInterface({ wallPlayback: v })}
>
<option value="video">
{intl.formatMessage({ id: "config.ui.preview_type.options.video" })}
{intl.formatMessage({
id: "config.ui.preview_type.options.video",
})}
</option>
<option value="animation">
{intl.formatMessage({
@@ -533,7 +540,8 @@ export const SettingsInterfacePanel: React.FC = () => {
headingID="dialogs.lightbox.scroll_mode.label"
subHeadingID="dialogs.lightbox.scroll_mode.description"
value={
iface.imageLightbox?.scrollMode ?? GQL.ImageLightboxScrollMode.Zoom
iface.imageLightbox?.scrollMode ??
GQL.ImageLightboxScrollMode.Zoom
}
onChange={(v) =>
saveLightboxSettings({
@@ -925,4 +933,5 @@ export const SettingsInterfacePanel: React.FC = () => {
</SettingSection>
</>
);
};
}
);