mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
@@ -29,19 +29,19 @@ import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrap
|
||||
import { useHotkey } from '@/hooks/Mapper/hooks';
|
||||
import { COMPACT_MAX_WIDTH } from './constants';
|
||||
|
||||
export const SIGNATURE_SETTINGS_KEY = 'wanderer_system_signature_settings_v5_2';
|
||||
const SIGNATURE_SETTINGS_KEY = 'wanderer_system_signature_settings_v5_5';
|
||||
export const SHOW_DESCRIPTION_COLUMN_SETTING = 'show_description_column_setting';
|
||||
export const SHOW_UPDATED_COLUMN_SETTING = 'SHOW_UPDATED_COLUMN_SETTING';
|
||||
export const SHOW_CHARACTER_COLUMN_SETTING = 'SHOW_CHARACTER_COLUMN_SETTING';
|
||||
export const LAZY_DELETE_SIGNATURES_SETTING = 'LAZY_DELETE_SIGNATURES_SETTING';
|
||||
export const KEEP_LAZY_DELETE_SETTING = 'KEEP_LAZY_DELETE_ENABLED_SETTING';
|
||||
export const HIDE_LINKED_SIGNATURES_SETTING = 'HIDE_LINKED_SIGNATURES_SETTING';
|
||||
|
||||
const SETTINGS: Setting[] = [
|
||||
{ key: SHOW_UPDATED_COLUMN_SETTING, name: 'Show Updated Column', value: false, isFilter: false },
|
||||
{ key: SHOW_DESCRIPTION_COLUMN_SETTING, name: 'Show Description Column', value: false, isFilter: false },
|
||||
{ key: SHOW_CHARACTER_COLUMN_SETTING, name: 'Show Character Column', value: false, isFilter: false },
|
||||
{ key: LAZY_DELETE_SIGNATURES_SETTING, name: 'Lazy Delete Signatures', value: false, isFilter: false },
|
||||
{ key: KEEP_LAZY_DELETE_SETTING, name: 'Keep "Lazy Delete" Enabled', value: false, isFilter: false },
|
||||
{ key: HIDE_LINKED_SIGNATURES_SETTING, name: 'Hide Linked Signatures', value: false, isFilter: false },
|
||||
|
||||
{ key: COSMIC_ANOMALY, name: 'Show Anomalies', value: true, isFilter: true },
|
||||
{ key: COSMIC_SIGNATURE, name: 'Show Cosmic Signatures', value: true, isFilter: true },
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
LAZY_DELETE_SIGNATURES_SETTING,
|
||||
SHOW_DESCRIPTION_COLUMN_SETTING,
|
||||
SHOW_UPDATED_COLUMN_SETTING,
|
||||
SHOW_CHARACTER_COLUMN_SETTING,
|
||||
} from '../SystemSignatures';
|
||||
import { COSMIC_SIGNATURE } from '../SystemSignatureSettingsDialog';
|
||||
import {
|
||||
@@ -34,6 +35,16 @@ import { getSignatureRowClass } from '../helpers/rowStyles';
|
||||
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth';
|
||||
import { useClipboard, useHotkey } from '@/hooks/Mapper/hooks';
|
||||
|
||||
type SystemSignaturesSortSettings = {
|
||||
sortField: string;
|
||||
sortOrder: SortOrder;
|
||||
};
|
||||
|
||||
const SORT_DEFAULT_VALUES: SystemSignaturesSortSettings = {
|
||||
sortField: 'inserted_at',
|
||||
sortOrder: -1,
|
||||
};
|
||||
|
||||
interface SystemSignaturesContentProps {
|
||||
systemId: string;
|
||||
settings: { key: string; value: boolean }[];
|
||||
@@ -41,7 +52,7 @@ interface SystemSignaturesContentProps {
|
||||
selectable?: boolean;
|
||||
onSelect?: (signature: SystemSignature) => void;
|
||||
onLazyDeleteChange?: (value: boolean) => void;
|
||||
onCountChange: (count: number) => void;
|
||||
onCountChange?: (count: number) => void;
|
||||
onPendingChange?: (pending: ExtendedSystemSignature[], undo: () => void) => void;
|
||||
}
|
||||
|
||||
@@ -68,7 +79,7 @@ export function SystemSignaturesContent({
|
||||
|
||||
const [sortSettings, setSortSettings] = useLocalStorageState<{ sortField: string; sortOrder: SortOrder }>(
|
||||
'window:signatures:sort',
|
||||
{ defaultValue: { sortField: 'inserted_at', sortOrder: -1 } },
|
||||
{ defaultValue: SORT_DEFAULT_VALUES },
|
||||
);
|
||||
|
||||
const tableRef = useRef<HTMLDivElement>(null);
|
||||
@@ -148,6 +159,7 @@ export function SystemSignaturesContent({
|
||||
const groupSettings = settings.filter(s => GROUPS_LIST.includes(s.key as SignatureGroup));
|
||||
const showDescriptionColumn = settings.find(s => s.key === SHOW_DESCRIPTION_COLUMN_SETTING)?.value;
|
||||
const showUpdatedColumn = settings.find(s => s.key === SHOW_UPDATED_COLUMN_SETTING)?.value;
|
||||
const showCharacterColumn = settings.find(s => s.key === SHOW_CHARACTER_COLUMN_SETTING)?.value;
|
||||
|
||||
const filteredSignatures = useMemo<ExtendedSystemSignature[]>(() => {
|
||||
return signatures.filter(sig => {
|
||||
@@ -278,6 +290,16 @@ export function SystemSignaturesContent({
|
||||
sortable
|
||||
/>
|
||||
)}
|
||||
|
||||
{showCharacterColumn && (
|
||||
<Column
|
||||
field="character_name"
|
||||
header="Character"
|
||||
bodyClassName="w-[70px] text-ellipsis overflow-hidden whitespace-nowrap"
|
||||
sortable
|
||||
></Column>
|
||||
)}
|
||||
|
||||
{!selectable && (
|
||||
<Column
|
||||
header=""
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface UseSystemSignaturesDataProps {
|
||||
systemId: string;
|
||||
settings: { key: string; value: boolean }[];
|
||||
hideLinkedSignatures?: boolean;
|
||||
onCountChange: (count: number) => void;
|
||||
onCountChange?: (count: number) => void;
|
||||
onPendingChange?: (pending: ExtendedSystemSignature[], undo: () => void) => void;
|
||||
onLazyDeleteChange?: (value: boolean) => void;
|
||||
}
|
||||
@@ -21,7 +21,6 @@ export interface UseFetchingParams {
|
||||
systemId: string;
|
||||
signaturesRef: React.MutableRefObject<ExtendedSystemSignature[]>;
|
||||
setSignatures: React.Dispatch<React.SetStateAction<ExtendedSystemSignature[]>>;
|
||||
outCommand: OutCommandHandler;
|
||||
localPendingDeletions: ExtendedSystemSignature[];
|
||||
}
|
||||
|
||||
@@ -30,7 +29,6 @@ export interface UseFetchingParams {
|
||||
*/
|
||||
export interface UsePendingDeletionParams {
|
||||
systemId: string;
|
||||
outCommand: OutCommandHandler;
|
||||
setSignatures: React.Dispatch<React.SetStateAction<ExtendedSystemSignature[]>>;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ import { OutCommand } from '@/hooks/Mapper/types/mapHandlers';
|
||||
import { ExtendedSystemSignature, prepareUpdatePayload, scheduleLazyDeletionTimers } from '../helpers';
|
||||
import { UsePendingDeletionParams } from './types';
|
||||
import { FINAL_DURATION_MS } from '../constants';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
|
||||
export function usePendingDeletions({ systemId, outCommand, setSignatures }: UsePendingDeletionParams) {
|
||||
export function usePendingDeletions({ systemId, setSignatures }: UsePendingDeletionParams) {
|
||||
const { outCommand } = useMapRootState();
|
||||
const [localPendingDeletions, setLocalPendingDeletions] = useState<ExtendedSystemSignature[]>([]);
|
||||
const [pendingDeletionMap, setPendingDeletionMap] = useState<
|
||||
Record<string, { finalUntil: number; finalTimeoutId: number }>
|
||||
|
||||
@@ -3,14 +3,19 @@ import { SystemSignature } from '@/hooks/Mapper/types';
|
||||
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers';
|
||||
import { ExtendedSystemSignature, prepareUpdatePayload, getActualSigs } from '../helpers';
|
||||
import { UseFetchingParams } from './types';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
|
||||
export function useSignatureFetching({
|
||||
systemId,
|
||||
signaturesRef,
|
||||
setSignatures,
|
||||
outCommand,
|
||||
localPendingDeletions,
|
||||
}: UseFetchingParams) {
|
||||
const {
|
||||
data: { characters },
|
||||
outCommand,
|
||||
} = useMapRootState();
|
||||
|
||||
const handleGetSignatures = useCallback(async () => {
|
||||
if (!systemId) {
|
||||
setSignatures([]);
|
||||
@@ -24,9 +29,12 @@ export function useSignatureFetching({
|
||||
data: { system_id: systemId },
|
||||
});
|
||||
const serverSigs = (resp.signatures ?? []) as SystemSignature[];
|
||||
const extended = serverSigs.map(x => ({ ...x })) as ExtendedSystemSignature[];
|
||||
const extended = serverSigs.map(s => ({
|
||||
...s,
|
||||
character_name: characters.find(c => c.eve_id === s.character_eve_id)?.name,
|
||||
})) as ExtendedSystemSignature[];
|
||||
setSignatures(extended);
|
||||
}, [systemId, localPendingDeletions, outCommand, setSignatures]);
|
||||
}, [characters, systemId, localPendingDeletions, outCommand, setSignatures]);
|
||||
|
||||
const handleUpdateSignatures = useCallback(
|
||||
async (newList: ExtendedSystemSignature[], updateOnly: boolean, skipUpdateUntouched?: boolean) => {
|
||||
@@ -37,14 +45,12 @@ export function useSignatureFetching({
|
||||
skipUpdateUntouched,
|
||||
);
|
||||
|
||||
const resp = await outCommand({
|
||||
await outCommand({
|
||||
type: OutCommand.updateSignatures,
|
||||
data: prepareUpdatePayload(systemId, added, updated, removed),
|
||||
});
|
||||
const final = (resp.signatures ?? []) as SystemSignature[];
|
||||
setSignatures(final.map(x => ({ ...x })) as ExtendedSystemSignature[]);
|
||||
},
|
||||
[systemId, signaturesRef, outCommand, setSignatures],
|
||||
[systemId, signaturesRef, outCommand],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -33,7 +33,6 @@ export function useSystemSignaturesData({
|
||||
const { localPendingDeletions, setLocalPendingDeletions, processRemovedSignatures, clearPendingDeletions } =
|
||||
usePendingDeletions({
|
||||
systemId,
|
||||
outCommand,
|
||||
setSignatures,
|
||||
});
|
||||
|
||||
@@ -46,7 +45,6 @@ export function useSystemSignaturesData({
|
||||
systemId,
|
||||
signaturesRef,
|
||||
setSignatures,
|
||||
outCommand,
|
||||
localPendingDeletions,
|
||||
});
|
||||
|
||||
@@ -191,7 +189,7 @@ export function useSystemSignaturesData({
|
||||
}, [systemId, handleGetSignatures, setSignatures]);
|
||||
|
||||
useEffect(() => {
|
||||
onCountChange(signatures.length);
|
||||
onCountChange?.(signatures.length);
|
||||
}, [signatures, onCountChange]);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user