Handle promise linting (#5488)
This commit is contained in:
@@ -84,14 +84,14 @@ function CollectionScene() {
|
||||
setError(undefined);
|
||||
|
||||
if (collection) {
|
||||
pins.fetchPage({
|
||||
void pins.fetchPage({
|
||||
collectionId: collection.id,
|
||||
});
|
||||
}
|
||||
}, [pins, collection]);
|
||||
|
||||
React.useEffect(() => {
|
||||
async function load() {
|
||||
async function fetchData() {
|
||||
if ((!can || !collection) && !error && !isFetching) {
|
||||
try {
|
||||
setError(undefined);
|
||||
@@ -105,7 +105,7 @@ function CollectionScene() {
|
||||
}
|
||||
}
|
||||
|
||||
load();
|
||||
void fetchData();
|
||||
}, [collections, isFetching, collection, error, id, can]);
|
||||
|
||||
useCommandBarActions(
|
||||
|
||||
@@ -53,7 +53,7 @@ const MembershipPreview = ({ collection, limit = 8 }: Props) => {
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
void fetchData();
|
||||
}, [
|
||||
isMobile,
|
||||
collection.permission,
|
||||
|
||||
@@ -36,10 +36,7 @@ function AddGroupsToCollection(props: Props) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const debouncedFetch = React.useMemo(
|
||||
() =>
|
||||
debounce((query) => {
|
||||
fetchGroups({ query });
|
||||
}, 250),
|
||||
() => debounce((query) => fetchGroups({ query }), 250),
|
||||
[fetchGroups]
|
||||
);
|
||||
|
||||
@@ -47,14 +44,14 @@ function AddGroupsToCollection(props: Props) {
|
||||
(ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const updatedQuery = ev.target.value;
|
||||
setQuery(updatedQuery);
|
||||
debouncedFetch(updatedQuery);
|
||||
void debouncedFetch(updatedQuery);
|
||||
},
|
||||
[debouncedFetch]
|
||||
);
|
||||
|
||||
const handleAddGroup = (group: Group) => {
|
||||
const handleAddGroup = async (group: Group) => {
|
||||
try {
|
||||
collectionGroupMemberships.create({
|
||||
await collectionGroupMemberships.create({
|
||||
collectionId: collection.id,
|
||||
groupId: group.id,
|
||||
});
|
||||
|
||||
@@ -44,9 +44,9 @@ function AddPeopleToCollection({ collection }: Props) {
|
||||
250
|
||||
);
|
||||
|
||||
const handleAddUser = (user: User) => {
|
||||
const handleAddUser = async (user: User) => {
|
||||
try {
|
||||
memberships.create({
|
||||
await memberships.create({
|
||||
collectionId: collection.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
@@ -99,7 +99,7 @@ function SharedDocumentScene(props: Props) {
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!auth.user) {
|
||||
changeLanguage(detectLanguage(), i18n);
|
||||
void changeLanguage(detectLanguage(), i18n);
|
||||
}
|
||||
}, [auth, i18n]);
|
||||
|
||||
@@ -125,7 +125,7 @@ function SharedDocumentScene(props: Props) {
|
||||
setError(err);
|
||||
}
|
||||
}
|
||||
fetchData();
|
||||
void fetchData();
|
||||
}, [documents, documentSlug, shareId, ui]);
|
||||
|
||||
if (error) {
|
||||
|
||||
@@ -69,14 +69,14 @@ function CommentForm({
|
||||
const { comments } = useStores();
|
||||
const user = useCurrentUser();
|
||||
|
||||
const reset = React.useCallback(() => {
|
||||
const reset = React.useCallback(async () => {
|
||||
const isEmpty = editorRef.current?.isEmpty() ?? true;
|
||||
|
||||
if (isEmpty && thread?.isNew) {
|
||||
if (thread.id) {
|
||||
editor?.removeComment(thread.id);
|
||||
}
|
||||
thread.delete();
|
||||
await thread.delete();
|
||||
}
|
||||
}, [editor, thread]);
|
||||
|
||||
@@ -173,11 +173,11 @@ function CommentForm({
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
const handleCancel = async () => {
|
||||
setData(undefined);
|
||||
setForceRender((s) => ++s);
|
||||
setInputFocused(false);
|
||||
reset();
|
||||
await reset();
|
||||
};
|
||||
|
||||
const handleFocus = () => {
|
||||
|
||||
@@ -114,7 +114,7 @@ function CommentThread({
|
||||
if (!topRef.current) {
|
||||
return;
|
||||
}
|
||||
scrollIntoView(topRef.current, {
|
||||
return scrollIntoView(topRef.current, {
|
||||
scrollMode: "if-needed",
|
||||
behavior: "smooth",
|
||||
block: "end",
|
||||
|
||||
@@ -86,7 +86,7 @@ function DataLoader({ match, children }: Props) {
|
||||
setError(err);
|
||||
}
|
||||
}
|
||||
fetchDocument();
|
||||
void fetchDocument();
|
||||
}, [ui, documents, document, shareId, documentSlug]);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -99,7 +99,7 @@ function DataLoader({ match, children }: Props) {
|
||||
}
|
||||
}
|
||||
}
|
||||
fetchRevision();
|
||||
void fetchRevision();
|
||||
}, [revisions, revisionId]);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -112,7 +112,7 @@ function DataLoader({ match, children }: Props) {
|
||||
}
|
||||
}
|
||||
}
|
||||
fetchRevision();
|
||||
void fetchRevision();
|
||||
}, [document, revisionId, revisions]);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -128,7 +128,7 @@ function DataLoader({ match, children }: Props) {
|
||||
}
|
||||
}
|
||||
}
|
||||
fetchSubscription();
|
||||
void fetchSubscription();
|
||||
}, [document?.id, subscriptions, revisionId]);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -143,7 +143,7 @@ function DataLoader({ match, children }: Props) {
|
||||
}
|
||||
}
|
||||
}
|
||||
fetchViews();
|
||||
void fetchViews();
|
||||
}, [document?.id, document?.isDeleted, revisionId, views]);
|
||||
|
||||
const onCreateLink = React.useCallback(
|
||||
@@ -180,7 +180,7 @@ function DataLoader({ match, children }: Props) {
|
||||
// when viewing a public share link
|
||||
if (can.read) {
|
||||
if (team?.getPreference(TeamPreference.Commenting)) {
|
||||
comments.fetchDocumentComments(document.id, {
|
||||
void comments.fetchDocumentComments(document.id, {
|
||||
limit: 100,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class DocumentScene extends React.Component<Props> {
|
||||
this.props.document.hasEmptyTitle &&
|
||||
this.props.document.isPersistedOnce
|
||||
) {
|
||||
this.props.document.delete();
|
||||
void this.props.document.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,8 @@ class DocumentScene extends React.Component<Props> {
|
||||
|
||||
this.props.document.text = template.text;
|
||||
this.updateIsDirty();
|
||||
this.onSave({
|
||||
|
||||
return this.onSave({
|
||||
autosave: true,
|
||||
publish: false,
|
||||
done: false,
|
||||
@@ -189,7 +190,7 @@ class DocumentScene extends React.Component<Props> {
|
||||
});
|
||||
|
||||
if (response) {
|
||||
this.replaceDocument(response.data);
|
||||
await this.replaceDocument(response.data);
|
||||
toasts.showToast(t("Document restored"));
|
||||
history.replace(this.props.document.url, history.location.state);
|
||||
}
|
||||
@@ -244,7 +245,7 @@ class DocumentScene extends React.Component<Props> {
|
||||
}
|
||||
|
||||
if (document?.collectionId) {
|
||||
this.onSave({
|
||||
void this.onSave({
|
||||
publish: true,
|
||||
done: true,
|
||||
});
|
||||
@@ -324,12 +325,14 @@ class DocumentScene extends React.Component<Props> {
|
||||
}
|
||||
};
|
||||
|
||||
autosave = debounce(() => {
|
||||
this.onSave({
|
||||
done: false,
|
||||
autosave: true,
|
||||
});
|
||||
}, AUTOSAVE_DELAY);
|
||||
autosave = debounce(
|
||||
() =>
|
||||
this.onSave({
|
||||
done: false,
|
||||
autosave: true,
|
||||
}),
|
||||
AUTOSAVE_DELAY
|
||||
);
|
||||
|
||||
updateIsDirty = () => {
|
||||
const { document } = this.props;
|
||||
@@ -370,7 +373,7 @@ class DocumentScene extends React.Component<Props> {
|
||||
this.title = value;
|
||||
this.props.document.title = value;
|
||||
this.updateIsDirty();
|
||||
this.autosave();
|
||||
void this.autosave();
|
||||
});
|
||||
|
||||
goBack = () => {
|
||||
|
||||
@@ -220,7 +220,7 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isLocalSynced && isRemoteSynced) {
|
||||
onSynced?.();
|
||||
void onSynced?.();
|
||||
}
|
||||
}, [onSynced, isLocalSynced, isRemoteSynced]);
|
||||
|
||||
@@ -236,14 +236,14 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
|
||||
!isVisible &&
|
||||
remoteProvider.status === WebSocketStatus.Connected
|
||||
) {
|
||||
remoteProvider.disconnect();
|
||||
void remoteProvider.disconnect();
|
||||
}
|
||||
|
||||
if (
|
||||
(!isIdle || isVisible) &&
|
||||
remoteProvider.status === WebSocketStatus.Disconnected
|
||||
) {
|
||||
remoteProvider.connect();
|
||||
void remoteProvider.connect();
|
||||
}
|
||||
}, [remoteProvider, isIdle, isVisible]);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ function References({ document }: Props) {
|
||||
const location = useLocation();
|
||||
|
||||
React.useEffect(() => {
|
||||
documents.fetchBacklinks(document.id);
|
||||
void documents.fetchBacklinks(document.id);
|
||||
}, [documents, document.id]);
|
||||
|
||||
const backlinks = documents.getBacklinkedDocuments(document.id);
|
||||
|
||||
@@ -76,7 +76,7 @@ function SharePopover({
|
||||
|
||||
React.useEffect(() => {
|
||||
if (visible && team.sharing) {
|
||||
document.share();
|
||||
void document.share();
|
||||
buttonRef.current?.focus();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ function DocumentNew() {
|
||||
}
|
||||
}
|
||||
|
||||
createDocument();
|
||||
void createDocument();
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@@ -33,10 +33,7 @@ function AddPeopleToGroup(props: Props) {
|
||||
|
||||
const { fetchPage: fetchUsers } = users;
|
||||
const debouncedFetch = React.useMemo(
|
||||
() =>
|
||||
debounce((query) => {
|
||||
fetchUsers({ query });
|
||||
}, 250),
|
||||
() => debounce((query) => fetchUsers({ query }), 250),
|
||||
[fetchUsers]
|
||||
);
|
||||
|
||||
@@ -44,7 +41,7 @@ function AddPeopleToGroup(props: Props) {
|
||||
(ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const updatedQuery = ev.target.value;
|
||||
setQuery(updatedQuery);
|
||||
debouncedFetch(updatedQuery);
|
||||
void debouncedFetch(updatedQuery);
|
||||
},
|
||||
[debouncedFetch]
|
||||
);
|
||||
|
||||
@@ -29,7 +29,7 @@ function Home() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
React.useEffect(() => {
|
||||
pins.fetchPage();
|
||||
void pins.fetchPage();
|
||||
}, [pins]);
|
||||
|
||||
const canManageTeam = usePolicy(team).manage;
|
||||
|
||||
@@ -101,7 +101,7 @@ function Login({ children }: Props) {
|
||||
// Try to detect the user's language and show the login page on its idiom
|
||||
// if translation is available
|
||||
React.useEffect(() => {
|
||||
changeLanguage(detectLanguage(), i18n);
|
||||
void changeLanguage(detectLanguage(), i18n);
|
||||
}, [i18n]);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import useStores from "~/hooks/useStores";
|
||||
|
||||
const Logout = () => {
|
||||
const { auth } = useStores();
|
||||
auth.logout();
|
||||
void auth.logout();
|
||||
return <Redirect to="/" />;
|
||||
};
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ class Search extends React.Component<Props> {
|
||||
handleKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (ev.key === "Enter") {
|
||||
this.updateLocation(ev.currentTarget.value);
|
||||
this.fetchResults();
|
||||
void this.fetchResults();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ class Search extends React.Component<Props> {
|
||||
this.allowLoadMore = true;
|
||||
// To prevent "no results" showing before debounce kicks in
|
||||
this.isLoading = true;
|
||||
this.fetchResults();
|
||||
void this.fetchResults();
|
||||
};
|
||||
|
||||
handleTermChange = () => {
|
||||
@@ -153,7 +153,7 @@ class Search extends React.Component<Props> {
|
||||
this.allowLoadMore = true;
|
||||
// To prevent "no results" showing before debounce kicks in
|
||||
this.isLoading = true;
|
||||
this.fetchResults();
|
||||
void this.fetchResults();
|
||||
};
|
||||
|
||||
handleFilterChange = (search: {
|
||||
|
||||
@@ -18,7 +18,7 @@ function RecentSearches() {
|
||||
const [isPreloaded] = React.useState(searches.recent.length > 0);
|
||||
|
||||
React.useEffect(() => {
|
||||
searches.fetchPage({});
|
||||
void searches.fetchPage({});
|
||||
}, [searches]);
|
||||
|
||||
const content = searches.recent.length ? (
|
||||
@@ -32,9 +32,9 @@ function RecentSearches() {
|
||||
<Tooltip tooltip={t("Remove search")} delay={150}>
|
||||
<RemoveButton
|
||||
aria-label={t("Remove search")}
|
||||
onClick={(ev) => {
|
||||
onClick={async (ev) => {
|
||||
ev.preventDefault();
|
||||
searchQuery.delete();
|
||||
await searchQuery.delete();
|
||||
}}
|
||||
>
|
||||
<CloseIcon />
|
||||
|
||||
@@ -18,7 +18,7 @@ function UserFilter(props: Props) {
|
||||
const { users } = useStores();
|
||||
|
||||
React.useEffect(() => {
|
||||
users.fetchPage({
|
||||
void users.fetchPage({
|
||||
limit: 100,
|
||||
});
|
||||
}, [users]);
|
||||
|
||||
@@ -42,7 +42,7 @@ function GoogleAnalytics() {
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
integrations.fetchPage({
|
||||
void integrations.fetchPage({
|
||||
type: IntegrationType.Analytics,
|
||||
});
|
||||
}, [integrations]);
|
||||
|
||||
@@ -68,7 +68,7 @@ function Members() {
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
void fetchData();
|
||||
}, [query, sort, filter, page, direction, users, users.counts.all]);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
@@ -46,7 +46,7 @@ function Security() {
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!providers && !loading) {
|
||||
request();
|
||||
void request();
|
||||
}
|
||||
}, [loading, providers, request]);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ function SelfHosted() {
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
integrations.fetchPage({
|
||||
void integrations.fetchPage({
|
||||
type: IntegrationType.Embed,
|
||||
});
|
||||
}, [integrations]);
|
||||
|
||||
@@ -53,7 +53,7 @@ function Shares() {
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
void fetchData();
|
||||
}, [query, sort, page, direction, shares]);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
@@ -71,7 +71,7 @@ class ImageUpload extends React.Component<RootStore & Props> {
|
||||
name: this.file.name,
|
||||
preset: AttachmentPreset.Avatar,
|
||||
});
|
||||
this.props.onSuccess(attachment.url);
|
||||
void this.props.onSuccess(attachment.url);
|
||||
} catch (err) {
|
||||
this.props.onError(err.message);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user