[Dev] Teact: Fix useState typing
This commit is contained in:
parent
e7026aa16c
commit
5f6040b82c
@ -64,7 +64,7 @@ const SettingsPrivacyVisibilityExceptionList: FC<OwnProps & StateProps> = ({
|
|||||||
// No need for expensive global updates on chats, so we avoid them
|
// No need for expensive global updates on chats, so we avoid them
|
||||||
const chatsById = getGlobal().chats.byId;
|
const chatsById = getGlobal().chats.byId;
|
||||||
|
|
||||||
const chatIds = unique([...folderAllOrderedIds, ...folderArchivedOrderedIds])
|
const chatIds = unique([...folderAllOrderedIds || [], ...folderArchivedOrderedIds || []])
|
||||||
.filter((chatId) => {
|
.filter((chatId) => {
|
||||||
const chat = chatsById[chatId];
|
const chat = chatsById[chatId];
|
||||||
return chat && ((isUserId(chat.id) && chat.id !== currentUserId) || isChatGroup(chat));
|
return chat && ((isUserId(chat.id) && chat.id !== currentUserId) || isChatGroup(chat));
|
||||||
|
|||||||
@ -52,7 +52,7 @@ const SettingsFoldersChatFilters: FC<OwnProps> = ({
|
|||||||
// No need for expensive global updates on chats, so we avoid them
|
// No need for expensive global updates on chats, so we avoid them
|
||||||
const chatsById = getGlobal().chats.byId;
|
const chatsById = getGlobal().chats.byId;
|
||||||
|
|
||||||
const chatIds = [...folderAllOrderedIds, ...folderArchivedOrderedIds];
|
const chatIds = [...folderAllOrderedIds || [], ...folderArchivedOrderedIds || []];
|
||||||
return unique([
|
return unique([
|
||||||
...selectedChatIds,
|
...selectedChatIds,
|
||||||
...filterChatsByName(lang, chatIds, chatsById, chatFilter),
|
...filterChatsByName(lang, chatIds, chatsById, chatFilter),
|
||||||
|
|||||||
@ -87,7 +87,7 @@ const ManageGroup: FC<OwnProps & StateProps> = ({
|
|||||||
const currentAbout = chat.fullInfo ? (chat.fullInfo.about || '') : '';
|
const currentAbout = chat.fullInfo ? (chat.fullInfo.about || '') : '';
|
||||||
|
|
||||||
const [isProfileFieldsTouched, setIsProfileFieldsTouched] = useState(false);
|
const [isProfileFieldsTouched, setIsProfileFieldsTouched] = useState(false);
|
||||||
const [title, setTitle] = useState(currentTitle);
|
const [title, setTitle] = useState(currentTitle || '');
|
||||||
const [about, setAbout] = useState(currentAbout);
|
const [about, setAbout] = useState(currentAbout);
|
||||||
const [photo, setPhoto] = useState<File | undefined>();
|
const [photo, setPhoto] = useState<File | undefined>();
|
||||||
const [error, setError] = useState<string | undefined>();
|
const [error, setError] = useState<string | undefined>();
|
||||||
|
|||||||
@ -57,7 +57,7 @@ const ManageGroupAdminRights: FC<OwnProps & StateProps> = ({
|
|||||||
const { updateChatAdmin } = getDispatch();
|
const { updateChatAdmin } = getDispatch();
|
||||||
|
|
||||||
const [permissions, setPermissions] = useState<ApiChatAdminRights>({});
|
const [permissions, setPermissions] = useState<ApiChatAdminRights>({});
|
||||||
const [isTouched, setIsTouched] = useState(isNewAdmin);
|
const [isTouched, setIsTouched] = useState(Boolean(isNewAdmin));
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isDismissConfirmationDialogOpen, openDismissConfirmationDialog, closeDismissConfirmationDialog] = useFlag();
|
const [isDismissConfirmationDialogOpen, openDismissConfirmationDialog, closeDismissConfirmationDialog] = useFlag();
|
||||||
const [customTitle, setCustomTitle] = useState('');
|
const [customTitle, setCustomTitle] = useState('');
|
||||||
|
|||||||
@ -38,7 +38,7 @@ const ManageReactions: FC<OwnProps & StateProps> = ({
|
|||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
const [isTouched, setIsTouched] = useState(false);
|
const [isTouched, setIsTouched] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [localEnabledReactions, setLocalEnabledReactions] = useState(enabledReactions);
|
const [localEnabledReactions, setLocalEnabledReactions] = useState(enabledReactions || []);
|
||||||
|
|
||||||
useHistoryBack(isActive, onClose);
|
useHistoryBack(isActive, onClose);
|
||||||
|
|
||||||
@ -53,9 +53,11 @@ const ManageReactions: FC<OwnProps & StateProps> = ({
|
|||||||
}, [chat, localEnabledReactions, setChatEnabledReactions]);
|
}, [chat, localEnabledReactions, setChatEnabledReactions]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(false);
|
if (enabledReactions) {
|
||||||
setIsTouched(false);
|
setIsLoading(false);
|
||||||
setLocalEnabledReactions(enabledReactions || []);
|
setIsTouched(false);
|
||||||
|
setLocalEnabledReactions(enabledReactions);
|
||||||
|
}
|
||||||
}, [enabledReactions]);
|
}, [enabledReactions]);
|
||||||
|
|
||||||
const handleReactionChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleReactionChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|||||||
@ -463,6 +463,8 @@ export function setTarget($element: VirtualElement, target: Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useState<T>(): [T, StateHookSetter<T>];
|
||||||
|
export function useState<T>(initial: T): [T, StateHookSetter<T>];
|
||||||
export function useState<T>(initial?: T): [T, StateHookSetter<T>] {
|
export function useState<T>(initial?: T): [T, StateHookSetter<T>] {
|
||||||
const { cursor, byCursor } = renderingInstance.hooks.state;
|
const { cursor, byCursor } = renderingInstance.hooks.state;
|
||||||
|
|
||||||
|
|||||||
@ -79,12 +79,12 @@ const prepared: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const results: {
|
const results: {
|
||||||
orderedIdsByFolderId: Record<string, string[]>;
|
orderedIdsByFolderId: Record<string, string[] | undefined>;
|
||||||
chatsCountByFolderId: Record<string, number>;
|
chatsCountByFolderId: Record<string, number | undefined>;
|
||||||
unreadCountersByFolderId: Record<string, {
|
unreadCountersByFolderId: Record<string, {
|
||||||
chatsCount: number;
|
chatsCount: number;
|
||||||
notificationsCount: number;
|
notificationsCount: number;
|
||||||
}>;
|
} | undefined>;
|
||||||
} = {
|
} = {
|
||||||
orderedIdsByFolderId: {},
|
orderedIdsByFolderId: {},
|
||||||
chatsCountByFolderId: {},
|
chatsCountByFolderId: {},
|
||||||
@ -596,7 +596,7 @@ function buildFolderUnreadCounters(folderId: number) {
|
|||||||
orderedIdsByFolderId: { [folderId]: orderedIds },
|
orderedIdsByFolderId: { [folderId]: orderedIds },
|
||||||
} = results;
|
} = results;
|
||||||
|
|
||||||
return orderedIds.reduce((newUnreadCounters, chatId) => {
|
return orderedIds!.reduce((newUnreadCounters, chatId) => {
|
||||||
const chatSummary = chatSummariesById.get(chatId);
|
const chatSummary = chatSummariesById.get(chatId);
|
||||||
if (!chatSummary) {
|
if (!chatSummary) {
|
||||||
return newUnreadCounters;
|
return newUnreadCounters;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user