pref: use `slice` instead of `replace`
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
d4db563761
commit
485d2d5d35
|
|
@ -15,3 +15,5 @@ export const ROUTE_FEED_IN_INBOX = "inbox-"
|
|||
|
||||
export const DAILY_CLAIM_AMOUNT = "20"
|
||||
export const INVITATION_PRICE = "100"
|
||||
|
||||
export const INBOX_PREFIX_ID = "inbox-"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ function nestPaths(paths: string[]): NestedStructure {
|
|||
|
||||
paths.forEach((path) => {
|
||||
// Remove the './pages' prefix and the '.tsx' suffix
|
||||
const trimmedPath = path.replace("./pages/", "").replace(".tsx", "")
|
||||
const prefix = "./pages/"
|
||||
const suffix = ".tsx"
|
||||
const trimmedPath = path.slice(prefix.length, -suffix.length)
|
||||
|
||||
const parts = trimmedPath.split("/")
|
||||
|
||||
let currentLevel = result
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export function ListItem({
|
|||
const isSubscription =
|
||||
withFollow && entry?.entries.url?.startsWith(UrlBuilder.shareFeed(entry.feedId))
|
||||
const feedId = isSubscription
|
||||
? entry?.entries.url?.replace(UrlBuilder.shareFeed(entry.feedId), "")
|
||||
? entry?.entries.url?.slice(UrlBuilder.shareFeed(entry.feedId).length)
|
||||
: undefined
|
||||
const isFollowed = !!useSubscriptionStore((state) => feedId && state.data[feedId])
|
||||
const { present } = useModalStack()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Fragment } from "react"
|
||||
|
||||
import { INBOX_PREFIX_ID } from "~/constants"
|
||||
import { sortByAlphabet } from "~/lib/utils"
|
||||
import { getPreferredTitle, useFeedStore } from "~/store/feed"
|
||||
import { getSubscriptionByFeedId } from "~/store/subscription"
|
||||
|
|
@ -76,7 +77,13 @@ export const SortByAlphabeticalInboxList = ({ view, data }: ListListProps) => {
|
|||
return (
|
||||
<div>
|
||||
{Object.keys(data).map((feedId) => (
|
||||
<InboxItem key={feedId} inboxId={feedId.replace("inbox-", "")} view={view} />
|
||||
<InboxItem
|
||||
key={feedId}
|
||||
inboxId={
|
||||
feedId.startsWith(INBOX_PREFIX_ID) ? feedId.slice(INBOX_PREFIX_ID.length) : feedId
|
||||
}
|
||||
view={view}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,16 @@ function getSettings() {
|
|||
loader: () => SettingPageConfig
|
||||
}[]
|
||||
for (const path in map) {
|
||||
const p = path.split("/").pop()?.replace(".tsx", "").replace("(settings)", "")!
|
||||
const prefix = "(settings)"
|
||||
const postfix = ".tsx"
|
||||
const lastItem = path.split("/").pop()
|
||||
|
||||
if (!lastItem) continue
|
||||
let p = lastItem.slice(0, -postfix.length)
|
||||
|
||||
if (p.includes(prefix)) {
|
||||
p = p.replace(prefix, "")
|
||||
}
|
||||
|
||||
if (p === "index" || p === "layout") continue
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue