chore: enable noUncheckedIndexedAccess, better type check (#2608)
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
"vscode-languagedetection": "npm:@vscode/vscode-languagedetection@^1.0.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@follow/types": "workspace:*",
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/node": "^22.10.1",
|
||||
"electron": "33.2.0",
|
||||
|
||||
@@ -18,8 +18,8 @@ const detectingWindows11 = () => {
|
||||
if (!isWindows) return false
|
||||
|
||||
const release = os.release()
|
||||
const majorVersion = Number.parseInt(release.split(".")[0])
|
||||
const buildNumber = Number.parseInt(release.split(".")[2])
|
||||
const majorVersion = Number.parseInt(release.split(".")[0]!)
|
||||
const buildNumber = Number.parseInt(release.split(".")[2]!)
|
||||
|
||||
return majorVersion === 10 && buildNumber >= 22000
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ const detectingWindows11 = () => {
|
||||
if (!isWindows) return false
|
||||
|
||||
const release = os.release()
|
||||
const majorVersion = Number.parseInt(release.split(".")[0])
|
||||
const buildNumber = Number.parseInt(release.split(".")[2])
|
||||
const majorVersion = Number.parseInt(release.split(".")[0]!)
|
||||
const buildNumber = Number.parseInt(release.split(".")[2]!)
|
||||
|
||||
return majorVersion === 10 && buildNumber >= 22000
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ function bootstrap() {
|
||||
userAgent = userAgent.replace(/\s?Electron\/[\d.]+/, "")
|
||||
userAgent = userAgent.replace(/\s?Follow\/[\d.a-zA-Z-]+/, "")
|
||||
}
|
||||
details.requestHeaders["User-Agent"] = userAgent
|
||||
details.requestHeaders["User-Agent"] = userAgent!
|
||||
|
||||
// set referer and origin
|
||||
if (selfRefererMatches.some((item) => details.url.startsWith(item))) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import { initializeSentry } from "./sentry"
|
||||
import { router } from "./tipc"
|
||||
import { createMainWindow, getMainWindow } from "./window"
|
||||
|
||||
if (process.argv.length === 3 && process.argv[2].startsWith("follow-dev:")) {
|
||||
if (process.argv.length === 3 && process.argv[2]!.startsWith("follow-dev:")) {
|
||||
process.env.NODE_ENV = "development"
|
||||
}
|
||||
const isDev = process.env.NODE_ENV === "development"
|
||||
@@ -36,7 +36,7 @@ export const initializeAppStage1 = () => {
|
||||
if (process.defaultApp) {
|
||||
if (process.argv.length >= 2) {
|
||||
app.setAsDefaultProtocolClient(APP_PROTOCOL, process.execPath, [
|
||||
path.resolve(process.argv[1]),
|
||||
path.resolve(process.argv[1]!),
|
||||
])
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -40,7 +40,7 @@ const normalizeProxyUri = (userProxy: string) => {
|
||||
return
|
||||
}
|
||||
// Only use the first proxy if there are multiple urls
|
||||
const firstInput = userProxy.split(",")[0]
|
||||
const firstInput = userProxy.split(",")[0]!
|
||||
|
||||
try {
|
||||
const proxyUrl = new URL(firstInput)
|
||||
|
||||
@@ -7,7 +7,7 @@ export function refreshBound(window: BrowserWindow, timeout = 0) {
|
||||
setTimeout(() => {
|
||||
// FIXME: workaround for theme bug in full screen mode
|
||||
const size = window?.getSize()
|
||||
window?.setSize(size[0] + 1, size[1] + 1)
|
||||
window?.setSize(size[0], size[1])
|
||||
window?.setSize(size[0]! + 1, size[1]! + 1)
|
||||
window?.setSize(size[0]!, size[1]!)
|
||||
}, timeout)
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ export const detectCodeStringLanguage = async function* (codeString: string) {
|
||||
logger.debug("no model results", codeString)
|
||||
return
|
||||
}
|
||||
const firstModelResult = adjustLanguageConfidence(modelResults[0])
|
||||
const firstModelResult = adjustLanguageConfidence(modelResults[0]!)
|
||||
if (firstModelResult.confidence < expectedRelativeConfidence) {
|
||||
logger.debug("first model result confidence is less than expected relative confidence")
|
||||
return
|
||||
|
||||
@@ -87,7 +87,7 @@ export class CustomGitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {
|
||||
if (hrefElement === null) continue
|
||||
|
||||
// This Release's Tag
|
||||
const hrefTag = hrefElement[1]
|
||||
const hrefTag = hrefElement[1]!
|
||||
// Get Channel from this release's tag
|
||||
// If it is null, we believe it is stable version
|
||||
const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || "stable"
|
||||
|
||||
@@ -40,7 +40,7 @@ const getLatestReleaseTag = async () => {
|
||||
|
||||
// Search the top nightly release
|
||||
const nightlyRelease = json.find((item) => item.prerelease)
|
||||
if (!nightlyRelease) return json[0].tag_name
|
||||
if (!nightlyRelease) return json[0]!.tag_name
|
||||
return nightlyRelease.tag_name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"outDir": "dist",
|
||||
"types": ["electron-vite/node"],
|
||||
"types": ["electron-vite/node", "@follow/types/vite"],
|
||||
"moduleResolution": "Bundler",
|
||||
"noImplicitReturns": false,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@pkg": ["../../package.json"],
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"ios:device": "expo run:ios --device",
|
||||
"lint": "expo lint",
|
||||
"start": "expo start --dev-client",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"web": "expo start --web"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -33,7 +33,7 @@ export function PickerIos<T>({
|
||||
|
||||
const [currentValue, setCurrentValue] = useState(() => {
|
||||
if (!value) {
|
||||
return options[0].value
|
||||
return options[0]!.value
|
||||
}
|
||||
return value
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ export function Select<T>({
|
||||
}: SelectProps<T>) {
|
||||
const [currentValue, setCurrentValue] = useState(() => {
|
||||
if (!value) {
|
||||
return options[0].value
|
||||
return options[0]!.value
|
||||
}
|
||||
return value
|
||||
})
|
||||
@@ -65,7 +65,7 @@ export function Select<T>({
|
||||
}))}
|
||||
onPress={(e) => {
|
||||
const { index } = e.nativeEvent
|
||||
handleChangeValue(options[index].value)
|
||||
handleChangeValue(options[index]!.value)
|
||||
}}
|
||||
>
|
||||
<View
|
||||
|
||||
@@ -28,7 +28,7 @@ export const FallbackIcon = ({
|
||||
const [, , , bgAccent, bgAccentLight, bgAccentUltraLight] = colors
|
||||
|
||||
const renderedText = useMemo(() => {
|
||||
const isCJK = isCJKChar(title[0])
|
||||
const isCJK = isCJKChar(title[0]!)
|
||||
return (
|
||||
<Text style={StyleSheet.flatten([styles.text, textStyle])} className={textClassName}>
|
||||
{isCJK ? title[0] : title.slice(0, 2)}
|
||||
@@ -39,7 +39,7 @@ export const FallbackIcon = ({
|
||||
return (
|
||||
<LinearGradient
|
||||
className={className}
|
||||
colors={[bgAccent, bgAccentLight, bgAccentUltraLight]}
|
||||
colors={[bgAccent!, bgAccentLight!, bgAccentUltraLight!]}
|
||||
locations={[0, 0.99, 1]}
|
||||
style={[sizeStyle, styles.container, style]}
|
||||
>
|
||||
|
||||
@@ -112,11 +112,11 @@ export const TabBar = forwardRef<ScrollView, TabBarProps>(
|
||||
indicatorPosition.value = withSpring(tabPositions[currentTab] || 0, springConfig)
|
||||
|
||||
if (tabRef.current) {
|
||||
const x = currentTab > 0 ? tabPositions[currentTab - 1] + tabWidths[currentTab - 1] : 0
|
||||
const x = currentTab > 0 ? tabPositions[currentTab - 1]! + tabWidths[currentTab - 1]! : 0
|
||||
|
||||
const isCurrentTabVisible =
|
||||
sharedPagerOffsetX.value < tabPositions[currentTab] &&
|
||||
sharedPagerOffsetX.value + tabWidths[currentTab] > tabPositions[currentTab]
|
||||
sharedPagerOffsetX.value < tabPositions[currentTab]! &&
|
||||
sharedPagerOffsetX.value + tabWidths[currentTab]! > tabPositions[currentTab]!
|
||||
|
||||
if (!isCurrentTabVisible) {
|
||||
tabRef.current.scrollTo({ x, y: 0, animated: true })
|
||||
@@ -146,17 +146,17 @@ export const TabBar = forwardRef<ScrollView, TabBarProps>(
|
||||
|
||||
// Interpolate between current and next tab positions
|
||||
const xPosition =
|
||||
tabPositions[currentIndex] +
|
||||
(tabPositions[nextIndex] - tabPositions[currentIndex]) * progress
|
||||
tabPositions[currentIndex]! +
|
||||
(tabPositions[nextIndex]! - tabPositions[currentIndex]!) * progress
|
||||
|
||||
// Interpolate between current and next tab widths
|
||||
const width =
|
||||
tabWidths[currentIndex] + (tabWidths[nextIndex] - tabWidths[currentIndex]) * progress
|
||||
tabWidths[currentIndex]! + (tabWidths[nextIndex]! - tabWidths[currentIndex]!) * progress
|
||||
|
||||
return {
|
||||
transform: [{ translateX: Math.max(xPosition, 0) }],
|
||||
width,
|
||||
backgroundColor: tabs[currentTab].activeColor || accentColor,
|
||||
backgroundColor: tabs[currentTab]!.activeColor || accentColor,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -64,14 +64,14 @@ export class ToastManager {
|
||||
}
|
||||
|
||||
private scheduleDismiss(index: number) {
|
||||
const props = this.propsMap[index]
|
||||
const props = this.propsMap[index]!
|
||||
|
||||
if (props.duration === Infinity) {
|
||||
return
|
||||
}
|
||||
|
||||
setTimeout(async () => {
|
||||
await this.toastRefs[index].dimiss()
|
||||
await this.toastRefs[index]!.dimiss()
|
||||
this.remove(index)
|
||||
}, props.duration)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export const RecommendationListItem: FC<{
|
||||
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))
|
||||
}
|
||||
@@ -120,7 +120,7 @@ export const RecommendationListItem: FC<{
|
||||
/>
|
||||
<View className="absolute inset-2 items-center justify-center" pointerEvents="none">
|
||||
<Text ellipsizeMode="middle" numberOfLines={1} className="text-text whitespace-pre">
|
||||
{data.routes[route].name}
|
||||
{data.routes[route]!.name}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -75,11 +75,11 @@ const Tab: TabComponent = ({ tab, ...rest }) => {
|
||||
return []
|
||||
}
|
||||
return Object.keys(data).sort((a, b) => {
|
||||
const aname = data[a].name
|
||||
const bname = data[b].name
|
||||
const aname = data[a]!.name
|
||||
const bname = data[b]!.name
|
||||
|
||||
const aRouteName = data[a].routes[Object.keys(data[a].routes)[0]].name
|
||||
const bRouteName = data[b].routes[Object.keys(data[b].routes)[0]].name
|
||||
const aRouteName = data[a]!.routes[Object.keys(data[a]!.routes)[0]!]!.name
|
||||
const bRouteName = data[b]!.routes[Object.keys(data[b]!.routes)[0]!]!.name
|
||||
|
||||
const ia = isASCII(aname) && isASCII(aRouteName)
|
||||
const ib = isASCII(bname) && isASCII(bRouteName)
|
||||
@@ -98,7 +98,7 @@ const Tab: TabComponent = ({ tab, ...rest }) => {
|
||||
const groups = keys.reduce(
|
||||
(acc, key) => {
|
||||
// A-Z -> A-Z, 0-9 -> #, other -> #, # push to the end
|
||||
const firstChar = key[0].toUpperCase()
|
||||
const firstChar = key[0]!.toUpperCase()
|
||||
if (/[A-Z]/.test(firstChar)) {
|
||||
acc[firstChar] = acc[firstChar] || []
|
||||
acc[firstChar].push(key)
|
||||
@@ -127,7 +127,7 @@ const Tab: TabComponent = ({ tab, ...rest }) => {
|
||||
if (!data) {
|
||||
continue
|
||||
}
|
||||
result.push({ key: item, data: data[item] })
|
||||
result.push({ key: item, data: data[item]! })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ const NavigationSidebar: FC<{
|
||||
(letter: string, animated = true) => {
|
||||
const index = alphabetGroups.findIndex((group) => {
|
||||
if (typeof group !== "string") return false
|
||||
const firstChar = group[0].toUpperCase()
|
||||
const firstChar = group[0]!.toUpperCase()
|
||||
const firstCharIsAlphabet = /[A-Z]/.test(firstChar)
|
||||
if (firstCharIsAlphabet) {
|
||||
return firstChar === letter
|
||||
@@ -233,7 +233,7 @@ const NavigationSidebar: FC<{
|
||||
return
|
||||
}
|
||||
|
||||
const firstChar = letter[0].toUpperCase()
|
||||
const firstChar = letter[0]!.toUpperCase()
|
||||
const firstCharIsAlphabet = /[A-Z]/.test(firstChar)
|
||||
if (firstCharIsAlphabet) {
|
||||
scrollToLetter(letter, false)
|
||||
|
||||
@@ -20,7 +20,7 @@ export const SearchTabBar: FC<{
|
||||
tabs={SearchTabs}
|
||||
currentTab={SearchTabs.findIndex((tab) => tab.value === searchType)}
|
||||
onTabItemPress={(index) => {
|
||||
setSearchType(SearchTabs[index].value as SearchType)
|
||||
setSearchType(SearchTabs[index]!.value as SearchType)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -199,7 +199,7 @@ const CategoryGrouped = memo(
|
||||
const SubscriptionItem = memo(({ id, className }: { id: string; className?: string }) => {
|
||||
const subscription = useSubscription(id)
|
||||
const unreadCount = useUnreadCount(id)
|
||||
const feed = useFeed(id)
|
||||
const feed = useFeed(id)!
|
||||
const inGrouped = !!useContext(GroupedContext)
|
||||
const view = useCurrentView()
|
||||
const { isLoading } = usePrefetchFeed(id, { enabled: !feed })
|
||||
|
||||
@@ -50,7 +50,7 @@ export function FollowFeed(props: { id: string }) {
|
||||
function FollowImpl() {
|
||||
const { id } = useLocalSearchParams()
|
||||
|
||||
const feed = useFeed(id as string)
|
||||
const feed = useFeed(id as string)!
|
||||
const isSubscribed = useSubscriptionByFeedId(feed?.id || "")
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
|
||||
@@ -96,7 +96,7 @@ const TeamsCheckBox = forwardRef<
|
||||
const runAnimation = (index: number) => {
|
||||
"worklet"
|
||||
if (index < animations.length) {
|
||||
shakeSharedValue.value = withTiming(animations[index], { duration: 100 }, () => {
|
||||
shakeSharedValue.value = withTiming(animations[index]!, { duration: 100 }, () => {
|
||||
runAnimation(index + 1)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export function SocialLogin() {
|
||||
{Object.keys(provider)
|
||||
.filter((key) => key !== "apple" || (Platform.OS === "ios" && key === "apple"))
|
||||
.map((key) => {
|
||||
const providerInfo = provider[key]
|
||||
const providerInfo = provider[key]!
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={key}
|
||||
|
||||
@@ -38,11 +38,11 @@ export const ViewTab = () => {
|
||||
indicatorPosition.value = withSpring(tabPositions[currentView] || 0, springConfig)
|
||||
|
||||
if (tabRef.current) {
|
||||
const x = currentView > 0 ? tabPositions[currentView - 1] + tabWidths[currentView - 1] : 0
|
||||
const x = currentView > 0 ? tabPositions[currentView - 1]! + tabWidths[currentView - 1]! : 0
|
||||
|
||||
const isCurrentTabVisible =
|
||||
scrollOffsetX.current < tabPositions[currentView] &&
|
||||
scrollOffsetX.current + tabWidths[currentView] > tabPositions[currentView]
|
||||
scrollOffsetX.current < tabPositions[currentView]! &&
|
||||
scrollOffsetX.current + tabWidths[currentView]! > tabPositions[currentView]!
|
||||
|
||||
if (!isCurrentTabVisible) {
|
||||
tabRef.current.scrollTo({ x, y: 0, animated: true })
|
||||
@@ -58,7 +58,7 @@ export const ViewTab = () => {
|
||||
translateX: indicatorPosition.value + 10 + Math.abs(offset),
|
||||
},
|
||||
],
|
||||
backgroundColor: views[currentView].activeColor,
|
||||
backgroundColor: views[currentView]!.activeColor,
|
||||
width: (tabWidths[currentView] || 20) - 40 + Math.abs(offset),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@ import { GroupedContext, useViewPageCurrentView } from "../ctx"
|
||||
export const SubscriptionItem = memo(({ id, className }: { id: string; className?: string }) => {
|
||||
const subscription = useSubscription(id)
|
||||
const unreadCount = useUnreadCount(id)
|
||||
const feed = useFeed(id)
|
||||
const feed = useFeed(id)!
|
||||
const inGrouped = !!useContext(GroupedContext)
|
||||
const view = useViewPageCurrentView()
|
||||
const { isLoading } = usePrefetchFeed(id, { enabled: !subscription && !feed })
|
||||
|
||||
@@ -10,6 +10,7 @@ export default function Add() {
|
||||
const [url, setUrl] = useState("")
|
||||
|
||||
const label = useColor("label")
|
||||
// @ts-expect-error FIXME: use the right color
|
||||
const disabled = useColor("disabled")
|
||||
return (
|
||||
<View>
|
||||
|
||||
@@ -55,7 +55,7 @@ export default function RsshubForm() {
|
||||
if (!parsedRoute || !routePrefix) {
|
||||
return null
|
||||
}
|
||||
return <FormImpl route={parsedRoute} routePrefix={routePrefix as string} name={name} />
|
||||
return <FormImpl route={parsedRoute} routePrefix={routePrefix as string} name={name!} />
|
||||
}
|
||||
|
||||
function FormImpl({ route, routePrefix, name }: RsshubFormParams) {
|
||||
@@ -98,7 +98,7 @@ function FormImpl({ route, routePrefix, name }: RsshubFormParams) {
|
||||
const ret = {} as Record<string, string | null>
|
||||
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
|
||||
}
|
||||
@@ -128,7 +128,7 @@ function FormImpl({ route, routePrefix, name }: RsshubFormParams) {
|
||||
>
|
||||
<View className="bg-secondary-system-grouped-background mx-2 mt-2 gap-4 rounded-lg px-3 py-6">
|
||||
{keys.map((keyItem) => {
|
||||
const parameters = normalizeRSSHubParameters(route.parameters[keyItem.name])
|
||||
const parameters = normalizeRSSHubParameters(route.parameters[keyItem.name]!)
|
||||
|
||||
return (
|
||||
<View key={keyItem.name}>
|
||||
|
||||
@@ -29,7 +29,7 @@ export default function Index() {
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerShown: true,
|
||||
title: views[currentView].name,
|
||||
title: views[currentView]!.name,
|
||||
headerLeft: LeftAction,
|
||||
headerRight: RightAction,
|
||||
headerTransparent: true,
|
||||
|
||||
@@ -20,7 +20,7 @@ export const getSubscriptionByCategory = (category: string): string[] => {
|
||||
|
||||
const ids = [] as string[]
|
||||
for (const id of Object.keys(state.data)) {
|
||||
if (state.data[id].category === category) {
|
||||
if (state.data[id]!.category === category) {
|
||||
ids.push(id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ export const useSortedGroupedSubscription = (
|
||||
})
|
||||
const sortedList = [] as { category: string; subscriptionIds: string[] }[]
|
||||
for (const category of sortedCategories) {
|
||||
sortedList.push({ category, subscriptionIds: grouped[category] })
|
||||
sortedList.push({ category, subscriptionIds: grouped[category]! })
|
||||
}
|
||||
return sortedList
|
||||
}, [grouped, sortBy, sortOrder]),
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
"extends": "expo/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
},
|
||||
|
||||
@@ -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])
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user