mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Refine format text
This commit is contained in:
@ -32,7 +32,6 @@ const fireMutation = async ({
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'reports':
|
case 'reports':
|
||||||
console.log('reporting')
|
|
||||||
res = await client({
|
res = await client({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
instance: 'local',
|
instance: 'local',
|
||||||
|
@ -42,7 +42,9 @@ const ComposeRoot: React.FC<Props> = ({ postState, postDispatch }) => {
|
|||||||
{ enabled: false }
|
{ enabled: false }
|
||||||
)
|
)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refetch()
|
if (postState.tag?.text) {
|
||||||
|
refetch()
|
||||||
|
}
|
||||||
}, [postState.tag?.text])
|
}, [postState.tag?.text])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -12,17 +12,21 @@ export interface Params {
|
|||||||
disableDebounce?: boolean
|
disableDebounce?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const debouncedSuggestions = debounce((postDispatch, tag) => {
|
const debouncedSuggestions = debounce(
|
||||||
console.log('debounced!!!')
|
(postDispatch, tag) => {
|
||||||
postDispatch({ type: 'tag', payload: tag })
|
postDispatch({ type: 'tag', payload: tag })
|
||||||
}, 500)
|
},
|
||||||
|
500,
|
||||||
|
{
|
||||||
|
trailing: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
let prevTags: PostState['tag'][] = []
|
let prevTags: PostState['tag'][] = []
|
||||||
|
|
||||||
const formatText = ({
|
const formatText = ({
|
||||||
postDispatch,
|
postDispatch,
|
||||||
content,
|
content,
|
||||||
refetch,
|
|
||||||
disableDebounce = false
|
disableDebounce = false
|
||||||
}: Params) => {
|
}: Params) => {
|
||||||
const tags: PostState['tag'][] = []
|
const tags: PostState['tag'][] = []
|
||||||
@ -54,24 +58,14 @@ const formatText = ({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const changedTag = differenceWith(prevTags, tags, isEqual)
|
const changedTag = differenceWith(tags, prevTags, isEqual)
|
||||||
// quick delete causes flicking of suggestion box
|
// quick delete causes flicking of suggestion box
|
||||||
if (
|
if (changedTag.length && !disableDebounce) {
|
||||||
changedTag.length > 0 &&
|
|
||||||
tags.length > 0 &&
|
|
||||||
content.length > 0 &&
|
|
||||||
!disableDebounce
|
|
||||||
) {
|
|
||||||
// console.log('changedTag length')
|
|
||||||
// console.log(changedTag.length)
|
|
||||||
// console.log('tags length')
|
|
||||||
// console.log(tags.length)
|
|
||||||
// console.log('changed Tag')
|
|
||||||
// console.log(changedTag)
|
|
||||||
if (changedTag[0]!.type !== 'url') {
|
if (changedTag[0]!.type !== 'url') {
|
||||||
debouncedSuggestions(postDispatch, changedTag[0])
|
debouncedSuggestions(postDispatch, changedTag[0])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
debouncedSuggestions.cancel()
|
||||||
postDispatch({ type: 'tag', payload: undefined })
|
postDispatch({ type: 'tag', payload: undefined })
|
||||||
}
|
}
|
||||||
prevTags = tags
|
prevTags = tags
|
||||||
|
@ -19,9 +19,5 @@ export const searchFetch = async (
|
|||||||
endpoint: 'search',
|
endpoint: 'search',
|
||||||
query: { type, q: term, limit }
|
query: { type, q: term, limit }
|
||||||
})
|
})
|
||||||
console.log('search query')
|
|
||||||
console.log({ type, q: term, limit })
|
|
||||||
console.log('search result')
|
|
||||||
console.log(res.body)
|
|
||||||
return Promise.resolve(res.body)
|
return Promise.resolve(res.body)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ const Base = 4
|
|||||||
export const StyleConstants = {
|
export const StyleConstants = {
|
||||||
Font: {
|
Font: {
|
||||||
Size: {
|
Size: {
|
||||||
S: 12,
|
S: 14,
|
||||||
M: 16,
|
M: 16,
|
||||||
L: 18
|
L: 18
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user