auth modals fix logic (#420)

auth modals fix logic
This commit is contained in:
Ilya Y 2024-02-27 17:42:54 +03:00 committed by GitHub
parent 8b066104e6
commit b1b3f8b435
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 20 deletions

View File

@ -94,10 +94,6 @@ export const App = (props: Props) => {
const is404 = createMemo(() => props.is404)
createEffect(() => {
if (!searchParams().m) {
hideModal()
}
const modal = MODALS[searchParams().m]
if (modal) {
showModal(modal)

View File

@ -19,13 +19,6 @@ type Props = {
const PAGE_SIZE = 20
// TODO: проверить нет ли дубликатов в базе данных, если нет - то не использовать addUniqueAuthors()
const addUniqueAuthors = (prevAuthors: Author[], newAuthors: Author[]) => {
const uniqueNewAuthors = newAuthors.filter(
(newAuthor) => !prevAuthors.some((prevAuthor) => prevAuthor.id === newAuthor.id),
)
return [...prevAuthors, ...uniqueNewAuthors]
}
export const AuthorsList = (props: Props) => {
const { t } = useLocalize()
const { isOwnerSubscribed } = useFollowing()
@ -44,9 +37,9 @@ export const AuthorsList = (props: Props) => {
})
if (queryType === 'shouts') {
setAuthorsByShouts((prev) => addUniqueAuthors(prev, result))
setAuthorsByShouts((prev) => [...prev, ...result])
} else {
setAuthorsByFollowers((prev) => addUniqueAuthors(prev, result))
setAuthorsByFollowers((prev) => [...prev, ...result])
}
setLoading(false)
}

View File

@ -53,7 +53,6 @@ export const RegisterForm = () => {
const handleSubmit = async (event: Event) => {
event.preventDefault()
if (passwordError()) {
setValidationErrors((errors) => ({ ...errors, password: passwordError() }))
} else {
@ -102,7 +101,7 @@ export const RegisterForm = () => {
redirect_uri: window.location.origin,
}
const { errors } = await signUp(opts)
if (errors) return
if (errors.length > 0) return
setIsSuccess(true)
} catch (error) {
console.error(error)
@ -134,7 +133,6 @@ export const RegisterForm = () => {
),
}))
break
case 'verified':
setValidationErrors((prev) => ({
email: (

View File

@ -96,7 +96,6 @@ export const SendResetLinkForm = () => {
placeholder={t('Email')}
onInput={(event) => handleEmailInput(event.currentTarget.value)}
/>
<label for="email">{t('Email')}</label>
<Show when={isUserNotFound()}>
<div class={styles.validationError}>

View File

@ -122,7 +122,13 @@ export const SessionProvider = (props: {
m: 'auth',
access_token,
})
else if (token) changeSearchParams({ mode: 'change-password', modal: 'auth', token })
else if (token) {
changeSearchParams({
mode: 'change-password',
m: 'auth',
token,
})
}
})
// load
@ -207,7 +213,6 @@ export const SessionProvider = (props: {
if (session()) {
const token = session()?.access_token
if (token) {
// console.log('[context.session] token observer got token', token)
if (!inboxClient.private) {
apiClient.connect(token)
notifierClient.connect(token)
@ -333,7 +338,6 @@ export const SessionProvider = (props: {
const response = await authorizer().graphqlQuery({
query: `query { is_registered(email: "${email}") { message }}`,
})
// console.log(response)
return response?.data?.is_registered?.message
} catch (error) {
console.warn(error)

View File

@ -25,6 +25,7 @@ export type PageProps = {
export type RootSearchParams = {
m: string // modal
lang: string
token: string
}
export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature'