chore: enable noUncheckedIndexedAccess, better type check (#2608)
This commit is contained in:
@@ -20,7 +20,7 @@ class AccessNotFoundError extends Error {
|
||||
this.name = "AccessNotFoundError"
|
||||
}
|
||||
|
||||
toString() {
|
||||
override toString() {
|
||||
return `${this.name}: ${this.message} at ${this.path}`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ export const ShadowDOM: FC<
|
||||
const [uiFont, usePointerCursor] = useUISettingKeys(["uiFontFamily", "usePointerCursor"])
|
||||
|
||||
return (
|
||||
// @ts-expect-error
|
||||
<root.div {...rest}>
|
||||
<ShadowDOMContext.Provider value={true}>
|
||||
<div
|
||||
@@ -150,7 +151,7 @@ function getLinkedStaticStyleSheets() {
|
||||
}
|
||||
|
||||
cssArray.push({
|
||||
cssText: cacheCssTextMap[sheet.href],
|
||||
cssText: cacheCssTextMap[sheet.href]!,
|
||||
ref: $link,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export function FeedPreview(props: {
|
||||
<div
|
||||
className={cn(
|
||||
"mx-auto mt-12 flex w-full flex-col items-center p-4 lg:p-0",
|
||||
views[view].gridMode ? "max-w-full" : "max-w-prose",
|
||||
views[view]!.gridMode ? "max-w-full" : "max-w-prose",
|
||||
)}
|
||||
>
|
||||
<FeedIcon
|
||||
@@ -73,7 +73,7 @@ export function FeedPreview(props: {
|
||||
<div
|
||||
className={cn(
|
||||
"w-full pb-12 pt-8",
|
||||
views[view].gridMode
|
||||
views[view]!.gridMode
|
||||
? "grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4"
|
||||
: "flex max-w-3xl flex-col gap-6",
|
||||
)}
|
||||
|
||||
@@ -84,8 +84,8 @@ export const useScrollTracking = (
|
||||
// calculate the range of data-container-top between each two headings
|
||||
const titleBetweenPositionTopRangeMap = [] as [number, number][]
|
||||
for (let i = 0; i < toc.length - 1; i++) {
|
||||
const { $heading } = toc[i]
|
||||
const $nextHeading = toc[i + 1].$heading
|
||||
const { $heading } = toc[i]!
|
||||
const $nextHeading = toc[i + 1]!.$heading
|
||||
|
||||
const headingTop =
|
||||
Number.parseInt($heading.dataset["containerTop"] || "0") || getElementTop($heading)
|
||||
|
||||
@@ -391,9 +391,9 @@ const PlayProgressBar = () => {
|
||||
setCurrentDragging(true)
|
||||
}}
|
||||
onValueChange={(value) => {
|
||||
setDragTime(value[0])
|
||||
setDragTime(value[0]!)
|
||||
startTransition(() => {
|
||||
controls.seek(value[0])
|
||||
controls.seek(value[0]!)
|
||||
})
|
||||
}}
|
||||
onValueCommit={() => {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const VolumeSlider: FC<{
|
||||
orientation="vertical"
|
||||
value={[volume ?? 0.8]}
|
||||
onValueChange={(values) => {
|
||||
onVolumeChange?.(values[0])
|
||||
onVolumeChange?.(values[0]!)
|
||||
}}
|
||||
>
|
||||
<Slider.Track className="relative w-1 grow rounded bg-zinc-500">
|
||||
|
||||
@@ -13,7 +13,7 @@ export const usePreviewMedia = (children?: React.ReactNode) => {
|
||||
return useCallback(
|
||||
(media: PreviewMediaProps[], initialIndex = 0) => {
|
||||
if (isMobile()) {
|
||||
window.open(replaceImgUrlIfNeed(media[initialIndex].url))
|
||||
window.open(replaceImgUrlIfNeed(media[initialIndex]!.url))
|
||||
return
|
||||
}
|
||||
present({
|
||||
|
||||
@@ -209,8 +209,8 @@ export const PreviewMediaContent: FC<{
|
||||
|
||||
if (media.length === 0) return null
|
||||
if (media.length === 1) {
|
||||
const src = media[0].url
|
||||
const { type } = media[0]
|
||||
const src = media[0]!.url
|
||||
const { type } = media[0]!
|
||||
const isVideo = type === "video"
|
||||
return (
|
||||
<Wrapper src={src} showActions={!isVideo} sideContent={children}>
|
||||
@@ -225,23 +225,23 @@ export const PreviewMediaContent: FC<{
|
||||
/>
|
||||
) : (
|
||||
<FallbackableImage
|
||||
fallbackUrl={media[0].fallbackUrl}
|
||||
fallbackUrl={media[0]!.fallbackUrl}
|
||||
containerClassName="w-auto"
|
||||
className="h-full w-auto object-contain"
|
||||
alt="cover"
|
||||
src={src}
|
||||
height={media[0].height}
|
||||
width={media[0].width}
|
||||
blurhash={media[0].blurhash}
|
||||
height={media[0]!.height}
|
||||
width={media[0]!.width}
|
||||
blurhash={media[0]!.blurhash}
|
||||
haveSideContent={!!children}
|
||||
/>
|
||||
)}
|
||||
</Wrapper>
|
||||
)
|
||||
}
|
||||
const isVideo = currentMedia.type === "video"
|
||||
const isVideo = currentMedia!.type === "video"
|
||||
return (
|
||||
<Wrapper src={currentMedia.url} showActions={!isVideo} sideContent={children}>
|
||||
<Wrapper src={currentMedia!.url} showActions={!isVideo} sideContent={children}>
|
||||
<div className="size-full overflow-hidden" ref={emblaRef}>
|
||||
<div className="flex size-full">
|
||||
{media.map((med) => (
|
||||
|
||||
@@ -43,7 +43,7 @@ export function PullToRefresh({
|
||||
) as HTMLElement
|
||||
if (!scrollContainer) return
|
||||
|
||||
const touchY = e.touches[0].clientY
|
||||
const touchY = e.touches[0]!.clientY
|
||||
setStartY(touchY)
|
||||
|
||||
if (scrollContainer.scrollTop <= 0) {
|
||||
@@ -56,7 +56,7 @@ export function PullToRefresh({
|
||||
const touchMoveHandler = (e: TouchEvent) => {
|
||||
if (!shouldAllowPull || isRefreshing) return
|
||||
|
||||
const y = e.touches[0].clientY
|
||||
const y = e.touches[0]!.clientY
|
||||
const delta = y - startY
|
||||
|
||||
if (delta > 0) {
|
||||
|
||||
@@ -125,7 +125,7 @@ function transformShortcuts<T extends Shortcuts>(configs: T) {
|
||||
for (const category in configs) {
|
||||
for (const shortcutKey in configs[category]) {
|
||||
const config = configs[category][shortcutKey]
|
||||
result[category][shortcutKey].key = transformShortcut(config.key)
|
||||
result[category]![shortcutKey]!.key = transformShortcut(config!.key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,17 @@ describe("upgradeToV8", () => {
|
||||
|
||||
const feeds = await browserDB.feeds.toArray()
|
||||
expect(feeds.length).toEqual(3)
|
||||
expect(feeds[0].tipUsers).toEqual(insertFeeds[0].tipUsers)
|
||||
expect(feeds[1].tipUsers).toEqual(insertFeeds[1].tipUsers)
|
||||
expect(feeds[2].tipUsers).toEqual(insertFeeds[2].tipUsers)
|
||||
expect(feeds[0]!.tipUsers).toEqual(insertFeeds[0]!.tipUsers)
|
||||
expect(feeds[1]!.tipUsers).toEqual(insertFeeds[1]!.tipUsers)
|
||||
expect(feeds[2]!.tipUsers).toEqual(insertFeeds[2]!.tipUsers)
|
||||
|
||||
await browserDB.transaction("rw", [browserDB.feeds], async (tx) => {
|
||||
await browserDB.upgradeToV8(tx)
|
||||
})
|
||||
const feedsAfterMigrate = await browserDB.feeds.toArray()
|
||||
expect(feedsAfterMigrate.length).toEqual(3)
|
||||
expect(feedsAfterMigrate[0].tipUsers).toEqual([])
|
||||
expect(feedsAfterMigrate[1].tipUsers).toEqual(null)
|
||||
expect(feedsAfterMigrate[2].tipUsers).toEqual([{ name: "user1" }])
|
||||
expect(feedsAfterMigrate[0]!.tipUsers).toEqual([])
|
||||
expect(feedsAfterMigrate[1]!.tipUsers).toEqual(null)
|
||||
expect(feedsAfterMigrate[2]!.tipUsers).toEqual([{ name: "user1" }])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -79,7 +79,7 @@ export const useFeedActions = ({
|
||||
|
||||
const inbox = useInboxById(feedId)
|
||||
const isInbox = !!inbox
|
||||
const subscription = useSubscriptionByFeedId(feedId)
|
||||
const subscription = useSubscriptionByFeedId(feedId)!
|
||||
|
||||
const subscriptions = useSubscriptionsByFeedIds(
|
||||
useMemo(() => feedIds || [feedId], [feedId, feedIds]),
|
||||
@@ -215,7 +215,7 @@ export const useFeedActions = ({
|
||||
submenu: [
|
||||
...Array.from(categories.values()).map((category) => {
|
||||
const isIncluded = isMultipleSelection
|
||||
? subscriptions.every((s) => s.category === category)
|
||||
? subscriptions.every((s) => s!.category === category)
|
||||
: subscription?.category === category
|
||||
return {
|
||||
label: category,
|
||||
@@ -397,7 +397,7 @@ export const useFeedActions = ({
|
||||
export const useListActions = ({ listId, view }: { listId: string; view: FeedViewType }) => {
|
||||
const { t } = useTranslation()
|
||||
const list = useListById(listId)
|
||||
const subscription = useSubscriptionByFeedId(listId)
|
||||
const subscription = useSubscriptionByFeedId(listId)!
|
||||
|
||||
const { present } = useModalStack()
|
||||
const { mutateAsync: deleteSubscription } = useDeleteSubscription({})
|
||||
|
||||
@@ -53,7 +53,7 @@ export function immersiveTranslate({
|
||||
return
|
||||
}
|
||||
|
||||
if (html.childNodes.length === 1 && html.childNodes[0].nodeType === Node.TEXT_NODE) {
|
||||
if (html.childNodes.length === 1 && html.childNodes[0]?.nodeType === Node.TEXT_NODE) {
|
||||
const textNode = html.childNodes[0] as Text
|
||||
if (!textNode.textContent) {
|
||||
return
|
||||
|
||||
@@ -42,7 +42,7 @@ const getMenuItemByPath = (items: ElectronMenuItem[], path: number[]): ElectronM
|
||||
|
||||
for (const index of path) {
|
||||
if (!currentItems || index >= currentItems.length) return null
|
||||
currentItem = currentItems[index]
|
||||
currentItem = currentItems[index]!
|
||||
|
||||
if (currentItem.submenu && Array.isArray(currentItem.submenu)) {
|
||||
currentItems = currentItem.submenu
|
||||
|
||||
@@ -74,7 +74,7 @@ export async function translate({
|
||||
if (!language) {
|
||||
return null
|
||||
}
|
||||
let fields = language && view !== undefined ? views[view!].translation.split(",") : []
|
||||
let fields = language && view !== undefined ? views[view!]!.translation.split(",") : []
|
||||
if (extraFields) {
|
||||
fields = [...fields, ...extraFields]
|
||||
}
|
||||
|
||||
@@ -84,20 +84,20 @@ export const getLevelMultiplier = (level: number) => {
|
||||
if (!serverConfigs) {
|
||||
return 1
|
||||
}
|
||||
const level1Range = serverConfigs?.LEVEL_PERCENTAGES[3] - serverConfigs?.LEVEL_PERCENTAGES[2]
|
||||
const level1Range = serverConfigs?.LEVEL_PERCENTAGES[3]! - serverConfigs?.LEVEL_PERCENTAGES[2]!
|
||||
const percentageIndex = serverConfigs.LEVEL_PERCENTAGES.length - level
|
||||
let levelCurrentRange
|
||||
if (percentageIndex - 1 < 0) {
|
||||
levelCurrentRange = serverConfigs?.LEVEL_PERCENTAGES[percentageIndex]
|
||||
} else {
|
||||
levelCurrentRange =
|
||||
serverConfigs?.LEVEL_PERCENTAGES[percentageIndex] -
|
||||
serverConfigs?.LEVEL_PERCENTAGES[percentageIndex - 1]
|
||||
serverConfigs?.LEVEL_PERCENTAGES[percentageIndex]! -
|
||||
serverConfigs?.LEVEL_PERCENTAGES[percentageIndex - 1]!
|
||||
}
|
||||
const rangeMultiplier = levelCurrentRange / level1Range
|
||||
|
||||
const poolMultiplier =
|
||||
serverConfigs?.DAILY_POWER_PERCENTAGES[level] / serverConfigs?.DAILY_POWER_PERCENTAGES[1]
|
||||
serverConfigs?.DAILY_POWER_PERCENTAGES[level]! / serverConfigs?.DAILY_POWER_PERCENTAGES[1]!
|
||||
|
||||
return (poolMultiplier / rangeMultiplier).toFixed(0)
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ export const FeedFilter = ({ index }: { index: number }) => {
|
||||
if (!data.condition[orConditionIdx]) {
|
||||
data.condition[orConditionIdx] = [{}]
|
||||
}
|
||||
data.condition[orConditionIdx][conditionIdx][key] = value
|
||||
data.condition[orConditionIdx][conditionIdx]![key] = value
|
||||
})
|
||||
}
|
||||
const type =
|
||||
@@ -174,15 +174,15 @@ export const FeedFilter = ({ index }: { index: number }) => {
|
||||
disabled={disabled}
|
||||
onAnd={() => {
|
||||
onChange((data) => {
|
||||
data.condition[orConditionIdx].push({})
|
||||
data.condition[orConditionIdx]!.push({})
|
||||
})
|
||||
}}
|
||||
onDelete={() => {
|
||||
onChange((data) => {
|
||||
if (data.condition[orConditionIdx].length === 1) {
|
||||
if (data.condition[orConditionIdx]!.length === 1) {
|
||||
data.condition.splice(orConditionIdx, 1)
|
||||
} else {
|
||||
data.condition[orConditionIdx].splice(conditionIdx, 1)
|
||||
data.condition[orConditionIdx]!.splice(conditionIdx, 1)
|
||||
}
|
||||
})
|
||||
}}
|
||||
|
||||
@@ -207,7 +207,7 @@ export const TargetActionList = ({ index }: { index: number }) => {
|
||||
{rewriteRules?.map((rule, rewriteIdx) => {
|
||||
const change = (key: string, value: string) => {
|
||||
onChange((data) => {
|
||||
data.result.rewriteRules![rewriteIdx][key] = value
|
||||
data.result.rewriteRules![rewriteIdx]![key] = value
|
||||
})
|
||||
}
|
||||
return (
|
||||
|
||||
@@ -23,7 +23,7 @@ export function CenterColumnDesktop() {
|
||||
const settingWideMode = useRealInWideMode()
|
||||
const entryColWidth = useMemo(() => getUISettings().entryColWidth, [])
|
||||
const { view } = useRouteParams()
|
||||
const inWideMode = (view ? views[view].wideMode : false) || settingWideMode
|
||||
const inWideMode = (view ? views[view]!.wideMode : false) || settingWideMode
|
||||
const feedColumnWidth = useUISettingKey("feedColWidth")
|
||||
const { position, separatorProps, isDragging, separatorCursor } = useResizable({
|
||||
axis: "x",
|
||||
|
||||
@@ -26,7 +26,7 @@ export const RightContentDesktop = () => {
|
||||
|
||||
const settingWideMode = useRealInWideMode()
|
||||
const realEntryId = entryId === ROUTE_ENTRY_PENDING ? "" : entryId
|
||||
const showEntryContent = !(views[view].wideMode || (settingWideMode && !realEntryId))
|
||||
const showEntryContent = !(views[view]!.wideMode || (settingWideMode && !realEntryId))
|
||||
const wideMode = !!(settingWideMode && realEntryId)
|
||||
const feedColumnTempShow = useFeedColumnTempShow()
|
||||
const feedColumnShow = useFeedColumnShow()
|
||||
|
||||
@@ -109,13 +109,13 @@ const PlaybackRateButton = () => {
|
||||
const handleClick = () => {
|
||||
const nextIndex = (currentIndex + 1) % rates.length
|
||||
setCurrentIndex(nextIndex)
|
||||
AudioPlayer.setPlaybackRate(rates[nextIndex])
|
||||
AudioPlayer.setPlaybackRate(rates[nextIndex]!)
|
||||
}
|
||||
|
||||
return (
|
||||
<button onClick={handleClick}>
|
||||
<span className="block font-mono text-xs text-muted-foreground">
|
||||
{rates[currentIndex].toFixed(2)}x
|
||||
{rates[currentIndex]!.toFixed(2)}x
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -123,7 +123,7 @@ const ViewTabs = ({ onViewChange }: { onViewChange?: (view: number) => void }) =
|
||||
|
||||
{showCount && (
|
||||
<span className="mt-px text-[8px] leading-none">
|
||||
{unreadByView[item.view] > 99 ? "99+" : unreadByView[item.view] || "0"}
|
||||
{unreadByView[item.view]! > 99 ? "99+" : unreadByView[item.view] || "0"}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -168,7 +168,7 @@ function RegisterForm() {
|
||||
return signUp.email({
|
||||
email: values.email,
|
||||
password: values.password,
|
||||
name: values.email.split("@")[0],
|
||||
name: values.email.split("@")[0]!,
|
||||
callbackURL: "/",
|
||||
fetchOptions: {
|
||||
onSuccess() {
|
||||
|
||||
@@ -240,7 +240,7 @@ const getEntryContentAsMarkdown = async (entry: FlatEntryModel) => {
|
||||
const isReadabilityReady = getReadabilityStatus()[entry.entries.id] === ReadabilityStatus.SUCCESS
|
||||
const content =
|
||||
(isReadabilityReady
|
||||
? getReadabilityContent()[entry.entries.id].content
|
||||
? getReadabilityContent()[entry.entries.id]!.content
|
||||
: entry.entries.content) || ""
|
||||
const [toMarkdown, toMdast, gfmTableToMarkdown] = await Promise.all([
|
||||
import("mdast-util-to-markdown").then((m) => m.toMarkdown),
|
||||
|
||||
@@ -158,7 +158,7 @@ export const DiscoverFeedForm = ({
|
||||
const ret = {}
|
||||
if (!route.parameters) return ret
|
||||
for (const key in route.parameters) {
|
||||
const params = normalizeRSSHubParameters(route.parameters[key])
|
||||
const params = normalizeRSSHubParameters(route.parameters[key]!)
|
||||
if (!params) continue
|
||||
ret[key] = params.default
|
||||
}
|
||||
@@ -218,7 +218,7 @@ export const DiscoverFeedForm = ({
|
||||
toast.error(err.message)
|
||||
const idx = keys.findIndex((item) => item.name === err.param)
|
||||
|
||||
form.setFocus(keys[idx === 0 ? 0 : idx - 1].name, {
|
||||
form.setFocus(keys[idx === 0 ? 0 : idx - 1]!.name, {
|
||||
shouldSelect: true,
|
||||
})
|
||||
}
|
||||
@@ -249,7 +249,7 @@ export const DiscoverFeedForm = ({
|
||||
)}
|
||||
<form className="flex flex-col gap-4" onSubmit={form.handleSubmit(onSubmit)} ref={formElRef}>
|
||||
{keys.map((keyItem) => {
|
||||
const parameters = normalizeRSSHubParameters(route.parameters?.[keyItem.name])
|
||||
const parameters = normalizeRSSHubParameters(route.parameters?.[keyItem.name]!)
|
||||
|
||||
const formRegister = form.register(keyItem.name)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ const info: Record<
|
||||
|
||||
type DiscoverSearchData = Awaited<ReturnType<typeof apiClient.discover.$post>>["data"]
|
||||
export function DiscoverForm({ type = "search" }: { type?: string }) {
|
||||
const { prefix, default: defaultValue } = info[type]
|
||||
const { prefix, default: defaultValue } = info[type]!
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
@@ -99,7 +99,7 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
|
||||
const { present, dismissAll } = useModalStack()
|
||||
|
||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
if (info[type].showModal) {
|
||||
if (info[type]!.showModal) {
|
||||
const defaultView = getSidebarActiveView() as FeedViewType
|
||||
present({
|
||||
title: t("feed_form.add_feed"),
|
||||
@@ -128,7 +128,7 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
|
||||
}
|
||||
const isValidPrefix = prefix.find((p) => trimmedKeyword.startsWith(p))
|
||||
if (!isValidPrefix) {
|
||||
form.setValue("keyword", prefix[0])
|
||||
form.setValue("keyword", prefix[0]!)
|
||||
return
|
||||
}
|
||||
if (trimmedKeyword.startsWith(`${isValidPrefix}${isValidPrefix}`)) {
|
||||
@@ -208,7 +208,7 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
|
||||
name="keyword"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>{t(info[type]?.label)}</FormLabel>
|
||||
<FormLabel>{t(info[type]?.label!)}</FormLabel>
|
||||
<FormControl>
|
||||
<Input autoFocus {...field} onChange={handleKeywordChange} />
|
||||
</FormControl>
|
||||
@@ -254,7 +254,7 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
|
||||
)}
|
||||
<div className="center flex" data-testid="discover-form-actions">
|
||||
<Button disabled={!form.formState.isValid} type="submit" isLoading={mutation.isPending}>
|
||||
{info[type].showModal ? t("discover.preview") : t("words.search")}
|
||||
{info[type]!.showModal ? t("discover.preview") : t("words.search")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -29,7 +29,7 @@ export const RecommendationCard: FC<RecommendationCardProps> = memo(
|
||||
const maintainers = new Set<string>()
|
||||
const categories = new Set<string>()
|
||||
for (const route in data.routes) {
|
||||
const routeData = data.routes[route]
|
||||
const routeData = data.routes[route]!
|
||||
if (routeData.maintainers) {
|
||||
routeData.maintainers.forEach((m) => maintainers.add(m))
|
||||
}
|
||||
@@ -89,17 +89,17 @@ export const RecommendationCard: FC<RecommendationCardProps> = memo(
|
||||
content: () => (
|
||||
<RecommendationContent
|
||||
routePrefix={routePrefix}
|
||||
route={data.routes[route]}
|
||||
route={data.routes[route]!}
|
||||
/>
|
||||
),
|
||||
icon: (
|
||||
<FeedIcon className="size-4" size={16} siteUrl={`https://${data.url}`} />
|
||||
),
|
||||
title: `${data.name} - ${data.routes[route].name}`,
|
||||
title: `${data.name} - ${data.routes[route]!.name}`,
|
||||
})
|
||||
}}
|
||||
>
|
||||
{data.routes[route].name}
|
||||
{data.routes[route]!.name}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -29,11 +29,11 @@ export function DiscoverRSS3() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{data?.rss3.routes && (
|
||||
{data?.rss3!.routes && (
|
||||
<div className="w-full max-w-[540px]">
|
||||
<DiscoverFeedForm
|
||||
routePrefix="rss3"
|
||||
route={data.rss3.routes[Object.keys(data.rss3.routes)[0]]}
|
||||
route={data.rss3.routes[Object.keys(data.rss3.routes)[0]!]!}
|
||||
noDescription
|
||||
submitButtonClassName="justify-center"
|
||||
/>
|
||||
|
||||
@@ -67,11 +67,11 @@ export function DiscoverTransform() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{data?.rsshub.routes && (
|
||||
{data?.rsshub!.routes && (
|
||||
<div className="w-full max-w-[540px]">
|
||||
<DiscoverFeedForm
|
||||
routePrefix="rsshub"
|
||||
route={data?.rsshub.routes["/transform/html/:url/:routeParams"]}
|
||||
route={data?.rsshub.routes["/transform/html/:url/:routeParams"]!}
|
||||
routeParams={transformRouteParams}
|
||||
noDescription
|
||||
submitButtonClassName="justify-center"
|
||||
|
||||
@@ -27,11 +27,11 @@ export function DiscoverUser() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{data?.follow.routes && (
|
||||
{data?.follow!.routes && (
|
||||
<div className="w-full max-w-[540px]">
|
||||
<DiscoverFeedForm
|
||||
routePrefix="follow"
|
||||
route={data.follow.routes[Object.keys(data.follow.routes)[0]]}
|
||||
route={data.follow.routes[Object.keys(data.follow.routes)[0]!]!}
|
||||
noDescription
|
||||
submitButtonClassName="justify-center"
|
||||
/>
|
||||
|
||||
@@ -17,7 +17,7 @@ export function PictureItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
<div
|
||||
className={cn(
|
||||
"relative flex w-full shrink-0 items-center overflow-hidden rounded-md",
|
||||
!entry.media?.[0].url && "aspect-square",
|
||||
!entry.media?.[0]!.url && "aspect-square",
|
||||
)}
|
||||
>
|
||||
{entry.media?.[0] ? (
|
||||
|
||||
@@ -127,7 +127,7 @@ export const PictureWaterFallItem = memo(function PictureWaterFallItem({
|
||||
}}
|
||||
>
|
||||
{media && media.length > 0 ? (
|
||||
<MasonryItemFixedDimensionWrapper url={media[0].url}>
|
||||
<MasonryItemFixedDimensionWrapper url={media[0]!.url}>
|
||||
<SwipeMedia
|
||||
media={media}
|
||||
className={cn("w-full shrink-0 grow rounded-md", isActive && "rounded-b-none")}
|
||||
@@ -196,7 +196,7 @@ const MasonryItemFixedDimensionWrapper = (
|
||||
const style = useMemo(
|
||||
() => ({
|
||||
width: itemWidth,
|
||||
height: itemWidth / stableRadioCtx,
|
||||
height: itemWidth / stableRadioCtx!,
|
||||
}),
|
||||
[itemWidth, stableRadioCtx],
|
||||
)
|
||||
|
||||
@@ -111,10 +111,10 @@ export function VideoItem({ entryId, entryPreview, translation }: UniversalItemP
|
||||
/>
|
||||
) : entry.entries.media ? (
|
||||
<Media
|
||||
key={entry.entries.media?.[0].url}
|
||||
src={entry.entries.media?.[0].url}
|
||||
type={entry.entries.media?.[0].type}
|
||||
previewImageUrl={entry.entries.media?.[0].preview_image_url}
|
||||
key={entry.entries.media?.[0]!.url}
|
||||
src={entry.entries.media?.[0]!.url}
|
||||
type={entry.entries.media?.[0]!.type}
|
||||
previewImageUrl={entry.entries.media?.[0]!.preview_image_url}
|
||||
className={cn(
|
||||
"aspect-video w-full shrink-0 rounded-md object-cover",
|
||||
isActive && "rounded-b-none",
|
||||
|
||||
@@ -187,7 +187,7 @@ const VirtualGridImpl: FC<
|
||||
horizontal: true,
|
||||
count: columns.length,
|
||||
getScrollElement: () => scrollRef,
|
||||
estimateSize: (i) => columns[i],
|
||||
estimateSize: (i) => columns[i]!,
|
||||
overscan: 5,
|
||||
initialOffset: offsetCache.get(columnCacheKey) ?? 0,
|
||||
initialMeasurementsCache: measurementsCache.get(columnCacheKey) ?? [],
|
||||
@@ -205,7 +205,7 @@ const VirtualGridImpl: FC<
|
||||
const rowVirtualizer = useVirtualizer({
|
||||
count: rows.length + 1,
|
||||
estimateSize: () => {
|
||||
return columns[0] / ratioMap[view] + 58
|
||||
return columns[0]! / ratioMap[view] + 58
|
||||
},
|
||||
overscan: 5,
|
||||
gap: 8,
|
||||
@@ -309,7 +309,7 @@ const VirtualGridImpl: FC<
|
||||
>
|
||||
{ready && (
|
||||
<EntryItem
|
||||
entryId={entriesIds[virtualRow.index * columns.length + virtualColumn.index]}
|
||||
entryId={entriesIds[virtualRow.index * columns.length + virtualColumn.index]!}
|
||||
view={view}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -137,7 +137,7 @@ export const useEntriesByView = ({
|
||||
|
||||
const groupByDate = useGeneralSettingKey("groupByDate")
|
||||
const groupedCounts: number[] | undefined = useMemo(() => {
|
||||
if (views[view].gridMode) {
|
||||
if (views[view]!.gridMode) {
|
||||
return
|
||||
}
|
||||
if (!groupByDate) {
|
||||
@@ -184,8 +184,11 @@ function sortEntriesIdByEntryPublishedAt(entries: string[]) {
|
||||
const entriesId2Map = entryActions.getFlattenMapEntries()
|
||||
return entries
|
||||
.slice()
|
||||
.sort((a, b) =>
|
||||
entriesId2Map[b]?.entries.publishedAt.localeCompare(entriesId2Map[a]?.entries.publishedAt),
|
||||
.sort(
|
||||
(a, b) =>
|
||||
entriesId2Map[b]?.entries.publishedAt.localeCompare(
|
||||
entriesId2Map[a]?.entries.publishedAt!,
|
||||
) || 0,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -203,8 +206,10 @@ function sortEntriesIdByEntryInsertedAt(entries: string[]) {
|
||||
const entriesId2Map = entryActions.getFlattenMapEntries()
|
||||
return entries
|
||||
.slice()
|
||||
.sort((a, b) =>
|
||||
entriesId2Map[b]?.entries.insertedAt.localeCompare(entriesId2Map[a]?.entries.insertedAt),
|
||||
.sort(
|
||||
(a, b) =>
|
||||
entriesId2Map[b]?.entries.insertedAt.localeCompare(entriesId2Map[a]?.entries.insertedAt!) ||
|
||||
0,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -217,7 +222,7 @@ const useFetchEntryContentByStream = (remoteEntryIds?: string[]) => {
|
||||
const nextIds = [] as string[]
|
||||
if (onlyNoStored) {
|
||||
for (const id of remoteEntryIds) {
|
||||
const entry = getEntry(id)
|
||||
const entry = getEntry(id)!
|
||||
if (entry.entries.content) {
|
||||
continue
|
||||
}
|
||||
@@ -253,8 +258,8 @@ const useFetchEntryContentByStream = (remoteEntryIds?: string[]) => {
|
||||
|
||||
// Process all complete lines
|
||||
for (let i = 0; i < lines.length - 1; i++) {
|
||||
if (lines[i].trim()) {
|
||||
const json = JSON.parse(lines[i])
|
||||
if (lines[i]!.trim()) {
|
||||
const json = JSON.parse(lines[i]!)
|
||||
// Handle each JSON line here
|
||||
entryActions.updateEntryContent(json.id, json.content)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export const useEntryMarkReadHandler = (entriesIds: string[]) => {
|
||||
)
|
||||
|
||||
return useMemo(() => {
|
||||
if (views[feedView].wideMode && renderAsRead) {
|
||||
if (views[feedView]!.wideMode && renderAsRead) {
|
||||
return handleRenderAsRead
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ function EntryColumnImpl() {
|
||||
|
||||
// Determine if the archived button should be shown
|
||||
const showArchivedButton = commonConditions && feed?.type === "feed"
|
||||
const hasNoEntries = entries.data?.pages?.[0].data?.length === 0 && !entries.isLoading
|
||||
const hasNoEntries = entries.data?.pages?.[0]?.data?.length === 0 && !entries.isLoading
|
||||
|
||||
// Determine if archived entries should be loaded
|
||||
const shouldLoadArchivedEntries =
|
||||
@@ -140,7 +140,7 @@ function EntryColumnImpl() {
|
||||
}
|
||||
|
||||
if (!renderAsRead) return
|
||||
if (!views[view].wideMode) {
|
||||
if (!views[view]!.wideMode) {
|
||||
return
|
||||
}
|
||||
// For gird, render as mark read logic
|
||||
@@ -156,7 +156,7 @@ function EntryColumnImpl() {
|
||||
}, [entries])
|
||||
const isMobile = useMobile()
|
||||
|
||||
const ListComponent = views[view].gridMode ? EntryColumnGrid : EntryList
|
||||
const ListComponent = views[view]!.gridMode ? EntryColumnGrid : EntryList
|
||||
return (
|
||||
<div
|
||||
data-hide-in-print
|
||||
|
||||
@@ -68,7 +68,7 @@ export const EntryItemSkeleton: FC<{
|
||||
}
|
||||
|
||||
return SkeletonItem ? (
|
||||
<div className={cn(views[view].gridMode ? girdClassNames : "flex flex-col")}>
|
||||
<div className={cn(views[view]!.gridMode ? girdClassNames : "flex flex-col")}>
|
||||
{SkeletonItem}
|
||||
{SkeletonItem}
|
||||
{SkeletonItem}
|
||||
|
||||
@@ -85,7 +85,7 @@ export const EntryListHeader: FC<{
|
||||
)}
|
||||
onClick={stopPropagation}
|
||||
>
|
||||
{views[view].wideMode && entryId && entryId !== ROUTE_ENTRY_PENDING && (
|
||||
{views[view]!.wideMode && entryId && entryId !== ROUTE_ENTRY_PENDING && (
|
||||
<>
|
||||
<EntryHeader view={view} entryId={entryId} />
|
||||
<DividerVertical className="mx-2 w-px" />
|
||||
@@ -93,7 +93,7 @@ export const EntryListHeader: FC<{
|
||||
)}
|
||||
|
||||
<AppendTaildingDivider>
|
||||
{!views[view].wideMode && <WideModeButton />}
|
||||
{!views[view]!.wideMode && <WideModeButton />}
|
||||
{view === FeedViewType.SocialMedia && <DailyReportButton />}
|
||||
{view === FeedViewType.Pictures && <SwitchToMasonryButton />}
|
||||
{view === FeedViewType.Pictures && <FilterNoImageButton />}
|
||||
|
||||
@@ -149,7 +149,7 @@ export const SwitchToMasonryButton = () => {
|
||||
step={1}
|
||||
defaultValue={[masonryColumnValue]}
|
||||
onValueCommit={(value) => {
|
||||
setMasonryColumnValue(value[0])
|
||||
setMasonryColumnValue(value[0]!)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -12,13 +12,15 @@ export const TimelineTabs = () => {
|
||||
|
||||
const listsData = useSubscriptionStore(
|
||||
useCallback(
|
||||
(state) => state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "listId" in s),
|
||||
(state) =>
|
||||
state.feedIdByView[view].map((id) => state.data[id]).filter((s) => s && "listId" in s),
|
||||
[view],
|
||||
),
|
||||
)
|
||||
const inboxData = useSubscriptionStore(
|
||||
useCallback(
|
||||
(state) => state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "inboxId" in s),
|
||||
(state) =>
|
||||
state.feedIdByView[view].map((id) => state.data[id]).filter((s) => s && "inboxId" in s),
|
||||
[view],
|
||||
),
|
||||
)
|
||||
@@ -27,7 +29,7 @@ export const TimelineTabs = () => {
|
||||
(state) => {
|
||||
const categoryNames = new Set<string>()
|
||||
for (const subId of state.feedIdByView[view]) {
|
||||
const sub = state.data[subId]
|
||||
const sub = state.data[subId]!
|
||||
if (sub.category) {
|
||||
categoryNames.add(sub.category)
|
||||
}
|
||||
@@ -63,16 +65,18 @@ export const TimelineTabs = () => {
|
||||
<TabsTrigger className="p-0" value="">
|
||||
<span>Yours</span>
|
||||
</TabsTrigger>
|
||||
{listsData.map((s) => (
|
||||
<TabsTrigger className="p-0" key={s.listId} value={s.listId!}>
|
||||
<ListItem
|
||||
listId={s.listId!}
|
||||
view={view}
|
||||
iconSize={16}
|
||||
className="h-5 !bg-transparent p-0"
|
||||
/>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
{listsData
|
||||
.filter((s) => !!s)
|
||||
.map((s) => (
|
||||
<TabsTrigger className="p-0" key={s.listId} value={s.listId!}>
|
||||
<ListItem
|
||||
listId={s.listId!}
|
||||
view={view}
|
||||
iconSize={16}
|
||||
className="h-5 !bg-transparent p-0"
|
||||
/>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
{categoriesData.map((s) => (
|
||||
<TabsTrigger
|
||||
key={s}
|
||||
@@ -89,16 +93,18 @@ export const TimelineTabs = () => {
|
||||
</span>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
{inboxData.map((s) => (
|
||||
<TabsTrigger key={s.inboxId} value={s.inboxId!}>
|
||||
<InboxItem
|
||||
inboxId={s.inboxId!}
|
||||
view={view}
|
||||
iconSize={16}
|
||||
className="h-5 !bg-transparent p-0"
|
||||
/>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
{inboxData
|
||||
.filter((s) => !!s)
|
||||
.map((s) => (
|
||||
<TabsTrigger key={s.inboxId} value={s.inboxId!}>
|
||||
<InboxItem
|
||||
inboxId={s.inboxId!}
|
||||
view={view}
|
||||
iconSize={16}
|
||||
className="h-5 !bg-transparent p-0"
|
||||
/>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
)
|
||||
|
||||
@@ -110,7 +110,7 @@ export const EntryList: FC<EntryListProps> = memo(
|
||||
groupCounts
|
||||
? groupCounts.reduce(
|
||||
(acc, count, index) => {
|
||||
acc[index + 1] = acc[index] + count
|
||||
acc[index + 1] = acc[index]! + count
|
||||
return acc
|
||||
},
|
||||
[0],
|
||||
@@ -263,7 +263,7 @@ export const EntryList: FC<EntryListProps> = memo(
|
||||
}
|
||||
>
|
||||
<EntryHeadDateItem
|
||||
entryId={entriesIds[virtualRow.index]}
|
||||
entryId={entriesIds[virtualRow.index]!}
|
||||
isSticky={isActiveStickyItem}
|
||||
/>
|
||||
</div>
|
||||
@@ -277,7 +277,7 @@ export const EntryList: FC<EntryListProps> = memo(
|
||||
ref={rowVirtualizer.measureElement}
|
||||
data-index={virtualRow.index}
|
||||
>
|
||||
<EntryItem entryId={entriesIds[virtualRow.index]} view={view} />
|
||||
<EntryItem entryId={entriesIds[virtualRow.index]!} view={view} />
|
||||
</div>
|
||||
</Fragment>
|
||||
)
|
||||
|
||||
@@ -83,7 +83,7 @@ export function ListItem({
|
||||
|
||||
const related = feed || inbox
|
||||
|
||||
const hasAudio = entry.entries?.attachments?.[0].url
|
||||
const hasAudio = entry.entries?.attachments?.[0]!.url
|
||||
const hasMedia = entry.entries?.media?.[0]?.url
|
||||
|
||||
const marginWidth = 8 * (isMobile ? 1.125 : 1)
|
||||
@@ -180,9 +180,9 @@ export function ListItem({
|
||||
{withAudio && !!hasAudio && (
|
||||
<AudioCover
|
||||
entryId={entryId}
|
||||
src={entry.entries!.attachments![0].url}
|
||||
src={entry.entries!.attachments![0]!.url}
|
||||
durationInSeconds={Number.parseInt(
|
||||
String(entry.entries!.attachments![0].duration_in_seconds ?? 0),
|
||||
String(entry.entries!.attachments![0]!.duration_in_seconds ?? 0),
|
||||
10,
|
||||
)}
|
||||
feedIcon={
|
||||
|
||||
@@ -15,10 +15,10 @@ export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperP
|
||||
return (
|
||||
<div className={clsx(styles, animationStyles, "mt-2")}>
|
||||
<ScrollArea
|
||||
scrollbarClassName={clsx(!views[view].wideMode ? "w-[5px] p-0" : "", "z-[3]")}
|
||||
scrollbarClassName={clsx(!views[view]!.wideMode ? "w-[5px] p-0" : "", "z-[3]")}
|
||||
mask={false}
|
||||
ref={ref}
|
||||
rootClassName={clsx("h-full", views[view].wideMode ? "mt-2" : "")}
|
||||
rootClassName={clsx("h-full", views[view]!.wideMode ? "mt-2" : "")}
|
||||
viewportClassName="[&>div]:grow flex"
|
||||
onScroll={onScroll}
|
||||
>
|
||||
|
||||
@@ -19,7 +19,10 @@ export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperP
|
||||
const [scrollElement, setScrollElement] = useState<HTMLElement | null>(null)
|
||||
return (
|
||||
<div className={clsx(styles, "relative flex flex-col")}>
|
||||
<div ref={ref} className={clsx("grow overflow-hidden", views[view].wideMode ? "mt-2" : "")}>
|
||||
<div
|
||||
ref={ref}
|
||||
className={clsx("grow overflow-hidden", views[view]!.wideMode ? "mt-2" : "")}
|
||||
>
|
||||
<PullToRefresh className="h-full" onRefresh={onPullToRefresh || noop}>
|
||||
<ScrollElementContext.Provider value={scrollElement}>
|
||||
<div
|
||||
|
||||
@@ -93,7 +93,7 @@ export const ElectronAdditionActions = IN_ELECTRON
|
||||
entryReadabilityStatus === ReadabilityStatus.WAITING ? `animate-pulse` : "",
|
||||
),
|
||||
key: "readability",
|
||||
hide: views[view].wideMode || !populatedEntry.entries.url,
|
||||
hide: views[view]!.wideMode || !populatedEntry.entries.url,
|
||||
active: isInReadability(entryReadabilityStatus),
|
||||
onClick: readabilityToggle,
|
||||
},
|
||||
|
||||
@@ -100,7 +100,7 @@ const MasonryItemFixedDimensionWrapper = (
|
||||
const style = useMemo(
|
||||
() => ({
|
||||
width: itemWidth,
|
||||
height: itemWidth / stableRadioCtx,
|
||||
height: itemWidth / stableRadioCtx!,
|
||||
}),
|
||||
[itemWidth, stableRadioCtx],
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ function EntryHeaderImpl({ view, entryId, className, compact }: EntryHeaderProps
|
||||
className={cn(
|
||||
"absolute left-5 top-0 flex h-full items-center gap-2 text-[13px] leading-none text-zinc-500 zen-mode-macos:left-12",
|
||||
"visible z-[11]",
|
||||
views[view].wideMode && "static",
|
||||
views[view]!.wideMode && "static",
|
||||
shouldShowMeta && "hidden",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -299,7 +299,7 @@ const BackTopIndicator: Component = memo(({ className }) => {
|
||||
<div className="flex items-center gap-2 tabular-nums">
|
||||
<IconOpacityTransition
|
||||
icon1={<MaterialSymbolsProgressActivity />}
|
||||
icon2={<CircleProgress percent={readPercent} size={14} strokeWidth={2} />}
|
||||
icon2={<CircleProgress percent={readPercent!} size={14} strokeWidth={2} />}
|
||||
status={readPercent === 0 ? "init" : "done"}
|
||||
/>
|
||||
<span>{readPercent}%</span>
|
||||
@@ -311,7 +311,7 @@ const BackTopIndicator: Component = memo(({ className }) => {
|
||||
}}
|
||||
className={cn(
|
||||
"mt-1 flex flex-nowrap items-center gap-2 opacity-50 transition-all duration-500 hover:opacity-100",
|
||||
readPercent > 10 ? "" : "pointer-events-none opacity-0",
|
||||
readPercent! > 10 ? "" : "pointer-events-none opacity-0",
|
||||
)}
|
||||
>
|
||||
<i className="i-mingcute-arrow-up-circle-line" />
|
||||
|
||||
@@ -68,7 +68,7 @@ function FeedCategoryImpl({ data: ids, view, categoryOpenStateData }: FeedCatego
|
||||
|
||||
const navigate = useNavigateEntry()
|
||||
|
||||
const subscription = useSubscriptionByFeedId(ids[0])
|
||||
const subscription = useSubscriptionByFeedId(ids[0]!)!
|
||||
const autoGroup = useGeneralSettingSelector((state) => state.autoGroup)
|
||||
const folderName =
|
||||
subscription?.category || (autoGroup ? subscription.defaultCategory : subscription.feedId)
|
||||
@@ -240,7 +240,7 @@ function FeedCategoryImpl({ data: ids, view, categoryOpenStateData }: FeedCatego
|
||||
submenu: views
|
||||
.filter((v) => v.view !== view)
|
||||
.map((v) => ({
|
||||
label: t(v.name),
|
||||
label: t(v.name as any),
|
||||
type: "text" as const,
|
||||
shortcut: (v.view + 1).toString(),
|
||||
icon: v.icon,
|
||||
|
||||
@@ -217,7 +217,7 @@ const ViewSwitchButton: FC<{
|
||||
<ActionButton
|
||||
ref={setNodeRef}
|
||||
key={item.name}
|
||||
tooltip={t(item.name)}
|
||||
tooltip={t(item.name as any)}
|
||||
shortcut={`${index + 1}`}
|
||||
className={cn(
|
||||
active === index && item.className,
|
||||
@@ -237,7 +237,7 @@ const ViewSwitchButton: FC<{
|
||||
{item.icon}
|
||||
{showSidebarUnreadCount ? (
|
||||
<div className="text-[0.625rem] font-medium leading-none">
|
||||
{unreadByView[index] > 99 ? <span className="-mr-0.5">99+</span> : unreadByView[index]}
|
||||
{unreadByView[index]! > 99 ? <span className="-mr-0.5">99+</span> : unreadByView[index]}
|
||||
</div>
|
||||
) : (
|
||||
<i
|
||||
|
||||
@@ -62,7 +62,7 @@ const DraggableItemWrapper: Component<
|
||||
}
|
||||
const FeedItemImpl = ({ view, feedId, className }: FeedItemProps) => {
|
||||
const { t } = useTranslation()
|
||||
const subscription = useSubscriptionByFeedId(feedId)
|
||||
const subscription = useSubscriptionByFeedId(feedId)!
|
||||
const navigate = useNavigateEntry()
|
||||
const feed = useFeedById(feedId, (feed) => {
|
||||
return {
|
||||
@@ -244,7 +244,7 @@ const ListItemImpl: Component<{
|
||||
const listUnread = useFeedUnreadStore((state) => state.data[listId] || 0)
|
||||
|
||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
||||
const subscription = useSubscriptionByFeedId(listId)
|
||||
const subscription = useSubscriptionByFeedId(listId)!
|
||||
const navigate = useNavigateEntry()
|
||||
const handleNavigate = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
|
||||
@@ -174,7 +174,7 @@ const FeedListImpl = forwardRef<HTMLDivElement, { className?: string; view: numb
|
||||
firstIndex < currentIndex
|
||||
? [firstIndex, currentIndex]
|
||||
: [currentIndex, firstIndex]
|
||||
const between = allVisible.slice(order[0], order[1] + 1) as string[]
|
||||
const between = allVisible.slice(order[0], order[1]! + 1) as string[]
|
||||
setSelectedFeedIds((prev) => {
|
||||
// with intersection, we need to update selected ids as between
|
||||
// otherwise, we need to add between to selected ids
|
||||
@@ -199,7 +199,7 @@ const FeedListImpl = forwardRef<HTMLDivElement, { className?: string; view: numb
|
||||
threshold: 0,
|
||||
}}
|
||||
onScroll={(e) => {
|
||||
scrollerRef.current?.scrollBy(e.direction[0] * 10, e.direction[1] * 10)
|
||||
scrollerRef.current?.scrollBy(e.direction[0]! * 10, e.direction[1]! * 10)
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
@@ -94,11 +94,11 @@ const FeedListImpl = ({ className, view }: { className?: string; view: number })
|
||||
}}
|
||||
className={cn(feedColumnStyles.item, "px-2.5 py-[2px]")}
|
||||
>
|
||||
{views[view].icon}
|
||||
{views[view]!.icon}
|
||||
<span className="ml-2">
|
||||
{t("words.all", { ns: "common" })}
|
||||
{t("space", { ns: "common" })}
|
||||
{t(views[view].name)}
|
||||
{t(views[view]!.name as any)}
|
||||
</span>
|
||||
</button>
|
||||
<SortableFeedList
|
||||
|
||||
@@ -42,7 +42,7 @@ export const useFeedsGroupedData = (view: FeedViewType) => {
|
||||
|
||||
const groupFolder = {} as Record<string, string[]>
|
||||
|
||||
for (const subscription of data) {
|
||||
for (const subscription of data.filter((s) => !!s)) {
|
||||
const category =
|
||||
subscription.category || (autoGroup ? subscription.defaultCategory : subscription.feedId)
|
||||
|
||||
@@ -66,11 +66,11 @@ export const useListsGroupedData = (view: FeedViewType) => {
|
||||
return useMemo(() => {
|
||||
if (!data || data.length === 0) return {}
|
||||
|
||||
const lists = data.filter((s) => "listId" in s)
|
||||
const lists = data.filter((s) => s && "listId" in s)
|
||||
|
||||
const groupFolder = {} as Record<string, string[]>
|
||||
|
||||
for (const subscription of lists) {
|
||||
for (const subscription of lists.filter((s) => !!s)) {
|
||||
groupFolder[subscription.feedId] = [subscription.feedId]
|
||||
}
|
||||
|
||||
@@ -86,11 +86,11 @@ export const useInboxesGroupedData = (view: FeedViewType) => {
|
||||
return useMemo(() => {
|
||||
if (!data || data.length === 0) return {}
|
||||
|
||||
const inboxes = data.filter((s) => "inboxId" in s)
|
||||
const inboxes = data.filter((s) => s && "inboxId" in s)
|
||||
|
||||
const groupFolder = {} as Record<string, string[]>
|
||||
|
||||
for (const subscription of inboxes) {
|
||||
for (const subscription of inboxes.filter((s) => !!s)) {
|
||||
if (!subscription.inboxId) continue
|
||||
groupFolder[subscription.inboxId] = [subscription.inboxId]
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export const ListHeader = ({ view }: { view: number }) => {
|
||||
let unread = 0
|
||||
|
||||
for (const category in feedsData) {
|
||||
for (const feedId of feedsData[category]) {
|
||||
for (const feedId of feedsData[category]!) {
|
||||
unread += state.data[feedId] || 0
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ export const ListHeader = ({ view }: { view: number }) => {
|
||||
}
|
||||
}}
|
||||
>
|
||||
{view !== undefined && t(views[view].name)}
|
||||
{view !== undefined && t(views[view]!.name as any)}
|
||||
</div>
|
||||
<div className="ml-2 flex items-center gap-3 text-base text-zinc-400 dark:text-zinc-600 lg:text-sm lg:!text-theme-vibrancyFg">
|
||||
<SortButton />
|
||||
|
||||
@@ -20,7 +20,7 @@ export const SortByAlphabeticalFeedList = ({
|
||||
(state) => {
|
||||
const map = {} as Record<string, string>
|
||||
for (const categoryName in data) {
|
||||
const feedId = data[categoryName][0]
|
||||
const feedId = data[categoryName]![0]
|
||||
if (!feedId) {
|
||||
continue
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export const SortByAlphabeticalFeedList = ({
|
||||
(state) => {
|
||||
const map = {} as Record<string, string>
|
||||
for (const categoryName in data) {
|
||||
const feedId = data[categoryName][0]
|
||||
const feedId = data[categoryName]![0]
|
||||
|
||||
if (!feedId) {
|
||||
continue
|
||||
@@ -52,7 +52,7 @@ export const SortByAlphabeticalFeedList = ({
|
||||
continue
|
||||
}
|
||||
const hascategoryNameNotDefault = !!feedId2CategoryMap[feedId]
|
||||
const isSingle = data[categoryName].length === 1
|
||||
const isSingle = data[categoryName]!.length === 1
|
||||
if (!isSingle || hascategoryNameNotDefault) {
|
||||
map[categoryName] = categoryName
|
||||
} else {
|
||||
@@ -84,7 +84,7 @@ export const SortByAlphabeticalFeedList = ({
|
||||
{sortedByAlphabetical.map((category) => (
|
||||
<FeedCategory
|
||||
key={category}
|
||||
data={data[category]}
|
||||
data={data[category]!}
|
||||
view={view}
|
||||
categoryOpenStateData={categoryOpenStateData}
|
||||
/>
|
||||
|
||||
@@ -16,7 +16,7 @@ export const SortByUnreadFeedList = ({ view, data, categoryOpenStateData }: Feed
|
||||
const folderUnread = {} as Record<string, number>
|
||||
// Calc total unread count for each folder
|
||||
for (const category in data) {
|
||||
folderUnread[category] = data[category].reduce(
|
||||
folderUnread[category] = data[category]!.reduce(
|
||||
(acc, cur) => (state.data[cur] || 0) + acc,
|
||||
0,
|
||||
)
|
||||
@@ -24,9 +24,9 @@ export const SortByUnreadFeedList = ({ view, data, categoryOpenStateData }: Feed
|
||||
|
||||
// Sort by unread count
|
||||
Object.keys(folderUnread)
|
||||
.sort((a, b) => folderUnread[b] - folderUnread[a])
|
||||
.sort((a, b) => folderUnread[b]! - folderUnread[a]!)
|
||||
.forEach((key) => {
|
||||
sortedList.push([key, data[key]])
|
||||
sortedList.push([key, data[key]!])
|
||||
})
|
||||
|
||||
if (!isDesc) {
|
||||
|
||||
@@ -165,10 +165,10 @@ export function FeedIcon({
|
||||
const [src] = getFeedIconSrc({
|
||||
siteUrl,
|
||||
})
|
||||
finalSrc = src
|
||||
finalSrc = src!
|
||||
|
||||
const isIconLoaded = isIconLoadedSet.has(src)
|
||||
isIconLoadedSet.add(src)
|
||||
const isIconLoaded = isIconLoadedSet.has(src!)
|
||||
isIconLoadedSet.add(src!)
|
||||
|
||||
ImageElement = (
|
||||
<PlatformIcon url={siteUrl} style={sizeStyle} className={cn("center", className)}>
|
||||
@@ -207,7 +207,7 @@ export function FeedIcon({
|
||||
height: size * 2,
|
||||
},
|
||||
})
|
||||
finalSrc = src
|
||||
finalSrc = src!
|
||||
|
||||
ImageElement = (
|
||||
<PlatformIcon
|
||||
@@ -218,7 +218,7 @@ export function FeedIcon({
|
||||
<FallbackableImage
|
||||
className={cn(marginClassName, className)}
|
||||
style={sizeStyle}
|
||||
fallbackUrl={fallbackSrc}
|
||||
fallbackUrl={fallbackSrc!}
|
||||
/>
|
||||
</PlatformIcon>
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ export const ViewSelectContent = () => {
|
||||
<SelectItem key={view.name} value={`${index}`}>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className={cn(view.className, "flex")}>{view.icon}</span>
|
||||
<span>{t(view.name)}</span>
|
||||
<span>{t(view.name as any)}</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
|
||||
@@ -189,17 +189,17 @@ export function GuideModalContent({ onClose }: { onClose: () => void }) {
|
||||
{!!title && (
|
||||
<div className="mb-6">
|
||||
<h1 className="mb-2 flex w-full items-center justify-center gap-2 text-xl font-bold">
|
||||
{typeof guideSteps[step - 1].icon === "string" ? (
|
||||
<i className={cn(guideSteps[step - 1].icon, "size-[22px]")} />
|
||||
{typeof guideSteps[step - 1]!.icon === "string" ? (
|
||||
<i className={cn(guideSteps[step - 1]!.icon, "size-[22px]")} />
|
||||
) : (
|
||||
guideSteps[step - 1].icon
|
||||
guideSteps[step - 1]!.icon
|
||||
)}
|
||||
{title}
|
||||
</h1>
|
||||
{!!guideSteps[step - 1].description && (
|
||||
{!!guideSteps[step - 1]!.description && (
|
||||
<div className="flex justify-center text-center text-sm text-theme-vibrancyFg">
|
||||
<Markdown className="prose max-w-[100ch] text-left text-sm">
|
||||
{guideSteps[step - 1].description!}
|
||||
{guideSteps[step - 1]!.description!}
|
||||
</Markdown>
|
||||
</div>
|
||||
)}
|
||||
@@ -208,7 +208,7 @@ export function GuideModalContent({ onClose }: { onClose: () => void }) {
|
||||
{status === "initial" ? (
|
||||
<Intro />
|
||||
) : status === "active" ? (
|
||||
guideSteps[step - 1].content
|
||||
guideSteps[step - 1]!.content
|
||||
) : status === "complete" ? (
|
||||
<Outtro />
|
||||
) : null}
|
||||
|
||||
@@ -352,8 +352,8 @@ export const PlayerProgress = () => {
|
||||
value={[controlledCurrentTime]}
|
||||
onPointerDown={() => setIsDraggingProgress(true)}
|
||||
onPointerUp={() => setIsDraggingProgress(false)}
|
||||
onValueChange={(value) => setControlledCurrentTime(value[0])}
|
||||
onValueCommit={(value) => AudioPlayer.seek(value[0])}
|
||||
onValueChange={(value) => setControlledCurrentTime(value[0]!)}
|
||||
onValueCommit={(value) => AudioPlayer.seek(value[0]!)}
|
||||
>
|
||||
<Slider.Track className="relative h-1 w-full grow rounded bg-gray-200 duration-200 group-hover:bg-gray-300 dark:bg-neutral-700 group-hover:dark:bg-neutral-600">
|
||||
<Slider.Range className="absolute h-1 rounded bg-theme-accent-400 dark:bg-theme-accent-700" />
|
||||
|
||||
@@ -53,7 +53,7 @@ export const useRewardDescriptionModal = () => {
|
||||
{
|
||||
from(
|
||||
serverConfigs.DAILY_POWER_SUPPLY *
|
||||
serverConfigs?.DAILY_POWER_PERCENTAGES[level],
|
||||
serverConfigs?.DAILY_POWER_PERCENTAGES[level]!,
|
||||
18,
|
||||
)[0]
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export const WithdrawButton = () => {
|
||||
const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
|
||||
const { t } = useTranslation("settings")
|
||||
const wallet = useWallet()
|
||||
const cashablePowerTokenBigInt = [BigInt(wallet.data?.[0].cashablePowerToken || 0n), 18] as const
|
||||
const cashablePowerTokenBigInt = [BigInt(wallet.data?.[0]!.cashablePowerToken || 0n), 18] as const
|
||||
const cashablePowerTokenNumber = toNumber(cashablePowerTokenBigInt)
|
||||
|
||||
const formSchema = z.object({
|
||||
@@ -119,8 +119,8 @@ const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
|
||||
i18nKey="wallet.withdraw.availableBalance"
|
||||
components={{
|
||||
Balance: (
|
||||
<Balance className="inline-block" value={wallet.data?.[0].cashablePowerToken || "0"}>
|
||||
{wallet.data?.[0].cashablePowerToken || "0"}
|
||||
<Balance className="inline-block" value={wallet.data?.[0]!.cashablePowerToken || "0"}>
|
||||
{wallet.data?.[0]!.cashablePowerToken || "0"}
|
||||
</Balance>
|
||||
),
|
||||
}}
|
||||
|
||||
@@ -40,7 +40,7 @@ export const useUserSubscriptionsQuery = (userId: string | undefined) => {
|
||||
if (!groupFolder[subscription.category]) {
|
||||
groupFolder[subscription.category] = []
|
||||
}
|
||||
groupFolder[subscription.category].push(subscription)
|
||||
groupFolder[subscription.category]!.push(subscription)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ export const UserProfileModalContent: FC<SubscriptionModalContentProps> = ({ use
|
||||
<SubscriptionGroup
|
||||
key={category}
|
||||
category={category}
|
||||
subscriptions={subscriptions.data?.[category]}
|
||||
subscriptions={subscriptions.data?.[category]!}
|
||||
itemStyle="loose"
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -57,7 +57,7 @@ export const SubscriptionItems = ({
|
||||
<SubscriptionGroup
|
||||
key={category}
|
||||
category={category}
|
||||
subscriptions={subscriptions.data?.[category]}
|
||||
subscriptions={subscriptions.data?.[category]!}
|
||||
itemStyle={itemStyle}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -10,7 +10,7 @@ export const TimeStamp = (props: { time: string }) => {
|
||||
const { entryId } = useContext(EntryInfoContext)
|
||||
const entry = useEntry(entryId)
|
||||
const mediaDuration = entry?.entries.attachments?.[0]?.duration_in_seconds
|
||||
const src = entry?.entries?.attachments?.[0].url
|
||||
const src = entry?.entries?.attachments?.[0]?.url
|
||||
if (!src) return <span>{props.time}</span>
|
||||
|
||||
const seekTo = timeStringToSeconds(props.time)
|
||||
@@ -95,10 +95,10 @@ function timeStringToSeconds(time: string): number | null {
|
||||
|
||||
if (timeParts.length === 2) {
|
||||
const [minutes, seconds] = timeParts
|
||||
return minutes * 60 + seconds
|
||||
return minutes! * 60 + seconds!
|
||||
} else if (timeParts.length === 3) {
|
||||
const [hours, minutes, seconds] = timeParts
|
||||
return hours * 3600 + minutes * 60 + seconds
|
||||
return hours! * 3600 + minutes! * 60 + seconds!
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export function SettingModalLayout(
|
||||
if (initialTab) {
|
||||
setTab(initialTab)
|
||||
} else {
|
||||
setTab(availableSettings[0].path)
|
||||
setTab(availableSettings[0]!.path)
|
||||
}
|
||||
}
|
||||
}, [availableSettings])
|
||||
|
||||
@@ -304,7 +304,7 @@ const AppCacheLimit = () => {
|
||||
})
|
||||
|
||||
const onChange = (value: number[]) => {
|
||||
tipcClient?.limitCacheSize(value[0])
|
||||
tipcClient?.limitCacheSize(value[0]!)
|
||||
refetchCacheLimit()
|
||||
}
|
||||
|
||||
|
||||
@@ -155,14 +155,14 @@ export const SettingLists = () => {
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex items-center",
|
||||
views[row.view].className,
|
||||
views[row.view]!.className,
|
||||
)}
|
||||
>
|
||||
{views[row.view].icon}
|
||||
{views[row.view]!.icon}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent>{t(views[row.view].name)}</TooltipContent>
|
||||
<TooltipContent>{t(views[row.view]!.name as any)}</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
|
||||
@@ -63,7 +63,7 @@ export const ListCreationModalContent = ({ id }: { id?: string }) => {
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
view: list?.view.toString() || views[0].view.toString(),
|
||||
view: list?.view.toString() || views[0]?.view.toString(),
|
||||
fee: list?.fee || 0,
|
||||
title: list?.title || "",
|
||||
description: list?.description || "",
|
||||
@@ -96,7 +96,8 @@ export const ListCreationModalContent = ({ id }: { id?: string }) => {
|
||||
dismiss()
|
||||
|
||||
if (!list) return
|
||||
if (id) subscriptionActions.changeListView(id, views[list.view].view, views[values.view].view)
|
||||
if (id)
|
||||
subscriptionActions.changeListView(id, views[list.view]!.view, views[values.view].view)
|
||||
},
|
||||
onError: createErrorToaster(id ? t("lists.edit.error") : t("lists.created.error")),
|
||||
})
|
||||
|
||||
@@ -45,7 +45,7 @@ export const ViewSelectorRadioGroup = forwardRef<
|
||||
{cloneElement(view.icon, {
|
||||
className: `text-lg ${view.icon?.props?.className ?? ""}`,
|
||||
})}
|
||||
<span className="mt-1 hidden text-xs lg:inline">{t(view.name)}</span>
|
||||
<span className="mt-1 hidden text-xs lg:inline">{t(view.name as any)}</span>
|
||||
</label>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -112,7 +112,7 @@ export function Component() {
|
||||
{currentTabs.map((tab) => (
|
||||
<TabsContent key={tab.name} value={tab.value} className="mt-8">
|
||||
<div className={tab.value === "inbox" ? "" : "center flex flex-col"}>
|
||||
{createElement(TabComponent[tab.value] || TabComponent.default, {
|
||||
{createElement(TabComponent[tab.value]! || TabComponent.default, {
|
||||
type: tab.value,
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -38,7 +38,7 @@ export const I18nProvider: FC<PropsWithChildren> = ({ children }) => {
|
||||
})
|
||||
const userLang = languageDetector.detect()
|
||||
if (!userLang) return
|
||||
const firstUserLang = Array.isArray(userLang) ? userLang[0] : userLang
|
||||
const firstUserLang = Array.isArray(userLang) ? userLang[0]! : userLang
|
||||
if (currentSupportedLanguages.includes(firstUserLang)) {
|
||||
setGeneralSetting("language", firstUserLang)
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ const ArticleElementResizeObserver = () => {
|
||||
setPosition({ x, y })
|
||||
|
||||
const observer = new ResizeObserver((entries) => {
|
||||
const entry = entries[0]
|
||||
const entry = entries[0]!
|
||||
const { height, width } = entry.contentRect
|
||||
const { x, y } = entry.target.getBoundingClientRect()
|
||||
|
||||
@@ -117,7 +117,7 @@ const BoundingDetection: Component<{
|
||||
const $el = ref.current
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
const entry = entries[0]
|
||||
const entry = entries[0]!
|
||||
|
||||
if (bounding === "start") startSetter(entry.isIntersecting)
|
||||
else endSetter(entry.isIntersecting)
|
||||
|
||||
@@ -12,7 +12,7 @@ export function useActionByIndex(index: number): ActionModel
|
||||
export function useActionByIndex<T>(index: number, selector: (action: ActionModel) => T): T
|
||||
export function useActionByIndex<T>(index: number, selector?: (action: ActionModel) => T) {
|
||||
return useActionStore((state) =>
|
||||
selector ? selector(state.actions[index]) : state.actions[index],
|
||||
selector ? selector(state.actions[index]!) : state.actions[index],
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class ActionActionStatic {
|
||||
|
||||
updateByIndex(index: number, update: (action: ActionModel) => void) {
|
||||
set((state) => {
|
||||
update(state.actions[index])
|
||||
update(state.actions[index]!)
|
||||
state.isDirty = true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ const unread = create({
|
||||
await apiClient.reads.$post({
|
||||
json: {
|
||||
entryIds: ids.map((i) => i.entryId),
|
||||
isInbox: ids[0].isInbox,
|
||||
isInbox: ids[0]!.isInbox,
|
||||
readHistories: ids.filter((i) => !i.isPrivate).map((i) => i.entryId),
|
||||
},
|
||||
})
|
||||
|
||||
@@ -115,4 +115,4 @@ export const useEntryIdsByFeedIdOrView = (
|
||||
export const useEntryReadHistory = (
|
||||
entryId: string,
|
||||
): Omit<EntryReadHistoriesModel, "entryId"> | null =>
|
||||
useEntryStore((state) => state.readHistory[entryId])
|
||||
useEntryStore((state) => state.readHistory[entryId] || null)
|
||||
|
||||
@@ -228,7 +228,7 @@ class EntryActions {
|
||||
|
||||
ids.forEach((entryId) => {
|
||||
if (filter) {
|
||||
const entry = draft.flatMapEntries[entryId]
|
||||
const entry = draft.flatMapEntries[entryId]!
|
||||
if (
|
||||
+new Date(entry.entries.publishedAt) < filter.startTime ||
|
||||
+new Date(entry.entries.publishedAt) > filter.endTime
|
||||
@@ -236,7 +236,7 @@ class EntryActions {
|
||||
return
|
||||
}
|
||||
}
|
||||
Object.assign(draft.flatMapEntries[entryId], changed)
|
||||
Object.assign(draft.flatMapEntries[entryId]!, changed)
|
||||
|
||||
if (changed.entries) {
|
||||
patchChangedEntriesInDb.push({
|
||||
@@ -290,11 +290,12 @@ class EntryActions {
|
||||
draft.internal_feedId2entryIdSet[item.feeds.id] = new Set()
|
||||
}
|
||||
|
||||
if (!draft.internal_feedId2entryIdSet[item.feeds.id].has(item.entries.id)) {
|
||||
draft.entries[item.feeds.id].push(item.entries.id)
|
||||
draft.internal_feedId2entryIdSet[item.feeds.id].add(item.entries.id)
|
||||
if (!draft.internal_feedId2entryIdSet[item.feeds.id]!.has(item.entries.id)) {
|
||||
draft.entries[item.feeds.id]!.push(item.entries.id)
|
||||
draft.internal_feedId2entryIdSet[item.feeds.id]!.add(item.entries.id)
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: fix this
|
||||
draft.flatMapEntries[item.entries.id] = merge(
|
||||
draft.flatMapEntries[item.entries.id] || {},
|
||||
{
|
||||
@@ -326,6 +327,7 @@ class EntryActions {
|
||||
draft.internal_feedId2entryIdSet[inboxId].add(item.entries.id)
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: fix this
|
||||
draft.flatMapEntries[item.entries.id] = merge(
|
||||
draft.flatMapEntries[item.entries.id] || {},
|
||||
{
|
||||
@@ -369,7 +371,7 @@ class EntryActions {
|
||||
}
|
||||
|
||||
if (item.settings && draft.flatMapEntries[item.entries.id] && !options?.isArchived) {
|
||||
draft.flatMapEntries[item.entries.id].settings = item.settings
|
||||
draft.flatMapEntries[item.entries.id]!.settings = item.settings
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,9 +414,9 @@ class EntryActions {
|
||||
draft.internal_feedId2entryIdSet[item.feedId] = new Set()
|
||||
}
|
||||
|
||||
if (!draft.internal_feedId2entryIdSet[item.feedId].has(item.entries.id)) {
|
||||
draft.entries[item.feedId].push(item.entries.id)
|
||||
draft.internal_feedId2entryIdSet[item.feedId].add(item.entries.id)
|
||||
if (!draft.internal_feedId2entryIdSet[item.feedId]!.has(item.entries.id)) {
|
||||
draft.entries[item.feedId]!.push(item.entries.id)
|
||||
draft.internal_feedId2entryIdSet[item.feedId]!.add(item.entries.id)
|
||||
}
|
||||
|
||||
draft.flatMapEntries[item.entries.id] = merge(
|
||||
@@ -444,7 +446,7 @@ class EntryActions {
|
||||
|
||||
async markRead({ feedId, entryId, read }: { feedId: string; entryId: string; read: boolean }) {
|
||||
const entry = get().flatMapEntries[entryId]
|
||||
const isInbox = entry?.entries && "inboxHandle" in entry.entries
|
||||
const isInbox = !!(entry?.entries && "inboxHandle" in entry.entries)
|
||||
const subscription = getSubscriptionByFeedId(feedId)
|
||||
|
||||
if (read && entry?.read) {
|
||||
@@ -454,7 +456,7 @@ class EntryActions {
|
||||
const tx = createTransaction<unknown, { prevUnread: number }>({})
|
||||
|
||||
tx.optimistic((_, ctx) => {
|
||||
const prevUnread = feedUnreadActions.incrementByFeedId(feedId, read ? -1 : 1)
|
||||
const prevUnread = feedUnreadActions.incrementByFeedId(feedId, read ? -1 : 1)!
|
||||
ctx.prevUnread = prevUnread
|
||||
|
||||
this.patch(entryId, {
|
||||
@@ -588,7 +590,7 @@ class EntryActions {
|
||||
|
||||
delete nextFlatMapEntries[entryId]
|
||||
|
||||
const index = state.entries[fullInboxId].indexOf(entryId)
|
||||
const index = state.entries[fullInboxId]!.indexOf(entryId)
|
||||
|
||||
const nextState = {
|
||||
...state,
|
||||
@@ -600,7 +602,7 @@ class EntryActions {
|
||||
const nextFeedEntries = {
|
||||
...state.entries,
|
||||
|
||||
[fullInboxId]: state.entries[fullInboxId].filter((id) => id !== entryId),
|
||||
[fullInboxId]: state.entries[fullInboxId]!.filter((id) => id !== entryId),
|
||||
}
|
||||
|
||||
nextState.entries = nextFeedEntries
|
||||
@@ -623,7 +625,7 @@ class EntryActions {
|
||||
...state,
|
||||
entries: {
|
||||
...state.entries,
|
||||
[entry.feedId]: state.entries[entry.feedId].splice(ctx.deletedIndex, 0, entryId),
|
||||
[entry.feedId]: state.entries[entry.feedId]!.splice(ctx.deletedIndex, 0, entryId),
|
||||
},
|
||||
flatMapEntries: {
|
||||
...state.flatMapEntries,
|
||||
|
||||
@@ -79,7 +79,7 @@ export const useFeedHeaderTitle = () => {
|
||||
|
||||
switch (currentFeedId) {
|
||||
case ROUTE_FEED_PENDING: {
|
||||
return t(views[view].name)
|
||||
return t(views[view]!.name as any)
|
||||
}
|
||||
case FEED_COLLECTION_LIST: {
|
||||
return t("words.starred")
|
||||
|
||||
@@ -10,6 +10,6 @@ export function useInboxById<T>(
|
||||
|
||||
export function useInboxById<T>(inboxId: Nullable<string>, selector?: (inbox: InboxModel) => T) {
|
||||
return useInboxStore((state) =>
|
||||
inboxId ? (selector ? selector(state.inboxes[inboxId]) : state.inboxes[inboxId]) : null,
|
||||
inboxId ? (selector ? selector(state.inboxes[inboxId]!) : state.inboxes[inboxId]) : null,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useWhoami } from "~/atoms/user"
|
||||
import { useListStore } from "./store"
|
||||
|
||||
export const useListById = (listId: Nullable<string>): ListModel | null =>
|
||||
useListStore((state) => (listId ? state.lists[listId] : null))
|
||||
useListStore((state) => (listId ? state.lists[listId] || null : null))
|
||||
|
||||
export const useListByView = (view: FeedViewType) => {
|
||||
return useListStore(
|
||||
|
||||
@@ -50,7 +50,7 @@ class ListActionStatic {
|
||||
|
||||
private patch(listId: string, data: Partial<ListModel>) {
|
||||
immerSet((state) => {
|
||||
state.lists[listId] = { ...state.lists[listId], ...data }
|
||||
state.lists[listId] = { ...state.lists[listId]!, ...data }
|
||||
return state
|
||||
})
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ export const useCategoriesByView = (view: FeedViewType) =>
|
||||
(state) =>
|
||||
new Set(
|
||||
subscriptionByViewSelector(view)(state)
|
||||
.map((subscription) => subscription.category)
|
||||
.map((subscription) => subscription!.category)
|
||||
.filter((category) => category !== null && category !== undefined)
|
||||
.filter(Boolean),
|
||||
),
|
||||
@@ -90,7 +90,7 @@ export const useAllFeeds = () => {
|
||||
const allSubscriptions = Object.values(store.feedIdByView).flat()
|
||||
|
||||
for (const feedId of allSubscriptions) {
|
||||
const subscription = store.data[feedId]
|
||||
const subscription = store.data[feedId]!
|
||||
const feed = feedTitleMap[feedId]
|
||||
if (feed) {
|
||||
feedInfo.push({ title: subscription.title || feed || "", id: feedId })
|
||||
|
||||
@@ -43,7 +43,7 @@ export const folderFeedsByFeedIdSelector =
|
||||
const folderName = feedId.replace(ROUTE_FEED_IN_FOLDER, "")
|
||||
const feedIds: string[] = []
|
||||
for (const feedId in state.data) {
|
||||
const subscription = state.data[feedId]
|
||||
const subscription = state.data[feedId]!
|
||||
if (
|
||||
subscription.view === view &&
|
||||
(subscription.category === folderName || subscription.defaultCategory === folderName)
|
||||
|
||||
@@ -255,7 +255,7 @@ class SubscriptionActions {
|
||||
tx.optimistic(async () => {
|
||||
const state = get()
|
||||
for (const feedId in state.data) {
|
||||
if (state.data[feedId].view === view) {
|
||||
if (state.data[feedId]!.view === view) {
|
||||
// We can not process this logic in local, so skip it. and then we will fetch the unread count from server.
|
||||
!filter && feedUnreadActions.updateByFeedId(feedId, 0)
|
||||
entryActions.patchManyByFeedId(feedId, { read: true }, filter)
|
||||
@@ -370,7 +370,7 @@ class SubscriptionActions {
|
||||
if (!idSet.has(id)) {
|
||||
return
|
||||
}
|
||||
const subscription = state.data[id]
|
||||
const subscription = state.data[id]!
|
||||
const feed = getFeedById(subscription.feedId)
|
||||
if (!feed || feed.type !== "feed") return
|
||||
const { siteUrl } = feed
|
||||
@@ -386,7 +386,7 @@ class SubscriptionActions {
|
||||
tx.rollback(async (snapshot) => {
|
||||
immerSet((state) => {
|
||||
Object.keys(snapshot.data).forEach((id) => {
|
||||
state.data[id] = snapshot.data[id]
|
||||
state.data[id] = snapshot.data[id]!
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -417,7 +417,7 @@ class SubscriptionActions {
|
||||
set((state) =>
|
||||
produce(state, (draft) => {
|
||||
for (const feedId of feedIds) {
|
||||
const subscription = state.data[feedId]
|
||||
const subscription = state.data[feedId]!
|
||||
ctx.subscription[feedId] = subscription
|
||||
|
||||
delete draft.data[feedId]
|
||||
@@ -444,7 +444,7 @@ class SubscriptionActions {
|
||||
if (!ctx.subscription[feedId]) return
|
||||
draft.data[feedId] = ctx.subscription[feedId]
|
||||
|
||||
for (const view of ctx.viewDeleted[feedId]) {
|
||||
for (const view of ctx.viewDeleted[feedId]!) {
|
||||
draft.feedIdByView[view].push(feedId)
|
||||
}
|
||||
}
|
||||
@@ -552,7 +552,7 @@ class SubscriptionActions {
|
||||
view,
|
||||
},
|
||||
})
|
||||
const oldView = snapshot.data[feedIdList[0]].view
|
||||
const oldView = snapshot.data[feedIdList[0]!]!.view
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
predicate(query) {
|
||||
@@ -592,7 +592,7 @@ class SubscriptionActions {
|
||||
changeToViewFeedIds.push(feedId)
|
||||
}
|
||||
|
||||
ctx.subscription[feedId] = state.data[feedId]
|
||||
ctx.subscription[feedId] = state.data[feedId]!
|
||||
}
|
||||
}),
|
||||
)
|
||||
@@ -602,7 +602,7 @@ class SubscriptionActions {
|
||||
set((state) =>
|
||||
produce(state, (draft) => {
|
||||
for (const feedId of feedIdList) {
|
||||
draft.data[feedId] = ctx.subscription[feedId]
|
||||
draft.data[feedId] = ctx.subscription[feedId]!
|
||||
}
|
||||
for (let i = 0; i < 6; i++) {
|
||||
draft.feedIdByView[i] = ctx.feedIdByView[i]
|
||||
@@ -648,7 +648,7 @@ class SubscriptionActions {
|
||||
const subscriptionIds = [] as string[]
|
||||
const state = get()
|
||||
for (const feedId in state.data) {
|
||||
const subscription = state.data[feedId]
|
||||
const subscription = state.data[feedId]!
|
||||
if (subscription.category === lastCategory || subscription.defaultCategory === lastCategory) {
|
||||
subscriptionIds.push(feedId)
|
||||
}
|
||||
@@ -676,7 +676,7 @@ class SubscriptionActions {
|
||||
subscription.category = newCategory
|
||||
subscription.defaultCategory = undefined
|
||||
|
||||
ctx.subscription[feedId] = state.data[feedId]
|
||||
ctx.subscription[feedId] = state.data[feedId]!
|
||||
}
|
||||
}
|
||||
}),
|
||||
@@ -686,7 +686,7 @@ class SubscriptionActions {
|
||||
set((state) =>
|
||||
produce(state, (draft) => {
|
||||
for (const feedId of Object.keys(ctx.subscription)) {
|
||||
draft.data[feedId] = ctx.subscription[feedId]
|
||||
draft.data[feedId] = ctx.subscription[feedId]!
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -91,7 +91,7 @@ class FeedUnreadActions {
|
||||
const handler = (state: UnreadState): void => {
|
||||
let unread = 0
|
||||
for (const key in state.data) {
|
||||
unread += state.data[key]
|
||||
unread += state.data[key]!
|
||||
}
|
||||
|
||||
fn(unread)
|
||||
|
||||
@@ -3,4 +3,4 @@ import type { UserModel } from "@follow/models/types"
|
||||
import { useUserStore } from "./store"
|
||||
|
||||
export const useUserById = (userId: string): UserModel | null =>
|
||||
useUserStore((state) => state.users[userId])
|
||||
useUserStore((state) => state.users[userId] || null)
|
||||
|
||||
@@ -20,7 +20,7 @@ const avatarBatcher = create({
|
||||
|
||||
const result = Array.from({ length: ids.length }).fill(null) as (typeof res)[string][]
|
||||
for (const [i, id] of ids.entries()) {
|
||||
result[i] = res[id]
|
||||
result[i] = res[id]!
|
||||
}
|
||||
return result
|
||||
},
|
||||
|
||||
@@ -70,7 +70,7 @@ export const registerPusher = (self: ServiceWorkerGlobalScope) => {
|
||||
.then((windowClients) => {
|
||||
if (windowClients.length > 0) {
|
||||
const client = windowClients[0]
|
||||
return client.focus()
|
||||
return client?.focus()
|
||||
}
|
||||
return self.clients.openWindow(urlToOpen.href)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user