Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Delusoire committed Sep 15, 2024
1 parent a1242a5 commit 2407097
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 31 deletions.
30 changes: 15 additions & 15 deletions archived/sort-plus/sortPlus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ const setQueue = (tracks: TrackData[]) => {

const sortTracksBy =
(sortAction: typeof lastSortAction, sortFn: AsyncTracksOperation, descending: boolean) =>
async (uri: string) => {
lastSortAction = sortAction;
lastFetchedUri = uri;
const tracks = await getTracksFromUri(uri);
let sortedTracks = await sortFn(tracks);
if (CONFIG.preventDuplicates) {
sortedTracks = _.uniqBy(sortedTracks, "name");
}
descending && sortedTracks.reverse();
return await setQueue(sortedTracks);
};

type SortBySubMenuItemProps = { descending: boolean; };
type GenericSortBySubMenuItemProps = SortBySubMenuItemProps & { sortAction: SortAction; };
async (uri: string) => {
lastSortAction = sortAction;
lastFetchedUri = uri;
const tracks = await getTracksFromUri(uri);
let sortedTracks = await sortFn(tracks);
if (CONFIG.preventDuplicates) {
sortedTracks = _.uniqBy(sortedTracks, "name");
}
descending && sortedTracks.reverse();
return await setQueue(sortedTracks);
};

type SortBySubMenuItemProps = { descending: boolean };
type GenericSortBySubMenuItemProps = SortBySubMenuItemProps & { sortAction: SortAction };
const GenericSortBySubMenuItem = ({ descending, sortAction }: GenericSortBySubMenuItemProps) => {
const { props } = useMenuItem();
const uri = props.uri;
Expand Down Expand Up @@ -104,7 +104,7 @@ import { useMenuItem } from "/modules/stdlib/src/registers/menu.js";
import { is } from "/modules/stdlib/src/webpack/URI.ts";
import { Platform } from "/modules/stdlib/src/expose/Platform.ts";
import { MenuItem, MenuItemSubMenu } from "/modules/stdlib/src/webpack/ReactComponents.ts";
import { useContextMenuState } from "/modules/stdlib/src/webpack/CustomHooks.ts";
import { useContextMenuState } from "/modules/stdlib/src/webpack/ReactHooks.ts";
import { Snackbar } from "/modules/stdlib/src/expose/Snackbar.ts";

const SortByShuffleSubMenuItem = ({ descending }: SortBySubMenuItemProps) => {
Expand Down
6 changes: 3 additions & 3 deletions modules/marketplace/src/components/ModuleCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AuthorsDiv from "./AuthorsDiv.tsx";
import TagsDiv from "./TagsDiv.tsx";
import { type Metadata, type Module, type ModuleIdentifier, type ModuleInstance } from "/hooks/module.ts";
import { useUpdate } from "../../util/index.ts";
import { Cards, SettingsToggle } from "/modules/stdlib/src/webpack/ReactComponents.ts";
import { Cards, Toggle } from "/modules/stdlib/src/webpack/ReactComponents.ts";
import { classnames } from "/modules/stdlib/src/webpack/ClassNames.ts";
import { useQuery } from "/modules/stdlib/src/webpack/ReactQuery.ts";
import { display } from "/modules/stdlib/lib/modal.tsx";
Expand Down Expand Up @@ -308,8 +308,8 @@ const ModuleCard = (props: ModuleCardProps) => {
>
{fastInstallDeleteButton}
</button>
{showLoaded && SettingsToggle && (
<SettingsToggle
{showLoaded && Toggle && (
<Toggle
className="x-settings-button justify-end"
value={loaded}
onSelected={onToggleLoaded}
Expand Down
2 changes: 1 addition & 1 deletion modules/marketplace/src/components/VersionList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { parse, parseRange, satisfies } from "/hooks/std/semver.ts";
import { React } from "/modules/stdlib/src/expose/React.ts";
import { classnames } from "/modules/stdlib/src/webpack/ClassNames.ts";
import { UI } from "/modules/stdlib/src/webpack/ComponentLibrary.ts";
import { usePanelAPI } from "/modules/stdlib/src/webpack/CustomHooks.ts";
import { usePanelAPI } from "/modules/stdlib/src/webpack/ReactHooks.ts";
import { ScrollableText } from "/modules/stdlib/src/webpack/ReactComponents.js";
import { PanelContainer, PanelContent, PanelHeader } from "/modules/stdlib/src/webpack/ReactComponents.ts";
import { useQuery } from "/modules/stdlib/src/webpack/ReactQuery.ts";
Expand Down
2 changes: 1 addition & 1 deletion modules/marketplace/src/pages/Marketplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useDropdown,
useSearchBar,
} from "/modules/stdlib/lib/components/index.tsx";
import { usePanelAPI } from "/modules/stdlib/src/webpack/CustomHooks.ts";
import { usePanelAPI } from "/modules/stdlib/src/webpack/ReactHooks.ts";
import { useModules } from "../components/ModulesProvider/index.tsx";

const SortOptions = {
Expand Down
4 changes: 2 additions & 2 deletions modules/more-columns/patchPlaylistApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function patchPlaylistContents(contents: any, opts: any) {
const albums = await getAlbumsFromURIs(albumUris);
items.forEach((track, i) => {
const album = albums[i];
const albumTracks = album.tracks.items.map((w) => w.track);
const albumTracks = album.tracksV2.items.map((w) => w.track);
const albumTrack = albumTracks.find((albumTrack) => albumTrack.uri === track.uri);
track.albumAlbum = album;
track.albumTrack = albumTrack;
Expand All @@ -68,7 +68,7 @@ export async function patchPlaylistContents(contents: any, opts: any) {
const p = (track) => Number(track.albumTrack.playcount ?? -1);
order = (a, b) => p(a) - p(b);
} else if (isReleaseDateSort) {
const p = (track) => new Date(track.albumTrack.date.isoString);
const p = (track) => new Date(track.albumAlbum.date.isoString);
order = (a, b) => p(a) - p(b);
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/statistics/pages/top_genres.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useStatus } from "../components/status/useStatus.tsx";
import { logger, settingsButton, storage } from "../mod.tsx";
import { useDropdown } from "/modules/stdlib/lib/components/index.tsx";
import { useQuery } from "/modules/stdlib/src/webpack/ReactQuery.ts";
import { getPlayContext } from "/modules/stdlib/src/webpack/CustomHooks.ts";
import { getPlayContext } from "/modules/stdlib/src/webpack/ReactHooks.ts";
import {
Tracklist,
TracklistColumnsContextProvider,
Expand Down Expand Up @@ -61,7 +61,7 @@ export const calculateTracksMeta = (tracks: Track[]) => {
};
};

const GenresTrackRow = ({ track, index }: { track: Track; index: number; }) => {
const GenresTrackRow = ({ track, index }: { track: Track; index: number }) => {
const { usePlayContextItem } = getPlayContext({ uri: "" }, { featureIdentifier: "queue" });

return (
Expand Down
2 changes: 1 addition & 1 deletion modules/statistics/pages/top_tracks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
TracklistColumnsContextProvider,
TracklistRow,
} from "/modules/stdlib/src/webpack/ReactComponents.ts";
import { getPlayContext, useTrackListColumns } from "/modules/stdlib/src/webpack/CustomHooks.ts";
import { getPlayContext, useTrackListColumns } from "/modules/stdlib/src/webpack/ReactHooks.ts";
import { SCROBBLES_COLUMN_TYPE } from "/modules/Delusoire.more-columns/columns.ts";
import { getLFMTracks } from "/modules/Delusoire.more-columns/patchPlaylistApi.ts";
import { exportedFunctions } from "/modules/stdlib/src/webpack/index.ts";
Expand Down
20 changes: 14 additions & 6 deletions modules/tracklist-columns/mix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,13 @@ globalThis.__patchColumnTypeToColumnLabelMap = (x) => {

function tracklistColumn(transformer: Transformer) {
transformer((emit) => (str) => {
emit();

str = str.replace(
/(\(0,([a-zA-Z_\$][\w\$]*)\.jsx\)\([a-zA-Z_\$][\w\$]*\.[a-zA-Z_\$][\w\$]*,{resolveItem:[a-zA-Z_\$][\w\$]*,getItems:[a-zA-Z_\$][\w\$]*,nrTracks:[a-zA-Z_\$][\w\$]*),children:\(0,\2\.jsx\)/,
"$1,children:((type,props)=>($2.jsx(type,__patchTracklistWrapperProps(props))))",
);

str = str.replaceAll(
/(switch\(([a-zA-Z_\$][\w\$]*)\){case [a-zA-Z_\$][\w\$]*\.[a-zA-Z_\$][\w\$]*\.INDEX:.*?default):/g,
"$1:return __patchRenderTracklistRowColumn($2);",
);

str = str.replace(
/([a-zA-Z_\$][\w\$]*)=([a-zA-Z_\$][\w\$]*)\[([a-zA-Z_\$][\w\$]*)\],(?=.*\.jsxs?\)\(\1,[^;]*columnIndex:)/,
"$1=$2[$3]??__patchTracklistColumnHeaderContextMenu($3),",
Expand All @@ -83,11 +80,22 @@ function tracklistColumn(transformer: Transformer) {
"globalThis.__patchColumnTypeToColumnLabelMap({$1})",
);

return str;
}, {
glob: /^\/xpui\.js$/,
});

transformer((emit) => (str) => {
emit();

str = str.replaceAll(
/(switch\(([a-zA-Z_\$][\w\$]*)\){case [a-zA-Z_\$][\w\$]*\.[a-zA-Z_\$][\w\$]*\.INDEX:.*?default):/g,
"$1:return __patchRenderTracklistRowColumn($2);",
);

return str;
}, {
glob: /^\/xpui\.js$/,
glob: /\.js$/,
});
}

Expand Down

0 comments on commit 2407097

Please sign in to comment.