fix exhaustive-deps warnings for custom hooks
This commit is contained in:
parent
b615e6ccba
commit
33d5987269
@ -50,8 +50,8 @@ const ImageEditInput: FC<ImageEditInputProps> = (props: ImageEditInputProps) =>
|
|||||||
return './img/error.png';
|
return './img/error.png';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
[value, setValid, isMounted, setMessage],
|
||||||
'./img/loading.svg',
|
'./img/loading.svg',
|
||||||
[value],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -28,7 +28,7 @@ const TokenRow: FC<TokenRowProps> = (props: TokenRowProps) => {
|
|||||||
|
|
||||||
const guildMeta = useRecoilValue(guildMetaState(guild.id));
|
const guildMeta = useRecoilValue(guildMetaState(guild.id));
|
||||||
|
|
||||||
const [guildSocketConfigs] = useOneTimeAsyncAction(async () => await guild.fetchSocketConfigs(), null, [guild]);
|
const [guildSocketConfigs] = useOneTimeAsyncAction(async () => await guild.fetchSocketConfigs(), [guild], null);
|
||||||
const iconSrc = useRecoilValueSoftImgSrc(
|
const iconSrc = useRecoilValueSoftImgSrc(
|
||||||
guildResourceSoftImgSrcState({
|
guildResourceSoftImgSrcState({
|
||||||
guildId: guild.id,
|
guildId: guild.id,
|
||||||
|
@ -70,7 +70,7 @@ const AddGuildOverlay: FC<AddGuildOverlayProps> = (props: AddGuildOverlayProps)
|
|||||||
const [avatarInputMessage, setAvatarInputMessage] = useState<string | null>(null);
|
const [avatarInputMessage, setAvatarInputMessage] = useState<string | null>(null);
|
||||||
const [avatarInputValid, setAvatarInputValid] = useState<boolean>(false);
|
const [avatarInputValid, setAvatarInputValid] = useState<boolean>(false);
|
||||||
|
|
||||||
const [exampleAvatarBuff, exampleAvatarBuffError] = useOneTimeAsyncAction(async () => await fs.readFile(exampleAvatarPath), null, [exampleAvatarPath]);
|
const [exampleAvatarBuff, exampleAvatarBuffError] = useOneTimeAsyncAction(async () => await fs.readFile(exampleAvatarPath), [exampleAvatarPath], null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (exampleAvatarBuff) {
|
if (exampleAvatarBuff) {
|
||||||
@ -103,7 +103,7 @@ const AddGuildOverlay: FC<AddGuildOverlayProps> = (props: AddGuildOverlayProps)
|
|||||||
|
|
||||||
setOverlay(null);
|
setOverlay(null);
|
||||||
return { result: newGuild, errorMessage: null };
|
return { result: newGuild, errorMessage: null };
|
||||||
}, [displayName, avatarBuff, displayNameInputValid, avatarInputValid, setOverlay]);
|
}, [guildsManager, validationErrorMessage, expired, displayName, avatarBuff, setCurrGuildId, setOverlay, addGuildData]);
|
||||||
|
|
||||||
const errorMessage = useMemo(() => {
|
const errorMessage = useMemo(() => {
|
||||||
if (validationErrorMessage) return validationErrorMessage;
|
if (validationErrorMessage) return validationErrorMessage;
|
||||||
@ -114,11 +114,22 @@ const AddGuildOverlay: FC<AddGuildOverlayProps> = (props: AddGuildOverlayProps)
|
|||||||
return (
|
return (
|
||||||
<Overlay childRootRef={rootRef}>
|
<Overlay childRootRef={rootRef}>
|
||||||
<div ref={rootRef} className="content add-guild">
|
<div ref={rootRef} className="content add-guild">
|
||||||
<InvitePreview name={addGuildData.name} iconSrc={addGuildData.iconSrc} url={addGuildData.url} expiresFromNow={addGuildData.expires ? moment.duration(addGuildData.expires - Date.now(), 'ms') : null} />
|
<InvitePreview
|
||||||
|
name={addGuildData.name}
|
||||||
|
iconSrc={addGuildData.iconSrc}
|
||||||
|
url={addGuildData.url}
|
||||||
|
expiresFromNow={addGuildData.expires ? moment.duration(addGuildData.expires - Date.now(), 'ms') : null}
|
||||||
|
/>
|
||||||
<div className="divider" />
|
<div className="divider" />
|
||||||
<div className="personalization">
|
<div className="personalization">
|
||||||
<div className="avatar">
|
<div className="avatar">
|
||||||
<ImageEditInput maxSize={Globals.MAX_AVATAR_SIZE} value={avatarBuff} setValue={setAvatarBuff} setValid={setAvatarInputValid} setMessage={setAvatarInputMessage} />
|
<ImageEditInput
|
||||||
|
maxSize={Globals.MAX_AVATAR_SIZE}
|
||||||
|
value={avatarBuff}
|
||||||
|
setValue={setAvatarBuff}
|
||||||
|
setValid={setAvatarInputValid}
|
||||||
|
setMessage={setAvatarInputMessage}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="display-name">
|
<div className="display-name">
|
||||||
<TextInput
|
<TextInput
|
||||||
|
@ -89,7 +89,7 @@ const ChannelOverlay: FC<ChannelOverlayProps> = (props: ChannelOverlayProps) =>
|
|||||||
setOverlay(null);
|
setOverlay(null);
|
||||||
return { result: null, errorMessage: null };
|
return { result: null, errorMessage: null };
|
||||||
},
|
},
|
||||||
[guild, edited, validationErrorMessage, name, flavorText, setOverlay],
|
[guild, edited, channel, validationErrorMessage, name, flavorText, setOverlay],
|
||||||
{ start: channel ? 'Modify Channel' : 'Create Channel' },
|
{ start: channel ? 'Modify Channel' : 'Create Channel' },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ const PersonalizeOverlay: FC<PersonalizeOverlayProps> = (props: PersonalizeOverl
|
|||||||
setOverlay(null);
|
setOverlay(null);
|
||||||
return { result: null, errorMessage: null };
|
return { result: null, errorMessage: null };
|
||||||
},
|
},
|
||||||
[validationErrorMessage, displayName, savedDisplayName, avatarBuff, savedAvatarBuff, setOverlay],
|
[validationErrorMessage, displayName, savedDisplayName, guild, avatarBuff, savedAvatarBuff, setOverlay],
|
||||||
);
|
);
|
||||||
|
|
||||||
//if (saveFailed) return 'Unable to save personalization';
|
//if (saveFailed) return 'Unable to save personalization';
|
||||||
|
@ -61,8 +61,8 @@ function useShake(ms: number): [shaking: boolean, doShake: () => void] {
|
|||||||
// runs an Async action one time (updates when deps changes)
|
// runs an Async action one time (updates when deps changes)
|
||||||
export function useOneTimeAsyncAction<T, V>(
|
export function useOneTimeAsyncAction<T, V>(
|
||||||
actionFunc: () => Promise<T>,
|
actionFunc: () => Promise<T>,
|
||||||
initialValue: V,
|
|
||||||
deps: DependencyList,
|
deps: DependencyList,
|
||||||
|
initialValue: V,
|
||||||
): [value: T | V, error: unknown | null] {
|
): [value: T | V, error: unknown | null] {
|
||||||
const isMounted = useRef(false);
|
const isMounted = useRef(false);
|
||||||
|
|
||||||
@ -241,8 +241,8 @@ export function useDownloadButton(
|
|||||||
|
|
||||||
setText(textMapping.success);
|
setText(textMapping.success);
|
||||||
},
|
},
|
||||||
// TODO: look into this warning
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[downloadName, fetchBuff, ...fetchBuffDeps, filePath, fileBuffer],
|
[shaking, doShake, downloadName, fetchBuff, ...fetchBuffDeps, filePath, fileBuffer, textMapping.pendingFetch, textMapping.notReadyFetch, textMapping.errorFetch, textMapping.errorSave, textMapping.success],
|
||||||
);
|
);
|
||||||
|
|
||||||
return [callable, text, shaking];
|
return [callable, text, shaking];
|
||||||
|
@ -61,7 +61,7 @@ const GuildListContainer: FC = () => {
|
|||||||
} else {
|
} else {
|
||||||
setOverlay(<AddGuildOverlay addGuildData={addGuildData} />);
|
setOverlay(<AddGuildOverlay addGuildData={addGuildData} />);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [setOverlay]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="guild-list-container">
|
<div className="guild-list-container">
|
||||||
|
@ -42,8 +42,8 @@ const AttachmentPreview: FC<AttachmentPreviewProps> = (props: AttachmentPreviewP
|
|||||||
return './img/file-improved.svg';
|
return './img/file-improved.svg';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'./img/loading.svg',
|
|
||||||
[attachmentBuff],
|
[attachmentBuff],
|
||||||
|
'./img/loading.svg',
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -30,13 +30,11 @@ import EnsuredFetchable from './fetchable-ensured';
|
|||||||
import { EventEmitter } from 'tsee';
|
import { EventEmitter } from 'tsee';
|
||||||
import { AutoVerifierChangesType } from './auto-verifier';
|
import { AutoVerifierChangesType } from './auto-verifier';
|
||||||
import { IDQuery, PartialMessageListQuery } from './auto-verifier-with-args';
|
import { IDQuery, PartialMessageListQuery } from './auto-verifier-with-args';
|
||||||
import Util from './util';
|
|
||||||
|
|
||||||
/** the general guild class. This handles connecting a RAM, PersonalDB, and Socket guild together using fetchable-pair-verifiers and some manual caching to nicely update messages */
|
/** the general guild class. This handles connecting a RAM, PersonalDB, and Socket guild together using fetchable-pair-verifiers and some manual caching to nicely update messages */
|
||||||
export default class CombinedGuild
|
export default class CombinedGuild
|
||||||
extends EventEmitter<Connectable & Conflictable>
|
extends EventEmitter<Connectable & Conflictable>
|
||||||
implements AsyncGuaranteedFetchable, AsyncRequestable
|
implements AsyncGuaranteedFetchable, AsyncRequestable {
|
||||||
{
|
|
||||||
private readonly ramGuild: RAMGuild;
|
private readonly ramGuild: RAMGuild;
|
||||||
private readonly personalDBGuild: PersonalDBGuild;
|
private readonly personalDBGuild: PersonalDBGuild;
|
||||||
private readonly socketGuild: SocketGuild;
|
private readonly socketGuild: SocketGuild;
|
||||||
|
Loading…
Reference in New Issue
Block a user