Merge remote-tracking branch 'origin/dev' into feat/beta-public

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2024-10-11 14:47:44 +08:00
125 changed files with 2186 additions and 1480 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
node-version: [18.x]
node-version: [lts/*]
steps:
- name: Checkout code
uses: actions/checkout@v4
+3 -1
View File
@@ -102,8 +102,10 @@ jobs:
# Update version in package.json
if [[ "$RUNNER_OS" == "Windows" ]]; then
sed -i "s/\"version\": \".*\"/\"version\": \"$NIGHTLY_VERSION\"/" package.json
else
elif [[ "$RUNNER_OS" == "macOS" ]]; then
sed -i '' "s/\"version\": \".*\"/\"version\": \"$NIGHTLY_VERSION\"/" package.json
else
sed -i "s/\"version\": \".*\"/\"version\": \"$NIGHTLY_VERSION\"/" package.json
fi
echo "Updated version to $NIGHTLY_VERSION"
+5 -1
View File
@@ -53,7 +53,11 @@
{
"rule": "unused-imports/no-unused-imports",
"severity": "off"
}
},
{ "rule": "@typescript-eslint/require-await", "severity": "info" },
{ "rule": "@typescript-eslint/await-thenable", "severity": "info" },
{ "rule": "@typescript-eslint/no-floating-promises", "severity": "info" },
{ "rule": "@typescript-eslint/no-misused-promises", "severity": "info" }
],
"cSpell.words": ["Hydable", "rsshub", "Русский"],
"editor.foldingImportsByDefault": true,
+23 -3
View File
@@ -1,4 +1,5 @@
import { electronApp, optimizer } from "@electron-toolkit/utils"
import { callWindowExpose } from "@follow/shared/bridge"
import { APP_PROTOCOL } from "@follow/shared/constants"
import { env } from "@follow/shared/env"
import { app, BrowserWindow, session } from "electron"
@@ -8,9 +9,10 @@ import { isDev, isMacOS } from "./env"
import { initializeAppStage0, initializeAppStage1 } from "./init"
import { updateProxy } from "./lib/proxy"
import { handleUrlRouting } from "./lib/router"
import { setAuthSessionToken } from "./lib/user"
import { store } from "./lib/store"
import { setAuthSessionToken, updateNotificationsToken } from "./lib/user"
import { registerUpdater } from "./updater"
import { createMainWindow } from "./window"
import { createMainWindow, getMainWindow, windowStateStoreKey } from "./window"
if (isDev) console.info("[main] env loaded:", env)
@@ -115,13 +117,28 @@ function bootstrap() {
}
})
const handleOpen = (url: string) => {
app.on("before-quit", () => {
// store window pos when before app quit
const window = getMainWindow()
if (!window) return
const bounds = window.getBounds()
store.set(windowStateStoreKey, {
width: bounds.width,
height: bounds.height,
x: bounds.x,
y: bounds.y,
})
})
const handleOpen = async (url: string) => {
const isValid = URL.canParse(url)
if (!isValid) return
const urlObj = new URL(url)
if (urlObj.hostname === "auth" || urlObj.pathname === "//auth") {
const token = urlObj.searchParams.get("token")
const userId = urlObj.searchParams.get("userId")
const apiURL = process.env["VITE_API_URL"] || import.meta.env.VITE_API_URL
if (token && apiURL) {
@@ -135,7 +152,10 @@ function bootstrap() {
domain: new URL(apiURL).hostname,
sameSite: "no_restriction",
})
userId && (await callWindowExpose(mainWindow).clearIfLoginOtherAccount(userId))
mainWindow.reload()
updateNotificationsToken()
}
} else {
handleUrlRouting(url)
+16 -17
View File
@@ -9,9 +9,9 @@ import { app, nativeTheme, Notification, shell } from "electron"
import contextMenu from "electron-context-menu"
import { getIconPath } from "./helper"
import { apiClient } from "./lib/api-client"
import { t } from "./lib/i18n"
import { store } from "./lib/store"
import { updateNotificationsToken } from "./lib/user"
import { registerAppMenu } from "./menu"
import type { RendererHandlers } from "./renderer-handlers"
import { initializeSentry } from "./sentry"
@@ -78,7 +78,7 @@ export const registerMenuAndContextMenu = () => {
showCopyImageAddress: true,
showCopyImage: true,
showInspectElement: isDev,
showSelectAll: false,
showSelectAll: true,
showCopyVideoAddress: true,
showSaveVideoAs: true,
@@ -119,6 +119,18 @@ export const registerMenuAndContextMenu = () => {
shell.openExternal(params.linkURL)
},
},
{
role: "undo",
label: t("menu.undo"),
accelerator: "CmdOrCtrl+Z",
visible: params.isEditable,
},
{
role: "redo",
label: t("menu.redo"),
accelerator: "CmdOrCtrl+Shift+Z",
visible: params.isEditable,
},
]
},
})
@@ -134,14 +146,7 @@ const registerPushNotifications = async () => {
const credentials = store.get(credentialsKey)
const persistentIds = store.get(persistentIdsKey)
if (credentials) {
apiClient.messaging.$post({
json: {
token: credentials.fcm.token,
channel: "desktop",
},
})
}
updateNotificationsToken()
const instance = new PushReceiver({
debug: isDev,
@@ -151,13 +156,7 @@ const registerPushNotifications = async () => {
})
instance.onCredentialsChanged(({ newCredentials }) => {
store.set(credentialsKey, newCredentials)
apiClient.messaging.$post({
json: {
token: newCredentials.fcm.token,
channel: "desktop",
},
})
updateNotificationsToken(newCredentials)
})
instance.onNotification((notification) => {
-69
View File
@@ -1,69 +0,0 @@
import type { BrowserWindow } from "electron"
import { clipboard, Menu } from "electron"
import { t } from "./i18n"
export const registerContextMenu = (window: BrowserWindow) => {
const handler = (_event: Electron.Event, props: Electron.ContextMenuParams) => {
const { selectionText, isEditable, linkURL } = props
if (isEditable) {
const inputMenu = Menu.buildFromTemplate([
{ role: "undo", label: t("menu.undo"), accelerator: "CmdOrCtrl+Z" },
{
role: "redo",
label: t("menu.redo"),
accelerator: "CmdOrCtrl+Shift+Z",
},
{ type: "separator" },
{
role: "cut",
label: t("menu.cut"),
accelerator: "CmdOrCtrl+X",
},
{
role: "copy",
label: t("menu.copy"),
accelerator: "CmdOrCtrl+C",
},
{
role: "paste",
label: t("menu.paste"),
accelerator: "CmdOrCtrl+V",
},
{
type: "separator",
},
{ role: "selectAll", label: t("menu.selectAll"), accelerator: "CmdOrCtrl+A" },
])
inputMenu.popup({
window,
})
} else if (linkURL) {
const linkMenu = Menu.buildFromTemplate([
{ role: "copy", label: t("menu.copy"), accelerator: "CmdOrCtrl+C" },
// Copy link
{
label: t("contextMenu.copyLink"),
accelerator: "CmdOrCtrl+Shift+C",
click: () => {
clipboard.writeText(linkURL)
},
},
])
linkMenu.popup({ window })
} else if (selectionText && selectionText.trim() !== "") {
const selectionMenu = Menu.buildFromTemplate([
{ role: "copy", label: t("menu.copy"), accelerator: "CmdOrCtrl+C" },
{ type: "separator" },
{ role: "selectAll", label: t("menu.selectAll"), accelerator: "CmdOrCtrl+A" },
])
selectionMenu.popup({ window })
}
}
window.webContents.on("context-menu", handler)
return () => {
window.webContents.removeListener("context-menu", handler)
}
}
+1 -5
View File
@@ -6,11 +6,7 @@ export const setDockCount = (input: number) => {
// TODO use Electron Overlay API
if (isWindows) return
if (app.dock) {
if (input === 0) {
app.dock.setBadge("")
} else {
app.dock.setBadge(input.toString())
}
app.dock.setBadge(input === 0 ? "" : input < 10000 ? input.toString() : "9999+")
} else {
app.setBadgeCount(input)
}
-2
View File
@@ -10,8 +10,6 @@ export const initPosthog = () => {
}
export const posthog = initPosthog()
// posthog?.debug(true)
export const trackEvent = (event: string, properties?: Record<string, any>) => {
const userId = getUser()?.id
if (!userId) return
+17
View File
@@ -1,5 +1,7 @@
import type { User } from "@auth/core/types"
import type { Credentials } from "@eneris/push-receiver/dist/types"
import { apiClient } from "./api-client"
import { store } from "./store"
const AuthKey = "authSessionToken"
@@ -15,3 +17,18 @@ export const getUser = (): User | null => {
}
export const cleanUser = () => store.set(UserKey, null)
export const updateNotificationsToken = async (newCredentials?: Credentials) => {
if (newCredentials) {
store.set("notifications-credentials", newCredentials)
}
const credentials = newCredentials || store.get("notifications-credentials")
if (credentials?.fcm?.token) {
await apiClient.messaging.$post({
json: {
token: credentials.fcm.token,
channel: "desktop",
},
})
}
}
@@ -0,0 +1,115 @@
// @see https://github.dev/microsoft/vscode/blob/main/src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts
import { createRequire } from "node:module"
import type { ModelResult } from "vscode-languagedetection"
import type vsld from "vscode-languagedetection"
import { logger } from "~/logger"
const expectedRelativeConfidence = 0.1
const positiveConfidenceCorrectionBucket1 = 0.05
const positiveConfidenceCorrectionBucket2 = 0.025
const negativeConfidenceCorrection = 0.5
const adjustLanguageConfidence = (modelResult: vsld.ModelResult): vsld.ModelResult => {
switch (modelResult.languageId) {
// For the following languages, we increase the confidence because
// these are commonly used languages in VS Code and supported
// by the model.
case "js":
case "html":
case "json":
case "ts":
case "css":
case "py":
case "xml":
case "php": {
modelResult.confidence += positiveConfidenceCorrectionBucket1
break
}
// case 'yaml': // YAML has been know to cause incorrect language detection because the language is pretty simple. We don't want to increase the confidence for this.
case "cpp":
case "sh":
case "java":
case "cs":
case "c": {
modelResult.confidence += positiveConfidenceCorrectionBucket2
break
}
// For the following languages, we need to be extra confident that the language is correct because
// we've had issues like #131912 that caused incorrect guesses. To enforce this, we subtract the
// negativeConfidenceCorrection from the confidence.
// languages that are provided by default in VS Code
case "bat":
case "ini":
case "makefile":
case "sql":
case "csv":
case "toml": {
// Other considerations for negativeConfidenceCorrection that
// aren't built in but suportted by the model include:
// * Assembly, TeX - These languages didn't have clear language modes in the community
// * Markdown, Dockerfile - These languages are simple but they embed other languages
modelResult.confidence -= negativeConfidenceCorrection
break
}
default: {
break
}
}
return modelResult
}
const require = createRequire(import.meta.url)
export const detectCodeStringLanguage = async function* (codeString: string) {
const { ModelOperations } =
require("vscode-languagedetection") as typeof import("vscode-languagedetection")
const modelOperations = new ModelOperations()
const modelResults = await modelOperations.runModel(codeString)
if (modelResults.length === 0) {
logger.debug("no model results", codeString)
return
}
const firstModelResult = adjustLanguageConfidence(modelResults[0])
if (firstModelResult.confidence < expectedRelativeConfidence) {
logger.debug("first model result confidence is less than expected relative confidence")
return
}
const possibleLanguages: ModelResult[] = [firstModelResult]
for (let current of modelResults) {
if (current === firstModelResult) {
continue
}
current = adjustLanguageConfidence(current)
const currentHighest = possibleLanguages.at(-1)
if (!currentHighest) {
logger.debug("no current highest")
continue
}
if (currentHighest.confidence - current.confidence >= expectedRelativeConfidence) {
while (possibleLanguages.length > 0) {
yield possibleLanguages.shift()!
}
if (current.confidence > expectedRelativeConfidence) {
possibleLanguages.push(current)
continue
}
return
} else {
if (current.confidence > expectedRelativeConfidence) {
possibleLanguages.push(current)
continue
}
return
}
}
return possibleLanguages
}
+20 -8
View File
@@ -1,15 +1,16 @@
import fs from "node:fs"
import { createRequire } from "node:module"
import path from "node:path"
import { callWindowExpose } from "@follow/shared/bridge"
import { app, BrowserWindow } from "electron"
import { MsEdgeTTS, OUTPUT_FORMAT } from "msedge-tts"
import type { ModelResult } from "vscode-languagedetection"
import { detectCodeStringLanguage } from "~/modules/language-detection"
import { readability } from "../lib/readability"
import { t } from "./_instance"
const require = createRequire(import.meta.url)
const tts = new MsEdgeTTS()
export const readerRoute = {
@@ -54,7 +55,7 @@ export const readerRoute = {
if (!window) {
return
}
callWindowExpose(window).toast.error(error.message, {
void callWindowExpose(window).toast.error(error.message, {
duration: 1000,
})
}
@@ -67,7 +68,7 @@ export const readerRoute = {
}
await tts.setMetadata(input, OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS).catch((error) => {
callWindowExpose(window).toast.error(error.message, {
return callWindowExpose(window).toast.error(error.message, {
duration: 1000,
})
})
@@ -76,9 +77,20 @@ export const readerRoute = {
detectCodeStringLanguage: t.procedure
.input<{ codeString: string }>()
.action(async ({ input }) => {
const { ModelOperations } = require("vscode-languagedetection")
const modelOperations = new ModelOperations()
const result = await modelOperations.runModel(input.codeString)
return result
const { codeString } = input
const languages = detectCodeStringLanguage(codeString)
let finalLanguage: ModelResult | undefined
for await (const language of languages) {
if (!finalLanguage) {
finalLanguage = language
continue
}
if (language.confidence > finalLanguage.confidence) {
finalLanguage = language
}
}
return finalLanguage
}),
}
+8 -9
View File
@@ -9,7 +9,6 @@ import { BrowserWindow, screen, shell } from "electron"
import { isDev, isMacOS, isWindows, isWindows11 } from "./env"
import { getIconPath } from "./helper"
import { registerContextMenu } from "./lib/context-menu"
import { store } from "./lib/store"
import { logger } from "./logger"
import { cancelPollingUpdateUnreadCount, pollingUpdateUnreadCount } from "./tipc/dock"
@@ -141,11 +140,13 @@ export function createWindow(
// Make it consistent with Chrome on Windows, instead of SimSun.
// ref: [[Feature Request]: Add possibility to change DevTools font · Issue #42055 · electron/electron](https://github.com/electron/electron/issues/42055)
window.webContents.on("devtools-opened", () => {
// source-code-font: For code such as Elements panel
// monospace-font: For sidebar such as Event Listener Panel
const css = `
:root {
--source-code-font-family: consolas; // For code such as Elements panel
--source-code-font-family: consolas;
--source-code-font-size: 13px;
--monospace-font-family: consolas; // For sidebar such as Event Listener Panel
--monospace-font-family: consolas;
--monospace-font-size: 13px;
}`
window.webContents.devToolsWebContents?.executeJavaScript(`
@@ -157,13 +158,11 @@ export function createWindow(
})
}
registerContextMenu(window)
return window
}
export const windowStateStoreKey = "windowState"
export const createMainWindow = () => {
const storeKey = "windowState"
const windowState = store.get(storeKey) as {
const windowState = store.get(windowStateStoreKey) as {
height: number
width: number
x: number
@@ -201,7 +200,7 @@ export const createMainWindow = () => {
const windowStoreKey = Symbol.for("maximized")
if (window[windowStoreKey]) {
const stored = window[windowStoreKey]
store.set(storeKey, {
store.set(windowStateStoreKey, {
width: stored.size[0],
height: stored.size[1],
x: stored.position[0],
@@ -213,7 +212,7 @@ export const createMainWindow = () => {
}
const bounds = window.getBounds()
store.set(storeKey, {
store.set(windowStateStoreKey, {
width: bounds.width,
height: bounds.height,
x: bounds.x,
+1
View File
@@ -99,6 +99,7 @@
"sonner": "^1.5.0",
"swiper": "11.1.14",
"tailwind-merge": "2.5.2",
"tailwindcss-motion": "0.3.0-beta",
"tldts": "6.1.48",
"unified": "11.0.5",
"use-context-selector": "2.0.0",
+6
View File
@@ -2,6 +2,7 @@ import { noop } from "foxact/noop"
import { atomWithStorage, createJSONStorage } from "jotai/utils"
import type { SyncStorage } from "jotai/vanilla/utils/atomWithStorage"
import { getRouteParams } from "~/hooks/biz/useRouteParams"
import { createAtomHooks } from "~/lib/jotai"
import { getStorageNS } from "~/lib/ns"
@@ -16,6 +17,8 @@ type PlayerAtomValue = {
isMute?: boolean
volume?: number
playbackRate?: number
/** the listId from the route to indicate that the audio is triggered from a list */
listId?: string
}
const playerInitialValue: PlayerAtomValue = {
@@ -66,11 +69,14 @@ export const AudioPlayer = {
return
}
const routeParams = getRouteParams()
setAudioPlayerAtomValue({
...curV,
...v,
status: "loading",
show: true,
listId: routeParams.listId,
})
if (this.audio.src !== v.src) {
+1 -1
View File
@@ -9,9 +9,9 @@ import { whoami } from "~/atoms/user"
import { cn } from "~/lib/utils"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { UserAvatar } from "../modules/user/UserAvatar"
import { FollowIcon } from "./icons/follow"
import { Logo } from "./icons/logo"
import { UserAvatar } from "./user-button"
const useMotionValueToState = (value: MotionValue<number>) => {
const [state, setState] = useState(value.get())
@@ -1,17 +0,0 @@
import type { SVGProps } from "react"
import React from "react"
export function IconoirBrightCrown(props: SVGProps<SVGSVGElement>) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
<path
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
d="M22 12h1M12 2V1m0 22v-1m8-2l-1-1m1-15l-1 1M4 20l1-1M4 4l1 1m-4 7h1m14.8 3.5l1.2-7l-4.2 2.1L12 8.5l-1.8 2.1L6 8.5l1.2 7z"
/>
</svg>
)
}
@@ -80,6 +80,7 @@ export const Autocomplete = forwardRef<HTMLInputElement, AutocompleteProps>(
<ComboboxInput
ref={forwardedRef}
as={Input}
autoComplete="off"
aria-label="Select Category"
displayValue={renderSuggestion}
value={value}
@@ -56,12 +56,12 @@ export const ShikiHighLighter: FC<ShikiProps> = (props) => {
}
function guessLanguage() {
tipcClient?.detectCodeStringLanguage({ codeString: code }).then((result) => {
for (const item of result) {
if (bundledLanguagesKeysSet?.has(item.languageId)) {
setCurrentLanguage(item.languageId)
break
}
return tipcClient?.detectCodeStringLanguage({ codeString: code }).then((result) => {
if (!result) {
return
}
if (bundledLanguagesKeysSet?.has(result.languageId)) {
setCurrentLanguage(result.languageId)
}
})
}
@@ -99,7 +99,7 @@ const ContextMenuCheckboxItem = React.forwardRef<
<ContextMenuPrimitive.CheckboxItem
ref={ref}
className={cn(
"relative flex cursor-checkbox select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-theme-item-hover focus:text-theme-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
"relative flex cursor-checkbox select-none items-center rounded-sm px-8 py-1.5 text-sm outline-none focus:bg-theme-item-hover focus:text-theme-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
"focus-within:outline-transparent",
className,
)}
@@ -1,9 +1,26 @@
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
import * as React from "react"
import { useHotkeyScope, useTypeScriptHappyCallback } from "~/hooks/common"
import { cn } from "~/lib/utils"
const DropdownMenu = DropdownMenuPrimitive.Root
const DropdownMenu: typeof DropdownMenuPrimitive.Root = (props) => {
const [open, setOpen] = React.useState(!!props.open)
useHotkeyScope("DropdownMenu", open)
return (
<DropdownMenuPrimitive.Root
{...props}
onOpenChange={useTypeScriptHappyCallback(
(open) => {
setOpen(open)
props.onOpenChange?.(open)
},
[props.onOpenChange],
)}
/>
)
}
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
@@ -54,20 +71,22 @@ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayNam
const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"shadow-context-menu z-50 min-w-32 overflow-hidden rounded-md border bg-theme-background p-1 text-theme-foreground",
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
/>
</DropdownMenuPrimitive.Portal>
))
>(({ className, sideOffset = 4, ...props }, ref) => {
return (
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"shadow-context-menu z-50 min-w-32 overflow-hidden rounded-md border bg-theme-background p-1 text-theme-foreground",
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
/>
</DropdownMenuPrimitive.Portal>
)
})
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
const DropdownMenuItem = React.forwardRef<
@@ -76,7 +95,7 @@ const DropdownMenuItem = React.forwardRef<
inset?: boolean
icon?: React.ReactNode
}
>(({ className, inset, ...props }, ref) => (
>(({ className, inset, icon, ...props }, ref) => (
<DropdownMenuPrimitive.Item
ref={ref}
className={cn(
@@ -87,12 +106,12 @@ const DropdownMenuItem = React.forwardRef<
)}
{...props}
>
{props.icon && (
<span className="mr-1.5 inline-flex size-4 items-center justify-center">{props.icon}</span>
{!!icon && (
<span className="mr-1.5 inline-flex size-4 items-center justify-center">{icon}</span>
)}
{props.children}
{/* Justify Fill */}
{props.icon && <span className="ml-1.5 size-4" />}
{!!icon && <span className="ml-1.5 size-4" />}
</DropdownMenuPrimitive.Item>
))
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
@@ -1,4 +1,4 @@
import { createElement, Fragment, memo, useEffect, useMemo, useState } from "react"
import { createElement, Fragment, memo, useEffect, useMemo, useRef, useState } from "react"
import { parseHtml } from "~/lib/parse-html"
import type { RemarkOptions } from "~/lib/parse-markdown"
@@ -46,12 +46,23 @@ const HTMLImpl = <A extends keyof JSX.IntrinsicElements = "div">(
accessory?: React.ReactNode
noMedia?: boolean
mediaInfo?: MediaInfoRecord
translate?: (html: HTMLElement | null) => void
} & JSX.IntrinsicElements[A] &
Partial<{
renderInlineStyle: boolean
}>,
) => {
const { children, renderInlineStyle, as = "div", accessory, noMedia, mediaInfo, ...rest } = props
const {
children,
renderInlineStyle,
as = "div",
accessory,
noMedia,
mediaInfo,
translate,
...rest
} = props
const [remarkOptions, setRemarkOptions] = useState({
renderInlineStyle,
noMedia,
@@ -71,6 +82,16 @@ const HTMLImpl = <A extends keyof JSX.IntrinsicElements = "div">(
const [refElement, setRefElement] = useState<HTMLElement | null>(null)
const onceRef = useRef(false)
useEffect(() => {
if (onceRef.current || !refElement) {
return
}
translate?.(refElement)
onceRef.current = true
}, [translate, refElement])
const markdownElement = useMemo(
() =>
children &&
@@ -90,7 +111,7 @@ const HTMLImpl = <A extends keyof JSX.IntrinsicElements = "div">(
{createElement(as, { ...rest, ref: setRefElement }, markdownElement)}
</MediaInfoRecordProvider>
</MediaContainerWidthProvider>
{accessory && <Fragment key={shouldForceReMountKey}>{accessory}</Fragment>}
{!!accessory && <Fragment key={shouldForceReMountKey}>{accessory}</Fragment>}
</MarkdownRenderContainerRefContext.Provider>
)
}
@@ -46,9 +46,9 @@ const Wrapper: Component<{
)}
>
{children}
<RootPortal>
<RootPortal to={entryId ? null : undefined}>
<div
className="pointer-events-auto fixed bottom-4 right-4 z-[99] flex gap-3 text-white/70 [&_button]:hover:text-white"
className="pointer-events-auto absolute bottom-4 right-4 z-[99] flex gap-3 text-white/70 [&_button]:hover:text-white"
onClick={stopPropagation}
>
{showActions && (
@@ -375,7 +375,7 @@ export const ModalInternal = memo(
onPointerDown={relocateModal}
>
<Dialog.Title className="flex w-0 max-w-full grow items-center gap-2 px-4 py-1 text-lg font-semibold">
{icon && <span className="size-4">{icon}</span>}
{!!icon && <span className="size-4">{icon}</span>}
<EllipsisHorizontalTextWithTooltip className="truncate">
<span>{title}</span>
</EllipsisHorizontalTextWithTooltip>
@@ -2,6 +2,7 @@ import type { ForwardedRef } from "react"
import { forwardRef } from "react"
import { m } from "~/components/common/Motion"
import { stopPropagation } from "~/lib/dom"
import { cn } from "~/lib/utils"
import { RootPortal } from "../../portal"
@@ -24,7 +25,7 @@ export const ModalOverlay = forwardRef(
ref={ref}
id="modal-overlay"
className={cn(
"pointer-events-none fixed inset-0 z-[11] rounded-[var(--fo-window-radius)] bg-zinc-50/80 dark:bg-neutral-900/80",
"fixed inset-0 z-[11] rounded-[var(--fo-window-radius)] bg-zinc-50/80 dark:bg-neutral-900/80",
blur && "backdrop-blur-sm",
className,
)}
@@ -32,6 +33,7 @@ export const ModalOverlay = forwardRef(
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
style={{ zIndex }}
onClick={stopPropagation}
/>
</RootPortal>
),
@@ -5,10 +5,11 @@ import { useRootPortal } from "./provider"
export const RootPortal: FC<
{
to?: HTMLElement
to?: HTMLElement | null
} & PropsWithChildren
> = (props) => {
const to = useRootPortal()
if (props.to === null) return props.children
return createPortal(props.children, props.to || to || document.body)
}
@@ -1,253 +0,0 @@
import { repository } from "@pkg"
import type { FC } from "react"
import { memo } from "react"
import { useTranslation } from "react-i18next"
import { Link } from "react-router-dom"
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar"
import { useSignOut } from "~/hooks/biz/useSignOut"
import { useAuthQuery } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { defineQuery } from "~/lib/defineQuery"
import { nextFrame } from "~/lib/dom"
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
import { cn } from "~/lib/utils"
import { useAchievementModal } from "~/modules/achievement/hooks"
import { LoginModalContent } from "~/modules/auth/LoginModalContent"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { useSettingModal } from "~/modules/settings/modal/hooks"
import { useSession } from "~/queries/auth"
import { UserArrowLeftIcon } from "./icons/user"
import { ActionButton } from "./ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "./ui/dropdown-menu/dropdown-menu"
import { PlainModal } from "./ui/modal/stacked/custom-modal"
import { useModalStack } from "./ui/modal/stacked/hooks"
interface LoginProps {
method?: "redirect" | "modal"
}
export const LoginButton: FC<LoginProps> = (props) => {
const { method } = props
const modalStack = useModalStack()
const { t } = useTranslation()
const Content = (
<ActionButton
className="relative z-[1]"
onClick={
method === "modal"
? () => {
modalStack.present({
CustomModalComponent: PlainModal,
title: "Login",
id: "login",
content: () => <LoginModalContent runtime={window.electron ? "app" : "browser"} />,
clickOutsideToDismiss: true,
})
}
: undefined
}
tooltip={t("words.login")}
>
<UserArrowLeftIcon className="size-4" />
</ActionButton>
)
return method === "modal" ? Content : <Link to="/login">{Content}</Link>
}
export const ProfileButton: FC<LoginProps> = memo((props) => {
const { status, session } = useSession()
const { user } = session || {}
const signOut = useSignOut()
const settingModalPresent = useSettingModal()
const presentUserProfile = usePresentUserProfileModal("dialog")
const presentAchievement = useAchievementModal()
const { t } = useTranslation()
if (status !== "authenticated") {
return <LoginButton {...props} />
}
return (
<DropdownMenu>
<DropdownMenuTrigger asChild className="!outline-none focus-visible:bg-theme-item-hover">
<ActionButton>
<UserAvatar className="h-5 p-0 [&_*]:border-0" hideName />
</ActionButton>
</DropdownMenuTrigger>
<DropdownMenuContent className="min-w-[180px]" side="bottom" align="end">
<DropdownMenuLabel className="text-xs text-theme-foreground/60">
{t("user_button.account")}
</DropdownMenuLabel>
<DropdownMenuLabel>
<div className="-mt-1 flex items-center gap-2">
<UserAvatar className="h-7 shrink-0 p-0" hideName />
<div className="max-w-40 leading-none">
<div className="truncate">{user?.name}</div>
<div className="truncate text-xs font-medium text-zinc-500">{user?.handle}</div>
</div>
</div>
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => {
presentUserProfile(user?.id)
}}
icon={<i className="i-mgc-user-3-cute-re" />}
>
{t("user_button.profile")}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
presentAchievement()
}}
icon={<i className="i-mgc-trophy-cute-re" />}
>
{t("user_button.achievement")}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => {
nextFrame(() => settingModalPresent("wallet"))
}}
icon={<i className="i-mgc-power-outline" />}
>
{t("user_button.power")}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
nextFrame(settingModalPresent)
}}
icon={<i className="i-mgc-settings-7-cute-re" />}
>
{t("user_button.preferences")}
</DropdownMenuItem>
<DropdownMenuSeparator />
{!window.electron && (
<>
<DropdownMenuItem
onClick={() => {
window.open(`${repository.url}/releases`)
}}
icon={<i className="i-mgc-download-2-cute-re" />}
>
{t("user_button.download_desktop_app")}
</DropdownMenuItem>
<DropdownMenuSeparator />
</>
)}
<DropdownMenuItem onClick={signOut} icon={<i className="i-mgc-exit-cute-re" />}>
{t("user_button.log_out")}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
})
ProfileButton.displayName = "ProfileButton"
export function UserAvatar({
className,
avatarClassName,
hideName,
userId,
enableModal,
...props
}: {
className?: string
avatarClassName?: string
hideName?: boolean
userId?: string
enableModal?: boolean
} & LoginProps) {
const { session, status } = useSession({
enabled: !userId,
})
const presentUserProfile = usePresentUserProfileModal("drawer")
const profile = useAuthQuery(
defineQuery(["profiles", userId], async () => {
const res = await apiClient.profiles.$get({
query: { id: userId! },
})
return res.data
}),
{
enabled: !!userId,
},
)
if (!userId && status !== "authenticated") {
return <LoginButton {...props} />
}
const renderUserData = userId ? profile.data : session?.user
return (
<div
className={cn(
"flex h-20 items-center justify-center gap-2 px-5 py-2 font-medium text-zinc-600 dark:text-zinc-300",
className,
)}
onClick={enableModal ? () => presentUserProfile(userId) : undefined}
>
<Avatar
className={cn(
"aspect-square h-full w-auto overflow-hidden rounded-full border bg-stone-300",
avatarClassName,
)}
>
<AvatarImage
className="duration-200 animate-in fade-in-0"
src={replaceImgUrlIfNeed(renderUserData?.image || undefined)}
/>
<AvatarFallback>{renderUserData?.name?.slice(0, 2)}</AvatarFallback>
</Avatar>
{!hideName && <div>{renderUserData?.name}</div>}
</div>
)
}
// const AppTheme = () => {
// const theme = useThemeAtomValue()
// const setTheme = useSetTheme()
// return (
// <SettingTabbedSegment
// className="mb-0"
// label={(
// <span>
// <i className="i-mgc-palette-cute-re mr-2 translate-y-0.5" />
// <span className="text-sm font-normal">
// Theme
// </span>
// </span>
// )}
// value={theme}
// values={[
// {
// value: "system",
// label: "",
// icon: <i className="i-mingcute-monitor-line" />,
// },
// {
// value: "light",
// label: "",
// icon: <i className="i-mingcute-sun-line" />,
// },
// {
// value: "dark",
// label: "",
// icon: <i className="i-mingcute-moon-line" />,
// },
// ]}
// onValueChanged={(value) => {
// setTheme(value as "light" | "dark" | "system")
// }}
// />
// )
// }
+1
View File
@@ -2,4 +2,5 @@ export const HotKeyScopeMap = {
Home: ["home"],
Menu: ["menu"],
Modal: ["modal"],
DropdownMenu: ["dropdown-menu"],
}
+1 -1
View File
@@ -30,7 +30,7 @@ export interface LocalDBSchemaMap {
}
// Define a local DB
export class BrowserDB extends Dexie {
class BrowserDB extends Dexie {
public entries: BrowserDBTable<"entries">
public feeds: BrowserDBTable<"feeds">
public subscriptions: BrowserDBTable<"subscriptions">
@@ -355,7 +355,7 @@ export const useEntryActions = ({
onClick: () => {
if (!populatedEntry.entries.url) return
navigator.clipboard.writeText(populatedEntry.entries.url)
toast(t("entry_actions.link_copied"), {
toast(t("entry_actions.copied_notify", { which: t("words.link") }), {
duration: 1000,
})
},
@@ -364,12 +364,12 @@ export const useEntryActions = ({
key: "copyTitle",
name: t("entry_actions.copy_title"),
className: tw`i-mgc-copy-cute-re`,
hide: !populatedEntry.entries.title,
hide: !populatedEntry.entries.title || type === "toolbar",
shortcut: shortcuts.entry.copyTitle.key,
onClick: () => {
if (!populatedEntry.entries.title) return
navigator.clipboard.writeText(populatedEntry.entries.title)
toast(t("entry_actions.title_copied"), {
toast(t("entry_actions.copied_notify", { which: t("words.title") }), {
duration: 1000,
})
},
@@ -20,7 +20,7 @@ import {
useRemoveFeedFromFeedList,
} from "~/store/feed"
import { useInboxById } from "~/store/inbox"
import { useListById, useListByView } from "~/store/list"
import { useListById, useOwnedList } from "~/store/list"
import { subscriptionActions, useSubscriptionByFeedId } from "~/store/subscription"
import { useNavigateEntry } from "./useNavigateEntry"
@@ -51,7 +51,7 @@ export const useFeedActions = ({
const { mutateAsync: addFeedToListMutation } = useAddFeedToFeedList()
const { mutateAsync: removeFeedFromListMutation } = useRemoveFeedFromFeedList()
const listByView = useListByView(view!)
const listByView = useOwnedList(view!)
const items = useMemo(() => {
if (!feed) return []
@@ -12,7 +12,7 @@ import {
} from "~/constants"
import { FeedViewType } from "~/lib/enum"
type NavigateEntryOptions = Partial<{
export type NavigateEntryOptions = Partial<{
feedId: string | null
entryId: string | null
view: FeedViewType
@@ -1,4 +1,4 @@
import { useCallback } from "react"
import { useCallback, useLayoutEffect, useRef } from "react"
import { useHotkeysContext } from "react-hotkeys-hook"
import { HotKeyScopeMap } from "~/constants"
@@ -18,9 +18,41 @@ export const useSwitchHotKeyScope = () => {
for (const key of allScopes) {
disableScope(key)
}
enableScope(nextScope[0])
for (const key of nextScope) {
enableScope(key)
}
},
[disableScope, enableScope],
)
}
export const useHotkeyScopeFn = (scope: keyof typeof HotKeyScopeMap) => {
const { enableScope, disableScope, enabledScopes } = useHotkeysContext()
const currentScopeRef = useRef(enabledScopes)
return useCallback(() => {
const currentScope = currentScopeRef.current
for (const key of allScopes) {
disableScope(key)
}
for (const key of scope) {
enableScope(key)
}
return () => {
for (const key of scope) {
disableScope(key)
}
for (const scope of currentScope) {
enableScope(scope)
}
}
}, [enableScope, disableScope, scope])
}
export const useHotkeyScope = (scope: keyof typeof HotKeyScopeMap, when: boolean) => {
const fn = useHotkeyScopeFn(scope)
useLayoutEffect(() => {
if (when) {
return fn()
}
}, [fn, when])
}
+7 -3
View File
@@ -7,6 +7,7 @@ import { EventBus } from "~/lib/event-bus"
import { defaultNS, ns } from "./@types/constants"
import { defaultResources } from "./@types/default-resource"
import { getGeneralSettings } from "./atoms/settings/general"
import { isDev } from "./constants"
import { Chain } from "./lib/chain"
import { jotaiStore } from "./lib/jotai"
import { getStorageNS } from "./lib/ns"
@@ -42,14 +43,17 @@ export const initI18n = async () => {
const i18next = jotaiStore.get(i18nAtom)
const lang = getGeneralSettings().language
const cache = LocaleCache.shared.get(lang)
const mergedResources = {
...defaultResources,
}
if (cache) {
mergedResources[lang] = cache
let cache = null as any
if (!isDev) {
cache = LocaleCache.shared.get(lang)
if (cache) {
mergedResources[lang] = cache
}
}
await i18next.use(initReactI18next).init({
+9 -6
View File
@@ -13,10 +13,18 @@ declare global {
}
}
}
export const initPostHog = async () => {
export const initPostHog = () => {
if (env.VITE_POSTHOG_KEY === undefined) return
posthog.init(env.VITE_POSTHOG_KEY, {
person_profiles: "identified_only",
enable_heatmaps: false,
autocapture: false,
loaded: () => {
const user = whoami()
if (user) {
posthog.identify(user.id, { name: user.name, handle: user.handle })
}
},
})
const { capture, reset } = posthog
@@ -40,9 +48,4 @@ export const initPostHog = async () => {
] as const)
},
}
const user = whoami()
if (user) {
posthog.identify(user.id, { name: user.name, handle: user.handle })
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ export const attachOpenInEditor = (stack: string) => {
if (!line.includes("at ")) {
return line
}
const match = line.match(/(http:\/\/localhost:\d+\/[^:]+):(\d+):(\d+)/)
const match = line.match(/http:\/\/localhost:\d+\/[^:]+:\d+:\d+/)
if (match) {
const [o] = match
@@ -0,0 +1,148 @@
import { franc } from "franc-min"
import type { FlatEntryModel } from "~/store/entry"
import { LanguageMap, translate } from "./translate"
function textNodesUnder(el: Node) {
const children: Node[] = el.nodeType === Node.TEXT_NODE ? [el] : []
const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT)
while (walker.nextNode()) {
const { currentNode } = walker
if (currentNode.textContent) {
children.push(currentNode)
}
}
return children
}
const tagsToDuplicate = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "li", "blockquote"]
export function immersiveTranslate({
html,
entry,
cache,
}: {
html?: HTMLElement
entry: FlatEntryModel
cache?: {
get: (key: string) => string | undefined
set: (key: string, value: string) => void
}
}) {
if (!html || !entry.settings?.translation) {
return
}
if (html.childNodes.length === 1 && html.childNodes[0].nodeType === Node.TEXT_NODE) {
const textNode = html.childNodes[0] as Text
if (!textNode.textContent) {
return
}
translate({
entry,
language: entry.settings?.translation,
part: textNode.textContent,
extraFields: ["content"],
}).then((transformed) => {
if (!transformed?.content) {
return
}
const p = document.createElement("p")
p.append(document.createTextNode(textNode.textContent!))
p.append(document.createElement("br"))
p.append(document.createTextNode(transformed.content))
textNode.replaceWith(p)
})
return
}
const tags = Array.from(html.querySelectorAll(tagsToDuplicate.join(","))).filter((tag) => {
const children = tag.querySelectorAll(tagsToDuplicate.join(","))
if (children.length > 0) {
return false
}
return true
}) as HTMLElement[]
for (const tag of tags) {
const sourceLanguage = franc(tag.textContent ?? "")
if (sourceLanguage === LanguageMap[entry.settings?.translation].code) {
return
}
const children = Array.from(tag.childNodes)
tag.dataset.childCount = children.filter((child) => child.textContent).length.toString()
const fontTag = document.createElement("font")
if (children.length > 0) {
fontTag.style.display = "none"
}
for (const child of children) {
const clone = child.cloneNode(true)
const textNodes = textNodesUnder(clone)
if (textNodes.length === 0) {
continue
}
for (const textNode of textNodes) {
if (textNode.textContent === null) {
continue
}
const { textContent } = textNode
const afterTranslate = (translated: string) => {
textNode.textContent = translated
if (tag.dataset.childCount === undefined) {
throw new Error("childCount is undefined")
}
let childCount = Number.parseInt(tag.dataset.childCount)
childCount -= 1
tag.dataset.childCount = childCount.toString()
if (childCount === 0) {
fontTag.style.display = "initial"
}
}
if (cache) {
const cached = cache.get(textContent)
if (cached) {
afterTranslate(cached)
continue
}
}
translate({
entry,
language: entry.settings?.translation,
part: textContent,
extraFields: ["content"],
}).then((transformed) => {
if (!transformed?.content) {
return
}
afterTranslate(transformed.content)
if (cache) {
cache.set(textContent, transformed.content)
}
})
}
fontTag.append(clone)
}
const parentFontTag = document.createElement("font")
parentFontTag.append(document.createElement("br"))
parentFontTag.append(fontTag)
tag.append(parentFontTag)
}
}
+2 -1
View File
@@ -233,9 +233,10 @@ const Img: Components["img"] = ({ node, ...props }) => {
...props,
proxy: { height: 0, width: 700 },
}
const widthPx = Number.parseInt(props.width as string)
return createElement(
node?.properties.inline ? MarkdownInlineImage : MarkdownBlockImage,
node?.properties.inline && widthPx < 600 ? MarkdownInlineImage : MarkdownBlockImage,
nextProps,
)
}
+76
View File
@@ -0,0 +1,76 @@
import { views } from "~/constants"
import type { SupportedLanguages } from "~/models"
import type { FlatEntryModel } from "~/store/entry"
import { apiClient } from "./api-fetch"
export const LanguageMap: Record<
SupportedLanguages,
{
code: string
}
> = {
en: {
code: "eng",
},
ja: {
code: "jpn",
},
"zh-CN": {
code: "cmn",
},
"zh-TW": {
code: "cmn",
},
}
export async function translate({
entry,
view,
language,
extraFields,
part,
}: {
entry: FlatEntryModel
view?: number
language?: SupportedLanguages
extraFields?: string[]
part?: string
}) {
if (!language) {
return null
}
let fields =
entry.settings?.translation && view !== undefined ? views[view!].translation.split(",") : []
if (extraFields) {
fields = [...fields, ...extraFields]
}
const { franc } = await import("franc-min")
fields = fields.filter((field) => {
if (entry.settings?.translation && entry.entries[field]) {
const sourceLanguage = franc(entry.entries[field])
if (sourceLanguage === LanguageMap[entry.settings?.translation].code) {
return false
} else {
return true
}
} else {
return false
}
})
if (fields.length > 0) {
const res = await apiClient.ai.translation.$get({
query: {
id: entry.entries.id,
language,
fields: fields?.join(",") || "title",
part,
},
})
return res.data
} else {
return null
}
}
+2
View File
@@ -114,3 +114,5 @@ export type ActionsInput = {
webhooks?: string[]
}
}[]
export const TransactionTypes = ["mint", "purchase", "tip", "withdraw"] as const
@@ -0,0 +1,283 @@
import { DotLottieReact } from "@lottiefiles/dotlottie-react"
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
import { useSingleton } from "foxact/use-singleton"
import { atom, useStore } from "jotai"
import { nanoid } from "nanoid"
import type { FC } from "react"
import { useEffect } from "react"
import { Trans } from "react-i18next"
import { Button } from "~/components/ui/button"
import { styledButtonVariant } from "~/components/ui/button/variants"
import { LoadingCircle, LoadingWithIcon } from "~/components/ui/loading"
import { useI18n } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { Chain } from "~/lib/chain"
import { cn } from "~/lib/utils"
import achievementAnimationUri from "~/lottie/achievement.lottie?url"
const absoluteachievementAnimationUri = new URL(achievementAnimationUri, import.meta.url).href
enum AchievementsActionIdMap {
FIRST_CLAIM_FEED = 0,
}
const achievementActionIdCopyMap: Record<
AchievementsActionIdMap,
{ title: I18nKeys; description: I18nKeys }
> = {
[AchievementsActionIdMap.FIRST_CLAIM_FEED]: {
title: "achievement.first_claim_feed",
description: "achievement.first_claim_feed_description",
},
}
export const AchievementModalContent: FC = () => {
const jotaiStore = useStore()
const queryClient = useQueryClient()
const defaultAchievements = useSingleton(buildDefaultAchievements)
const _achievementType = apiClient.achievement.$get({
query: {
type: "all",
},
})
type Achievement = Awaited<typeof _achievementType>["data"]
const {
data: achievements,
isLoading,
refetch,
} = useQuery({
queryKey: ["achievements"],
meta: {
persist: true,
},
queryFn: async () => {
const res = await apiClient.achievement.$get({
query: {
type: "all",
},
})
jotaiStore.set(achievementsDataAtom.current, res.data)
return res.data
},
initialData: defaultAchievements.current as Achievement,
})
useEffect(() => {
if (!achievements) return
let shouldPolling = false
const pollingChain = new Chain()
for (const achievement of achievements) {
if (achievement.type === "checking") {
shouldPolling = true
break
}
}
if (shouldPolling) {
pollingChain.wait(2000).next(() => {
refetch()
})
}
return () => {
pollingChain.abort()
}
}, [achievements, refetch])
const { mutateAsync: mintAchievement, isPending: isMinting } = useMutation({
mutationFn: async (actionId: number) => {
return apiClient.achievement.$put({
json: {
actionId,
},
})
},
})
const achievementsDataAtom = useSingleton(() => atom<typeof achievements>())
const { mutateAsync: checkAchievement, isPending: checkPending } = useMutation({
mutationFn: async (actionId: number) => {
return apiClient.achievement.check.$post({
json: {
actionId,
},
})
},
onSuccess: () => {
refetch()
},
})
const t = useI18n()
return (
<div className="relative flex w-full grow flex-col items-center">
<DotLottieReact
className="mt-12 size-[100px]"
autoplay
speed={2}
src={absoluteachievementAnimationUri}
loop={false}
/>
<div className="mt-4 text-xl font-bold">{t("words.achievement")}</div>
<small className="center mt-1 gap-1 text-theme-vibrancyFg">
<Trans
i18nKey={"achievement.mint_more_power"}
components={{
power: (
<span className="center gap-0.5 font-semibold">
<span>{t("words.power")}</span>
<i className="i-mgc-power text-accent" />
</span>
),
}}
/>
</small>
<ul className="mt-10 flex w-full grow flex-col gap-2">
{isLoading ? (
<div className="center pointer-events-none grow -translate-y-16">
<LoadingWithIcon icon={<i className="i-mgc-trophy-cute-re" />} size="large" />
</div>
) : (
achievements?.map((achievement) => {
const copy = achievementActionIdCopyMap[achievement.actionId]
if (!copy) return null
return (
<li key={achievement.id} className="flex items-center justify-between">
<div>
<div className="text-base font-bold">
{t(copy.title)}
{achievement.power && (
<span className="ml-2 inline-flex items-center gap-0.5 text-xs font-normal">
<span className="font-medium opacity-80">{achievement.power}</span>
<i className="i-mgc-power text-sm text-accent" />
</span>
)}
</div>
<div className="flex items-center text-sm text-muted-foreground">
{t(copy.description)}
</div>
</div>
{achievement.type === "checking" && (
<div
className={styledButtonVariant({
variant: "outline",
className: "relative border-0 pointer-events-none",
})}
>
<LoadingCircle size="small" className="center absolute inset-0" />
<span className="select-none opacity-0">{t("words.mint")}</span>
</div>
)}
{achievement.type === "incomplete" && (
<button
type="button"
className={styledButtonVariant({
variant: "ghost",
className: "relative hover:bg-transparent group cursor-pointer",
})}
onClick={() => {
checkAchievement(achievement.actionId)
}}
>
<div className="center absolute z-[1] opacity-0 duration-200 group-hover:opacity-100">
<i
className={cn(
"i-mgc-refresh-2-cute-re size-5 text-accent",
checkPending && "animate-spin",
)}
/>
</div>
<div className="duration-200 group-hover:opacity-30">
<span className="center relative ml-2 inline-flex w-24 -translate-y-1 flex-col *:!m-0">
<small className="shrink-0 text-xs leading-tight text-muted-foreground">
{achievement.progress} / {achievement.progressMax}
</small>
<span className="relative h-1 w-full overflow-hidden rounded-full bg-accent/10">
<span
className="absolute -left-3 top-0 inline-block h-1 rounded-full bg-accent"
style={{
width: `calc(${Math.min(
(achievement.progress / achievement.progressMax) * 100,
100,
)}% + 0.75rem)`,
}}
/>
</span>
</span>
</div>
</button>
)}
{achievement.type === "received" && (
<div
className={styledButtonVariant({
variant: "outline",
className:
"relative !bg-green-100/50 gap-1 border-green-200 text-green-800 dark:text-foreground dark:!bg-green-100/5 dark:border-green-200/20",
})}
>
<i className="i-mgc-check-filled" />
{t("achievement.all_done")}
</div>
)}
{achievement.type === "completed" && (
<Button
isLoading={isMinting}
variant="primary"
onClick={async () => {
const res = await mintAchievement(achievement.actionId)
const currentData = jotaiStore.get(achievementsDataAtom.current)
if (!currentData) return
let shouldInvalidate = false
const newData = currentData.map((item) => {
if (item.id === achievement.id && res.data.result) {
shouldInvalidate = true
return {
...item,
done: true,
doneAt: new Date().toISOString(),
type: "received",
} as const
}
return item
})
jotaiStore.set(achievementsDataAtom.current, newData)
if (shouldInvalidate) {
queryClient.invalidateQueries({ queryKey: ["achievements"] })
}
}}
>
{t("words.mint")}
</Button>
)}
</li>
)
})
)}
</ul>
</div>
)
}
const buildDefaultAchievements = () => {
return [
{
id: nanoid(),
actionId: AchievementsActionIdMap.FIRST_CLAIM_FEED,
type: "checking",
progress: 0,
progressMax: 0,
},
]
}
+2 -281
View File
@@ -1,38 +1,9 @@
import { DotLottieReact } from "@lottiefiles/dotlottie-react"
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
import { useSingleton } from "foxact/use-singleton"
import { atom, useStore } from "jotai"
import { nanoid } from "nanoid"
import type { FC } from "react"
import { useCallback, useEffect } from "react"
import { Trans } from "react-i18next"
import { useCallback } from "react"
import { Button } from "~/components/ui/button"
import { styledButtonVariant } from "~/components/ui/button/variants"
import { LoadingCircle, LoadingWithIcon } from "~/components/ui/loading"
import { useModalStack } from "~/components/ui/modal"
import { SlideUpModal } from "~/components/ui/modal/stacked/custom-modal"
import { useI18n } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { Chain } from "~/lib/chain"
import { cn } from "~/lib/utils"
import achievementAnimationUri from "~/lottie/achievement.lottie?url"
const absoluteachievementAnimationUri = new URL(achievementAnimationUri, import.meta.url).href
enum AchievementsActionIdMap {
FIRST_CLAIM_FEED = 0,
}
const achievementActionIdCopyMap: Record<
AchievementsActionIdMap,
{ title: I18nKeys; description: I18nKeys }
> = {
[AchievementsActionIdMap.FIRST_CLAIM_FEED]: {
title: "achievement.first_claim_feed",
description: "achievement.first_claim_feed_description",
},
}
import { AchievementModalContent } from "./AchievementModalContent"
export const useAchievementModal = () => {
const { present } = useModalStack()
@@ -47,253 +18,3 @@ export const useAchievementModal = () => {
})
}, [present])
}
const buildDefaultAchievements = () => {
return [
{
id: nanoid(),
actionId: AchievementsActionIdMap.FIRST_CLAIM_FEED,
type: "checking",
progress: 0,
progressMax: 0,
},
]
}
export const AchievementModalContent: FC = () => {
const jotaiStore = useStore()
const queryClient = useQueryClient()
const defaultAchievements = useSingleton(buildDefaultAchievements)
const _achievementType = apiClient.achievement.$get({
query: {
type: "all",
},
})
type Achievement = Awaited<typeof _achievementType>["data"]
const {
data: achievements,
isLoading,
refetch,
} = useQuery({
queryKey: ["achievements"],
meta: {
persist: true,
},
queryFn: async () => {
const res = await apiClient.achievement.$get({
query: {
type: "all",
},
})
jotaiStore.set(achievementsDataAtom.current, res.data)
return res.data
},
initialData: defaultAchievements.current as Achievement,
})
useEffect(() => {
if (!achievements) return
let shouldPolling = false
const pollingChain = new Chain()
for (const achievement of achievements) {
if (achievement.type === "checking") {
shouldPolling = true
break
}
}
if (shouldPolling) {
pollingChain.wait(2000).next(() => {
refetch()
})
}
return () => {
pollingChain.abort()
}
}, [achievements, refetch])
const { mutateAsync: mintAchievement, isPending: isMinting } = useMutation({
mutationFn: async (actionId: number) => {
return apiClient.achievement.$put({
json: {
actionId,
},
})
},
})
const achievementsDataAtom = useSingleton(() => atom<typeof achievements>())
const { mutateAsync: checkAchievement, isPending: checkPending } = useMutation({
mutationFn: async (actionId: number) => {
return apiClient.achievement.check.$post({
json: {
actionId,
},
})
},
onSuccess: () => {
refetch()
},
})
const t = useI18n()
return (
<div className="relative flex w-full grow flex-col items-center">
<DotLottieReact
className="mt-12 size-[100px]"
autoplay
speed={2}
src={absoluteachievementAnimationUri}
loop={false}
/>
<div className="mt-4 text-xl font-bold">{t("words.achievement")}</div>
<small className="center mt-1 gap-1 text-theme-vibrancyFg">
<Trans
i18nKey={"achievement.mint_more_power"}
components={{
power: (
<span className="center gap-0.5 font-semibold">
<span>{t("words.power")}</span>
<i className="i-mgc-power text-accent" />
</span>
),
}}
/>
</small>
<ul className="mt-10 flex w-full grow flex-col gap-2">
{isLoading ? (
<div className="center pointer-events-none grow -translate-y-16">
<LoadingWithIcon icon={<i className="i-mgc-trophy-cute-re" />} size="large" />
</div>
) : (
achievements?.map((achievement) => {
const copy = achievementActionIdCopyMap[achievement.actionId]
if (!copy) return null
return (
<li key={achievement.id} className="flex items-center justify-between">
<div>
<div className="text-base font-bold">
{t(copy.title)}
{achievement.power && (
<span className="ml-2 inline-flex items-center gap-0.5 text-xs font-normal">
<span className="font-medium opacity-80">{achievement.power}</span>
<i className="i-mgc-power text-sm text-accent" />
</span>
)}
</div>
<div className="flex items-center text-sm text-muted-foreground">
{t(copy.description)}
</div>
</div>
{achievement.type === "checking" && (
<div
className={styledButtonVariant({
variant: "outline",
className: "relative border-0 pointer-events-none",
})}
>
<LoadingCircle size="small" className="center absolute inset-0" />
<span className="select-none opacity-0">{t("words.mint")}</span>
</div>
)}
{achievement.type === "incomplete" && (
<button
type="button"
className={styledButtonVariant({
variant: "ghost",
className: "relative hover:bg-transparent group cursor-pointer",
})}
onClick={() => {
checkAchievement(achievement.actionId)
}}
>
<div className="center absolute z-[1] opacity-0 duration-200 group-hover:opacity-100">
<i
className={cn(
"i-mgc-refresh-2-cute-re size-5 text-accent",
checkPending && "animate-spin",
)}
/>
</div>
<div className="duration-200 group-hover:opacity-30">
<span className="center relative ml-2 inline-flex w-24 -translate-y-1 flex-col *:!m-0">
<small className="shrink-0 text-xs leading-tight text-muted-foreground">
{achievement.progress} / {achievement.progressMax}
</small>
<span className="relative h-1 w-full overflow-hidden rounded-full bg-accent/10">
<span
className="absolute -left-3 top-0 inline-block h-1 rounded-full bg-accent"
style={{
width: `calc(${Math.min(
(achievement.progress / achievement.progressMax) * 100,
100,
)}% + 0.75rem)`,
}}
/>
</span>
</span>
</div>
</button>
)}
{achievement.type === "received" && (
<div
className={styledButtonVariant({
variant: "outline",
className:
"relative !bg-green-100/50 gap-1 border-green-200 text-green-800 dark:text-foreground dark:!bg-green-100/5 dark:border-green-200/20",
})}
>
<i className="i-mgc-check-filled" />
{t("achievement.all_done")}
</div>
)}
{achievement.type === "completed" && (
<Button
isLoading={isMinting}
variant="primary"
onClick={async () => {
const res = await mintAchievement(achievement.actionId)
const currentData = jotaiStore.get(achievementsDataAtom.current)
if (!currentData) return
let shouldInvalidate = false
const newData = currentData.map((item) => {
if (item.id === achievement.id && res.data.result) {
shouldInvalidate = true
return {
...item,
done: true,
doneAt: new Date().toISOString(),
type: "received",
} as const
}
return item
})
jotaiStore.set(achievementsDataAtom.current, newData)
if (shouldInvalidate) {
queryClient.invalidateQueries({ queryKey: ["achievements"] })
}
}}
>
{t("words.mint")}
</Button>
)}
</li>
)
})
)}
</ul>
</div>
)
}
@@ -1,6 +1,6 @@
import clsx from "clsx"
import { AnimatePresence, m } from "framer-motion"
import { useState } from "react"
import { useEffect, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import { FollowIcon } from "~/components/icons/follow"
@@ -23,7 +23,26 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
const { t } = useTranslation()
const [loadingLockSet, setLoadingLockSet] = useState<string>("")
const [loadingLockSet, _setLoadingLockSet] = useState<string>("")
const timerRef = useRef<NodeJS.Timeout | null>(null)
const setLoadingLockSet = (id: string) => {
_setLoadingLockSet(id)
if (timerRef.current) {
clearTimeout(timerRef.current)
}
timerRef.current = setTimeout(() => {
_setLoadingLockSet("")
}, 3000)
}
useEffect(() => {
return () => {
if (timerRef.current) {
clearTimeout(timerRef.current)
}
}
}, [])
const disabled = !!loadingLockSet
return (
@@ -81,12 +81,7 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
<RelativeTime date={entry.entries.publishedAt} />
</span>
</div>
<div
className={cn(
"relative mt-1 whitespace-pre-line text-base",
!!entry.collections && "pr-5",
)}
>
<div className={cn("relative mt-1 text-base", !!entry.collections && "pr-5")}>
<EntryTranslation
className="cursor-auto select-text text-sm leading-relaxed prose-blockquote:mt-0 [&_br:last-child]:hidden"
source={content}
@@ -9,10 +9,10 @@ import { useOnClickOutside } from "usehooks-ts"
import { ActionButton, Button, IconButton } from "~/components/ui/button"
import { Kbd, KbdCombined } from "~/components/ui/kbd/Kbd"
import { RootPortal } from "~/components/ui/portal"
import { HotKeyScopeMap } from "~/constants"
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT, HotKeyScopeMap } from "~/constants"
import { shortcuts } from "~/constants/shortcuts"
import { useI18n } from "~/hooks/common"
import { cn } from "~/lib/utils"
import { cn, getOS } from "~/lib/utils"
import type { MarkAllFilter } from "../hooks/useMarkAll"
import { useMarkAllByRoute } from "../hooks/useMarkAll"
@@ -51,7 +51,7 @@ export const MarkAllReadWithOverlay = forwardRef<
<m.div
ref={setPopoverRef}
initial={{ y: -70 }}
animate={{ y: 0 }}
animate={{ y: getOS() === "Windows" ? -ElECTRON_CUSTOM_TITLEBAR_HEIGHT : 0 }}
exit={{ y: -70 }}
transition={{ type: "spring", damping: 20, stiffness: 300 }}
className="shadow-modal absolute z-50 bg-theme-modal-background-opaque shadow"
@@ -248,6 +248,8 @@ const WideModeButton = () => {
shortcut={shortcuts.layout.toggleWideMode.key}
onClick={() => {
setUISetting("wideMode", !isWideMode)
// TODO: Remove this after useMeasure can get bounds in time
window.dispatchEvent(new Event("resize"))
window.posthog?.capture("Switch to Wide Mode", {
wideMode: !isWideMode ? 1 : 0,
click: 1,
@@ -50,7 +50,7 @@ export const EntryTranslation: Component<{
<HoverCard.Portal>
<HoverCard.Content
className={cn(
"group relative z-[1] text-sm",
"group relative z-[11] text-sm",
"animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
)}
style={useOverlay ? { width: bounds.width } : undefined}
@@ -65,7 +65,6 @@ export const EntryTranslation: Component<{
"shadow-modal rounded-xl border bg-background p-2",
"group-data-[side=top]:top-0",
"group-data-[side=bottom]:top-full",
"max-w-[30ch]",
)}
viewportClassName="max-h-[12ch]"
>
@@ -1,6 +1,8 @@
import { atom } from "jotai"
import { atomWithStorage } from "jotai/utils"
import { createAtomHooks } from "~/lib/jotai"
import { getStorageNS } from "~/lib/ns"
export const [, , useEntryTitleMeta, , getEntryTitleMeta, setEntryTitleMeta] = createAtomHooks(
atom(
@@ -28,3 +30,7 @@ export const [
getEntryContentPlaceholderLogoShow,
setEntryContentPlaceholderLogoShow,
] = createAtomHooks(atom(true))
export const [, , , , getTranslationCache, setTranslationCache] = createAtomHooks(
atomWithStorage(getStorageNS("translation-cache"), {} as Record<string, string>),
)
@@ -61,7 +61,7 @@ export const EntryReadHistory: Component<{ entryId: string }> = ({ entryId }) =>
<button
type="button"
style={{
right: `${LIMIT * 8}px`,
marginLeft: `-${LIMIT * 8}px`,
zIndex: LIMIT + 1,
}}
className="no-drag-region relative flex size-7 items-center justify-center rounded-full border border-border bg-muted ring-2 ring-background"
@@ -79,7 +79,11 @@ export const EntryTitle = ({ entryId, compact }: EntryLinkProps) => {
rel="noreferrer"
>
<div className={cn("select-text break-words font-bold", compact ? "text-2xl" : "text-3xl")}>
<EntryTranslation source={entry.entries.title} target={translation.data?.title} />
<EntryTranslation
source={entry.entries.title}
target={translation.data?.title}
useOverlay
/>
</div>
<div className="mt-2 text-[13px] font-medium text-zinc-500">{getPreferredTitle(feed)}</div>
<div className="flex items-center gap-2 text-[13px] text-zinc-500">
@@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next"
import { Button } from "~/components/ui/button"
import { Divider } from "~/components/ui/divider"
import { UserAvatar } from "~/components/user-button"
import { UserAvatar } from "~/modules/user/UserAvatar"
import { useEntry } from "~/store/entry"
import { useFeedById } from "~/store/feed"
@@ -30,6 +30,7 @@ import { useAuthQuery, useTitle } from "~/hooks/common"
import { stopPropagation } from "~/lib/dom"
import { FeedViewType } from "~/lib/enum"
import { getNewIssueUrl } from "~/lib/issues"
import { LanguageMap } from "~/lib/translate"
import { cn } from "~/lib/utils"
import type { ActiveEntryId, FeedModel, InboxModel } from "~/models"
import {
@@ -43,7 +44,12 @@ import { useFeedById } from "~/store/feed"
import { LoadingWithIcon } from "../../components/ui/loading"
import { EntryPlaceholderDaily } from "../ai/ai-daily/EntryPlaceholderDaily"
import { setEntryContentScrollToTop, setEntryTitleMeta } from "./atoms"
import {
getTranslationCache,
setEntryContentScrollToTop,
setEntryTitleMeta,
setTranslationCache,
} from "./atoms"
import { EntryPlaceholderLogo } from "./components/EntryPlaceholderLogo"
import { EntryTitle } from "./components/EntryTitle"
import { SourceContentPanel } from "./components/SourceContentView"
@@ -185,6 +191,30 @@ export const EntryContentRender: Component<{
const content = entry?.entries.content ?? data?.entries.content
const translate = async (html: HTMLElement | null) => {
if (!html || !entry || !entry.settings?.translation) return
const fullText = html.textContent ?? ""
if (!fullText) return
const { franc } = await import("franc-min")
const sourceLanguage = franc(fullText)
if (sourceLanguage === LanguageMap[entry.settings?.translation].code) {
return
}
const { immersiveTranslate } = await import("~/lib/immersive-translate")
immersiveTranslate({
html,
entry,
cache: {
get: (key: string) => getTranslationCache()[key],
set: (key: string, value: string) =>
setTranslationCache({ ...getTranslationCache(), [key]: value }),
},
})
}
return (
<EntryContentProvider
entryId={entry.entries.id}
@@ -237,6 +267,7 @@ export const EntryContentRender: Component<{
{!isInReadabilityMode ? (
<ShadowDOM>
<HTML
translate={translate}
mediaInfo={mediaInfo}
noMedia={noMedia}
accessory={contentAccessories}
@@ -16,7 +16,7 @@ import type { FeedViewType } from "~/lib/enum"
import { showNativeMenu } from "~/lib/native-menu"
import { cn, sortByAlphabet } from "~/lib/utils"
import { getPreferredTitle, useAddFeedToFeedList, useFeedStore } from "~/store/feed"
import { useListByView } from "~/store/list"
import { useOwnedList } from "~/store/list"
import { subscriptionActions, useSubscriptionByFeedId } from "~/store/subscription"
import { useFeedUnreadStore } from "~/store/unread"
@@ -131,7 +131,7 @@ function FeedCategoryImpl({ data: ids, view, categoryOpenStateData }: FeedCatego
const addMutation = useAddFeedToFeedList()
const listList = useListByView(view!)
const listList = useOwnedList(view!)
return (
<div tabIndex={-1} onClick={stopPropagation}>
@@ -2,7 +2,7 @@ import * as Slider from "@radix-ui/react-slider"
import type { TooltipContentProps } from "@radix-ui/react-tooltip"
import dayjs from "dayjs"
import { AnimatePresence, m } from "framer-motion"
import { useEffect, useState } from "react"
import { useEffect, useMemo, useState } from "react"
import Marquee from "react-fast-marquee"
import { useHotkeys } from "react-hotkeys-hook"
import { useTranslation } from "react-i18next"
@@ -18,11 +18,13 @@ import { microReboundPreset } from "~/components/ui/constants/spring"
import { VolumeSlider } from "~/components/ui/media/VolumeSlider"
import { Tooltip, TooltipContent, TooltipTrigger } from "~/components/ui/tooltip"
import { HotKeyScopeMap } from "~/constants"
import type { NavigateEntryOptions } from "~/hooks/biz/useNavigateEntry"
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { FeedViewType } from "~/lib/enum"
import { cn } from "~/lib/utils"
import { useEntry } from "~/store/entry"
import { useFeedById } from "~/store/feed"
import { useListById } from "~/store/list"
const handleClickPlay = () => {
AudioPlayer.togglePlayAndPause()
@@ -97,11 +99,13 @@ const CornerPlayerImpl = () => {
const entryId = useAudioPlayerAtomSelector((v) => v.entryId)
const status = useAudioPlayerAtomSelector((v) => v.status)
const isMute = useAudioPlayerAtomSelector((v) => v.isMute)
const listId = useAudioPlayerAtomSelector((v) => v.listId)
const playerValue = { entryId, status, isMute }
const entry = useEntry(playerValue.entryId)
const feed = useFeedById(entry?.feedId)
const list = useListById(listId)
useHotkeys("space", handleClickPlay, {
preventDefault: true,
@@ -120,6 +124,31 @@ const CornerPlayerImpl = () => {
const navigateToEntry = useNavigateEntry()
usePlayerTracker()
const navigateOptions = useMemo<NavigateEntryOptions | null>(() => {
if (!entry) return null
const options: NavigateEntryOptions = {
entryId: entry.entries.id,
}
if (feed?.type === "inbox") {
Object.assign(options, {
inboxId: feed.id,
view: FeedViewType.Articles,
})
} else if (list) {
Object.assign(options, {
listId: list.id,
view: list.view,
})
} else if (feed) {
Object.assign(options, {
feedId: feed.id,
view: entry.view ?? FeedViewType.Audios,
})
} else {
return null
}
return options
}, [entry, feed, list])
if (!entry || !feed) return null
return (
@@ -178,13 +207,11 @@ const CornerPlayerImpl = () => {
/>
<ActionIcon
className="i-mgc-external-link-cute-re"
onClick={() =>
navigateToEntry({
entryId: entry.entries.id,
feedId: feed.id,
view: FeedViewType.Audios,
})
}
onClick={() => {
if (navigateOptions) {
navigateToEntry(navigateOptions)
}
}}
label={t("player.open_entry")}
/>
<ActionIcon
@@ -312,7 +339,7 @@ const ActionIcon = ({
onClick={onClick}
asChild
>
<button type="button">{children || <i className={className} />}</button>
<button type="button">{children || <i aria-hidden className={className} />}</button>
</TooltipTrigger>
<TooltipContent align={tooltipAlign}>{label}</TooltipContent>
</Tooltip>
@@ -12,11 +12,11 @@ import { setFeedColumnShow, useFeedColumnShow, useSidebarActiveView } from "~/at
import { Logo } from "~/components/icons/logo"
import { ActionButton } from "~/components/ui/button"
import { Popover, PopoverContent, PopoverTrigger } from "~/components/ui/popover"
import { ProfileButton } from "~/components/user-button"
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { useI18n } from "~/hooks/common"
import { stopPropagation } from "~/lib/dom"
import { cn } from "~/lib/utils"
import { ProfileButton } from "~/modules/user/ProfileButton"
const useBackHome = (active: number) => {
const navigate = useNavigateEntry()
@@ -60,7 +60,7 @@ export const FeedColumnHeader = memo(() => {
</div>
</LogoContextMenu>
)}
<div className="relative flex items-center gap-1" onClick={stopPropagation}>
<div className="relative flex items-center gap-2" onClick={stopPropagation}>
<Link to="/discover" tabIndex={-1}>
<ActionButton shortcut="Meta+T" tooltip={t("words.discover")}>
<i className="i-mgc-add-cute-re size-5 text-theme-vibrancyFg" />
@@ -89,6 +89,9 @@ const LayoutActionButton = () => {
}, [feedColumnShow])
const t = useI18n()
if (feedColumnShow) return null
return (
<m.div initial={animation} animate={animation} className="overflow-hidden">
<ActionButton
+1
View File
@@ -241,6 +241,7 @@ export const CmdF = () => {
<AnimatePresence>
{show && (
<m.div
className="relative z-[1000]"
initial={{ opacity: 0.8, y: -150 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -150 }}
+70 -65
View File
@@ -149,71 +149,76 @@ export const SearchCmdK: React.FC = () => {
/>
<div className={cn(styles["status-bar"], isPending && styles["loading"])} />
<ScrollArea.ScrollArea
ref={scrollViewRef}
viewportClassName="max-h-[50vh] [&>div]:!flex"
rootClassName="h-full px-5"
scrollbarClassName="mb-6"
>
<Command.List className="flex w-full min-w-0 flex-col">
<SearchPlaceholder />
<div className="flex flex-1 flex-col overflow-y-hidden">
<ScrollArea.ScrollArea
ref={scrollViewRef}
viewportClassName="max-h-[50vh] [&>div]:!flex"
rootClassName="flex-1 px-5"
scrollbarClassName="mb-6"
>
<Command.List className="flex w-full min-w-0 flex-col">
<SearchPlaceholder />
{renderedEntries.length > 0 && (
<Command.Group
heading={
<SearchGroupHeading
icon="i-mgc-paper-cute-fi size-4"
title={t("search.group.entries")}
/>
}
className="flex w-full min-w-0 flex-col py-2"
>
{renderedEntries.map((entry) => {
const feed = getFeedById(entry.feedId)
return (
<SearchItem
key={`entry-${entry.item.id}-${entry.feedId}`}
view={feed?.id ? getSubscriptionByFeedId(feed.id)?.view : undefined}
title={entry.item.title!}
feedId={entry.feedId}
entryId={entry.item.id}
id={entry.item.id}
icon={feed?.type === "feed" ? feed?.siteUrl : undefined}
subtitle={feed?.title}
{renderedEntries.length > 0 && (
<Command.Group
heading={
<SearchGroupHeading
icon="i-mgc-paper-cute-fi size-4"
title={t("search.group.entries")}
/>
)
})}
</Command.Group>
)}
{renderedFeeds.length > 0 && (
<Command.Group
heading={
<SearchGroupHeading
icon="i-mgc-rss-cute-fi size-4 text-accent"
title={t("search.group.feeds")}
/>
}
className="py-2"
>
{renderedFeeds.map((feed) => (
<SearchItem
key={`feed-${feed.item.id}`}
view={getSubscriptionByFeedId(feed.item.id!)?.view}
title={feed.item.title!}
feedId={feed.item.id!}
entryId={ROUTE_ENTRY_PENDING}
id={feed.item.id!}
icon={feed.item.type === "feed" ? feed.item.siteUrl : undefined}
subtitle={useFeedUnreadStore.getState().data[feed.item.id!]?.toString()}
/>
))}
</Command.Group>
)}
{canLoadMore && <LoadMoreIndicator className="center w-full" onLoading={loadMore} />}
</Command.List>
</ScrollArea.ScrollArea>
<SearchOptions />
<SearchResultCount count={totalCount} />
}
className="flex w-full min-w-0 flex-col py-2"
>
{renderedEntries.map((entry) => {
const feed = getFeedById(entry.feedId)
return (
<SearchItem
key={`entry-${entry.item.id}-${entry.feedId}`}
view={feed?.id ? getSubscriptionByFeedId(feed.id)?.view : undefined}
title={entry.item.title!}
feedId={entry.feedId}
entryId={entry.item.id}
id={entry.item.id}
icon={feed?.type === "feed" ? feed?.siteUrl : undefined}
subtitle={feed?.title}
/>
)
})}
</Command.Group>
)}
{renderedFeeds.length > 0 && (
<Command.Group
heading={
<SearchGroupHeading
icon="i-mgc-rss-cute-fi size-4 text-accent"
title={t("search.group.feeds")}
/>
}
className="py-2"
>
{renderedFeeds.map((feed) => (
<SearchItem
key={`feed-${feed.item.id}`}
view={getSubscriptionByFeedId(feed.item.id!)?.view}
title={feed.item.title!}
feedId={feed.item.id!}
entryId={ROUTE_ENTRY_PENDING}
id={feed.item.id!}
icon={feed.item.type === "feed" ? feed.item.siteUrl : undefined}
subtitle={useFeedUnreadStore.getState().data[feed.item.id!]?.toString()}
/>
))}
</Command.Group>
)}
{canLoadMore && <LoadMoreIndicator className="center w-full" onLoading={loadMore} />}
</Command.List>
</ScrollArea.ScrollArea>
<div className="relative flex items-center justify-between px-3 py-2">
<SearchOptions />
<SearchResultCount count={totalCount} />
</div>
</div>
</Command.Dialog>
</SearchCmdKContext.Provider>
)
@@ -307,7 +312,7 @@ const SearchResultCount: FC<{
return (
<Tooltip>
<TooltipTrigger asChild>
<small className="center absolute bottom-3 right-3 shrink-0 gap-1 opacity-80">
<small className="center shrink-0 gap-1 opacity-80">
{hasKeyword ? (
<span>
{count} {t.common("words.result", { count })}
@@ -339,7 +344,7 @@ const SearchOptions: Component = memo(({ children }) => {
const searchInstance = React.useContext(SearchCmdKContext)
return (
<div className="absolute bottom-2 left-4 flex items-center gap-2 text-sm text-theme-foreground/80">
<div className="flex items-center gap-2 text-sm text-theme-foreground/80">
<span className="shrink-0">{t("search.options.search_type")}</span>
<Select
@@ -1,7 +1,6 @@
import { useMutation } from "@tanstack/react-query"
import { Trans, useTranslation } from "react-i18next"
import { useWhoami } from "~/atoms/user"
import { Button } from "~/components/ui/button"
import { CopyButton } from "~/components/ui/code-highlighter"
import { Divider } from "~/components/ui/divider"
@@ -20,8 +19,7 @@ import { WithdrawButton } from "./withdraw"
export const MyWalletSection = () => {
const { t } = useTranslation("settings")
const user = useWhoami()
const wallet = useWallet({ userId: user?.id })
const wallet = useWallet()
const myWallet = wallet.data?.[0]
const refreshMutation = useMutation({
@@ -53,6 +51,7 @@ export const MyWalletSection = () => {
<div className="space-y-8">
<div>
<div className="text-sm">
<i className="i-mgc-power mr-0.5 size-3.5 translate-y-px text-accent" />
<Trans
i18nKey="wallet.power.description"
ns="settings"
@@ -71,7 +70,7 @@ export const MyWalletSection = () => {
<p>{t("wallet.power.dailyClaim", { amount: DAILY_CLAIM_AMOUNT })}</p>
</div>
<SettingSectionTitle margin="compact" title={t("wallet.address.title")} />
<div className="flex items-center gap-2 text-sm">
<div className="group flex items-center gap-2 text-sm">
<a
href={`https://scan.rss3.io/address/${myWallet.address}`}
target="_blank"
@@ -79,7 +78,10 @@ export const MyWalletSection = () => {
>
{myWallet.address}
</a>
<CopyButton value={myWallet.address!} className="p-1 [&_i]:size-2.5" />
<CopyButton
value={myWallet.address!}
className="p-1 opacity-0 duration-200 group-hover:opacity-100 [&_i]:size-2.5"
/>
</div>
<SettingSectionTitle title={t("wallet.balance.title")} margin="compact" />
<div className="mb-2 flex items-end justify-between">
@@ -125,6 +127,7 @@ export const MyWalletSection = () => {
</Tooltip>
</div>
</div>
<Divider className="my-8" />
</>
)
@@ -7,7 +7,6 @@ import { Trans, useTranslation } from "react-i18next"
import { toast } from "sonner"
import { z } from "zod"
import { useWhoami } from "~/atoms/user"
import { Button } from "~/components/ui/button"
import {
Form,
@@ -44,8 +43,7 @@ export const WithdrawButton = () => {
const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
const { t } = useTranslation("settings")
const user = useWhoami()
const wallet = useWallet({ userId: user?.id })
const wallet = useWallet()
const cashablePowerTokenBigInt = [BigInt(wallet.data?.[0].cashablePowerToken || 0n), 18] as const
const cashablePowerTokenNumber = toNumber(cashablePowerTokenBigInt)
@@ -1,3 +1,4 @@
import { useState } from "react"
import { useTranslation } from "react-i18next"
import { useWhoami } from "~/atoms/user"
@@ -5,7 +6,6 @@ import { Logo } from "~/components/icons/logo"
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar"
import { MotionButtonBase } from "~/components/ui/button"
import { RelativeTime } from "~/components/ui/datetime"
import { LoadingCircle } from "~/components/ui/loading"
import {
Table,
TableBody,
@@ -14,88 +14,87 @@ import {
TableHeader,
TableRow,
} from "~/components/ui/table"
import { Tabs, TabsList, TabsTrigger } from "~/components/ui/tabs"
import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "~/components/ui/tooltip"
import { EllipsisHorizontalTextWithTooltip } from "~/components/ui/typography"
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
import { cn } from "~/lib/utils"
import { TransactionTypes } from "~/models/types"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { SettingSectionTitle } from "~/modules/settings/section"
import { Balance } from "~/modules/wallet/balance"
import { useWallet, useWalletTransactions } from "~/queries/wallet"
export const TransactionsSection = () => {
const tabs = ["all", ...TransactionTypes] as const
export const TransactionsSection: Component = ({ className }) => {
const { t } = useTranslation("settings")
const user = useWhoami()
const wallet = useWallet({ userId: user?.id })
const wallet = useWallet()
const myWallet = wallet.data?.[0]
const transactions = useWalletTransactions({ fromOrToUserId: user?.id })
const [type, setType] = useState("all")
const transactions = useWalletTransactions({
fromOrToUserId: user?.id,
type: type === "all" ? undefined : type,
})
if (!myWallet) return null
if (transactions.isLoading) {
return (
<div className="center mt-12">
<LoadingCircle size="large" />
</div>
)
}
return (
<div className="relative flex min-w-0 grow flex-col">
<SettingSectionTitle title={t("wallet.transactions.title")} />
<div className="w-fit min-w-0 grow overflow-x-auto">
<Tabs value={type} onValueChange={(val) => setType(val)}>
<TabsList className="relative -ml-2 border-b-transparent">
{tabs.map((tab) => (
<TabsTrigger key={tab} value={tab} className="py-0">
{t(`wallet.transactions.types.${tab}`)}
</TabsTrigger>
))}
</TabsList>
</Tabs>
<div className={cn("w-fit min-w-0 grow overflow-x-auto", className)}>
<Table className="w-full table-fixed">
<TableHeader>
<TableRow className="[&_*]:!font-semibold">
<TableHead className="whitespace-nowrap text-center" size="sm">
{t("wallet.transactions.type")}
</TableHead>
<TableHead className="whitespace-nowrap text-center" size="sm">
{t("wallet.transactions.amount")}
</TableHead>
<TableHead className="whitespace-nowrap pl-8" size="sm">
{t("wallet.transactions.from")}
</TableHead>
<TableHead className="whitespace-nowrap pl-8" size="sm">
{t("wallet.transactions.to")}
</TableHead>
<TableHead className="whitespace-nowrap pl-6" size="sm">
{t("wallet.transactions.date")}
</TableHead>
<TableHead className="whitespace-nowrap pl-6 text-center" size="sm">
{t("wallet.transactions.tx")}
</TableHead>
<TableHeader className="sticky top-0 z-10 bg-theme-background">
<TableRow className="[&_*]:!pl-0 [&_*]:!font-semibold">
<TableHead>{t("wallet.transactions.type")}</TableHead>
<TableHead>{t("wallet.transactions.amount")}</TableHead>
<TableHead>{t("wallet.transactions.from")}</TableHead>
<TableHead>{t("wallet.transactions.to")}</TableHead>
<TableHead>{t("wallet.transactions.date")}</TableHead>
<TableHead>{t("wallet.transactions.tx")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{transactions.data?.map((row) => (
<TableRow key={row.hash}>
<TableCell align="center" size="sm">
<TableCell align="left" size="sm">
<TypeRenderer type={row.type} />
</TableCell>
<TableCell align="center" size="sm">
<TableCell align="left" size="sm">
<BalanceRenderer
sign={row.fromUserId === user?.id ? "-" : "+"}
amount={row.powerToken}
/>
</TableCell>
<TableCell align="left" className="px-3" size="sm">
<TableCell align="left" size="sm">
<UserRenderer user={row.fromUser} />
</TableCell>
<TableCell align="left" className="truncate px-3" size="sm">
<TableCell align="left" size="sm">
<UserRenderer user={row.toUser} />
</TableCell>
<TableCell align="left" size="sm" className="whitespace-nowrap pl-6">
<RelativeTime date={row.createdAt} dateFormatTemplate="l" />
<TableCell align="left" size="sm">
<EllipsisHorizontalTextWithTooltip>
<RelativeTime date={row.createdAt} dateFormatTemplate="l" />
</EllipsisHorizontalTextWithTooltip>
</TableCell>
<TableCell align="left" size="sm" className="pl-6">
<TableCell align="left" size="sm">
<Tooltip>
<TooltipTrigger>
<a target="_blank" href={`https://scan.rss3.io/tx/${row.hash}`}>
{row.hash.slice(0, 6)}...
{row.hash.slice(0, 10)}...
</a>
</TooltipTrigger>
<TooltipPortal>
@@ -123,19 +122,7 @@ const TypeRenderer = ({
type: NonNullable<ReturnType<typeof useWalletTransactions>["data"]>[number]["type"]
}) => {
const { t } = useTranslation("settings")
return (
<div
className={cn("center rounded-full px-1.5 py-px text-xs uppercase", {
"bg-theme-accent-700 text-white": type === "tip",
"bg-green-700 text-white": type === "mint",
"bg-red-700 text-white": type === "burn",
"bg-yellow-700 text-white": type === "withdraw",
"bg-blue-700 text-white": type === "purchase",
})}
>
{t(`wallet.transactions.types.${type}`)}
</div>
)
return <div className="uppercase">{t(`wallet.transactions.types.${type}`)}</div>
}
const BalanceRenderer = ({
@@ -146,7 +133,7 @@ const BalanceRenderer = ({
amount: NonNullable<ReturnType<typeof useWalletTransactions>["data"]>[number]["powerToken"]
}) => (
<div
className={cn("flex items-center justify-center", {
className={cn("flex items-center", {
"text-green-500": sign === "+",
"text-red-500": sign === "-",
})}
@@ -16,6 +16,7 @@ import { ActionButton, Button } from "~/components/ui/button"
import { LoadingCircle, LoadingWithIcon } from "~/components/ui/loading"
import { useCurrentModal, useModalStack } from "~/components/ui/modal"
import { ScrollArea } from "~/components/ui/scroll-area"
import { EllipsisHorizontalTextWithTooltip } from "~/components/ui/typography"
import { useAuthQuery, useI18n } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { defineQuery } from "~/lib/defineQuery"
@@ -299,15 +300,20 @@ export const UserProfileModalContent: FC<{
className="center h-48 w-full max-w-full"
/>
) : (
subscriptions.data &&
Object.keys(subscriptions.data).map((category) => (
<SubscriptionGroup
key={category}
category={category}
subscriptions={subscriptions.data?.[category]}
itemStyle={itemStyle}
/>
))
subscriptions.data && (
<div className="flex w-full">
<div className="relative flex w-0 grow flex-col">
{Object.keys(subscriptions.data).map((category) => (
<SubscriptionGroup
key={category}
category={category}
subscriptions={subscriptions.data?.[category]}
itemStyle={itemStyle}
/>
))}
</div>
</div>
)
)}
</ScrollArea.ScrollArea>
</Fragment>
@@ -332,7 +338,11 @@ const SubscriptionGroup: FC<{
className="mb-2 mt-8 flex w-full items-center justify-between text-2xl font-bold"
type="button"
>
<h3>{category}</h3>
<h3 className="min-w-0 pr-1">
<EllipsisHorizontalTextWithTooltip className="min-w-0 truncate">
{category}
</EllipsisHorizontalTextWithTooltip>
</h3>
<div className="inline-flex shrink-0 items-center opacity-50">
<i
@@ -133,7 +133,7 @@ export const SettingGeneral = () => {
}),
{
label: t("general.rebuild_database.label"),
action: async () => {
action: () => {
present({
title: t("general.rebuild_database.title"),
clickOutsideToDismiss: true,
@@ -143,7 +143,7 @@ export const SettingGeneral = () => {
<p>{t("general.rebuild_database.warning.line2")}</p>
<div className="mt-4 flex justify-end">
<Button
className="bg-red-600 px-3 text-white dark:bg-red-500"
className="bg-red-500 px-3 text-white"
onClick={async () => {
await clearLocalPersistStoreData()
window.location.reload()
@@ -49,7 +49,9 @@ export const SettingInvitations = () => {
INVITATION_PRICE,
}}
components={{
PowerIcon: <i className="i-mgc-power ml-1 mr-0.5 text-base text-accent" />,
PowerIcon: (
<i className="i-mgc-power mx-0.5 size-3.5 -translate-y-px text-base text-accent" />
),
}}
i18nKey="invitation.generateCost"
/>
@@ -182,10 +184,9 @@ const ConfirmModalContent = ({ dismiss }: { dismiss: () => void }) => {
INVITATION_PRICE,
}}
components={{
PowerIcon: <i className="i-mgc-power mx-1 text-base text-accent" />,
div: <div />,
PowerIcon: <i className="i-mgc-power mx-0.5 size-3.5 -translate-y-px text-accent" />,
}}
i18nKey="invitation.confirmModal.message"
i18nKey="invitation.generateCost"
/>
</div>
<div className="mt-2 text-sm">{t("invitation.confirmModal.confirm")}</div>
@@ -1,4 +1,6 @@
import { WEB_URL } from "@follow/shared/constants"
import { useMutation } from "@tanstack/react-query"
import { toast } from "sonner"
import { Avatar, AvatarImage } from "~/components/ui/avatar"
import { Button } from "~/components/ui/button"
@@ -17,9 +19,11 @@ import {
import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "~/components/ui/tooltip"
import { views } from "~/constants"
import { useAuthQuery, useI18n } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { cn } from "~/lib/utils"
import { Balance } from "~/modules/wallet/balance"
import { Queries } from "~/queries"
import { listActions } from "~/store/list"
import { ListCreationModalContent, ListFeedsModalContent } from "./modals"
@@ -29,6 +33,24 @@ export const SettingLists = () => {
const { present } = useModalStack()
const deleteFeedList = useMutation({
mutationFn: async (payload: { listId: string }) => {
listActions.deleteList(payload.listId)
await apiClient.lists.$delete({
json: {
listId: payload.listId,
},
})
},
onSuccess: () => {
toast.success(t.settings("lists.delete.success"))
Queries.lists.list().invalidate()
},
async onError() {
toast.error(t.settings("lists.delete.error"))
},
})
return (
<section className="mt-4">
<div className="mb-4 space-y-2 text-sm">
@@ -140,6 +162,21 @@ export const SettingLists = () => {
<TooltipContent>{t.common("words.edit")}</TooltipContent>
</TooltipPortal>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="ghost"
onClick={() => {
deleteFeedList.mutate({ listId: row.id })
}}
>
<i className="i-mgc-delete-2-cute-re" />
</Button>
</TooltipTrigger>
<TooltipPortal>
<TooltipContent>{t.common("words.delete")}</TooltipContent>
</TooltipPortal>
</Tooltip>
</TableCell>
</TableRow>
))}
@@ -1,13 +0,0 @@
import { SettingsTitle } from "../../title"
import { MyWalletSection } from "./my-wallet-section"
import { TransactionsSection } from "./transaction-section"
export const SettingWallet = () => (
<div className="mt-4 flex grow flex-col">
<SettingsTitle />
<MyWalletSection />
<TransactionsSection />
</div>
)
+8 -4
View File
@@ -5,7 +5,6 @@ import { useTranslation } from "react-i18next"
import { getTrendingAggregates } from "~/api/trending"
import { FeedIcon } from "~/components/feed-icon"
import { IconoirBrightCrown } from "~/components/icons/crown"
import { PhUsersBold } from "~/components/icons/users"
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar"
import { ActionButton, Button } from "~/components/ui/button"
@@ -22,7 +21,7 @@ import type { FeedModel, Models } from "~/models"
import { usePresentUserProfileModal } from "../profile/hooks"
export const Trend = () => {
export const Trend = ({ className }: { className?: string }) => {
const { present } = useModalStack()
const { t } = useTranslation()
return (
@@ -40,6 +39,7 @@ export const Trend = () => {
className={cn(
"size-6 text-accent duration-200 hover:shadow-none",
"absolute bottom-1 right-3",
className,
)}
>
<i className="i-mgc-trending-up-cute-re" />
@@ -171,8 +171,12 @@ const TrendingUsers: FC<{ data: User[] }> = ({ data }) => {
<section className="w-full text-left">
<h2 className="my-2 text-xl font-bold">{t("trending.user")}</h2>
<div className="relative h-[100px]">
<div className="absolute left-[calc(50%+12px)] top-[12px] rotate-45 text-[20px] text-accent">
<IconoirBrightCrown />
<div className="absolute left-[calc(50%+15px)] top-[8px] rotate-45 text-[20px] text-accent">
<i className="i-mgc-vip-2-cute-fi" />
</div>
<div className="absolute left-[calc(33%+15px)] top-[calc(theme(spacing.3))] rotate-45 text-[20px] text-accent/80">
<i className="i-mgc-vip-2-cute-re" />
</div>
{data.slice(0, 3).map((user, index: number) => (
@@ -0,0 +1,41 @@
import type { FC } from "react"
import { useTranslation } from "react-i18next"
import { Link } from "react-router-dom"
import { LoginModalContent } from "~/modules/auth/LoginModalContent"
import { UserArrowLeftIcon } from "../../components/icons/user"
import { ActionButton } from "../../components/ui/button"
import { PlainModal } from "../../components/ui/modal/stacked/custom-modal"
import { useModalStack } from "../../components/ui/modal/stacked/hooks"
export interface LoginProps {
method?: "redirect" | "modal"
}
export const LoginButton: FC<LoginProps> = (props) => {
const { method } = props
const modalStack = useModalStack()
const { t } = useTranslation()
const Content = (
<ActionButton
className="relative z-[1]"
onClick={
method === "modal"
? () => {
modalStack.present({
CustomModalComponent: PlainModal,
title: "Login",
id: "login",
content: () => <LoginModalContent runtime={window.electron ? "app" : "browser"} />,
clickOutsideToDismiss: true,
})
}
: undefined
}
tooltip={t("words.login")}
>
<UserArrowLeftIcon className="size-4" />
</ActionButton>
)
return method === "modal" ? Content : <Link to="/login">{Content}</Link>
}
@@ -0,0 +1,224 @@
import { repository } from "@pkg"
import type { FC } from "react"
import { forwardRef, memo, useCallback, useLayoutEffect, useState } from "react"
import { useTranslation } from "react-i18next"
import { useNavigate } from "react-router-dom"
import { useSignOut } from "~/hooks/biz/useSignOut"
import { useMeasure } from "~/hooks/common"
import { nextFrame } from "~/lib/dom"
import { cn } from "~/lib/utils"
import { useAchievementModal } from "~/modules/achievement/hooks"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { useSettingModal } from "~/modules/settings/modal/hooks"
import { Balance } from "~/modules/wallet/balance"
import { useSession } from "~/queries/auth"
import { useWallet } from "~/queries/wallet"
import { ActionButton } from "../../components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "../../components/ui/dropdown-menu/dropdown-menu"
import { RootPortal } from "../../components/ui/portal"
import type { LoginProps } from "./LoginButton"
import { LoginButton } from "./LoginButton"
import { UserAvatar } from "./UserAvatar"
export const ProfileButton: FC<LoginProps> = memo((props) => {
const { status, session } = useSession()
const { user } = session || {}
const signOut = useSignOut()
const settingModalPresent = useSettingModal()
const presentUserProfile = usePresentUserProfileModal("dialog")
const presentAchievement = useAchievementModal()
const { t } = useTranslation()
const [dropdown, setDropdown] = useState(false)
const navigate = useNavigate()
if (status !== "authenticated") {
return <LoginButton {...props} />
}
return (
<>
<DropdownMenu onOpenChange={setDropdown}>
<DropdownMenuTrigger asChild className="!outline-none focus-visible:bg-theme-item-hover">
<TransitionAvatar stage={dropdown ? "zoom-in" : ""} />
</DropdownMenuTrigger>
<DropdownMenuContent
className="min-w-[180px] overflow-visible px-1 pt-4"
side="bottom"
align="center"
>
<DropdownMenuLabel>
<div className="text-center leading-none">
<div className="truncate text-lg">{user?.name}</div>
<div className="truncate text-xs font-medium text-zinc-500">{user?.handle}</div>
</div>
</DropdownMenuLabel>
<DropdownMenuItem
onClick={() => {
navigate("/power")
}}
>
<div className="flex w-full items-center justify-between gap-6 px-1.5 font-semibold">
<PowerButton />
<LevelButton />
</div>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="pl-3"
onClick={() => {
presentUserProfile(user?.id)
}}
icon={<i className="i-mgc-user-3-cute-re" />}
>
{t("user_button.profile")}
</DropdownMenuItem>
<DropdownMenuItem
className="pl-3"
onClick={() => {
presentAchievement()
}}
icon={<i className="i-mgc-trophy-cute-re" />}
>
{t("user_button.achievement")}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="pl-3"
onClick={() => {
nextFrame(settingModalPresent)
}}
icon={<i className="i-mgc-settings-7-cute-re" />}
>
{t("user_button.preferences")}
</DropdownMenuItem>
<DropdownMenuSeparator />
{!window.electron && (
<>
<DropdownMenuItem
className="pl-3"
onClick={() => {
window.open(`${repository.url}/releases`)
}}
icon={<i className="i-mgc-download-2-cute-re" />}
>
{t("user_button.download_desktop_app")}
</DropdownMenuItem>
<DropdownMenuSeparator />
</>
)}
<DropdownMenuItem
className="pl-3"
onClick={signOut}
icon={<i className="i-mgc-exit-cute-re" />}
>
{t("user_button.log_out")}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</>
)
})
ProfileButton.displayName = "ProfileButton"
const TransitionAvatar = forwardRef<
HTMLButtonElement,
{
stage: "zoom-in" | ""
} & React.HTMLAttributes<HTMLButtonElement>
>(({ stage, ...props }, forwardRef) => {
const [ref, { x, y }, forceRefresh] = useMeasure()
const [avatarHovered, setAvatarHovered] = useState(false)
const zoomIn = stage === "zoom-in"
const [currentZoomIn, setCurrentZoomIn] = useState(false)
useLayoutEffect(() => {
if (zoomIn) {
setCurrentZoomIn(true)
}
}, [zoomIn])
return (
<>
<ActionButton
{...props}
ref={forwardRef}
onMouseEnter={useCallback(() => {
forceRefresh()
setAvatarHovered(true)
}, [forceRefresh])}
onMouseLeave={useCallback(() => {
setAvatarHovered(false)
}, [])}
>
<UserAvatar ref={ref} className="h-6 p-0 [&_*]:border-0" hideName />
</ActionButton>
{x !== 0 && y !== 0 && (avatarHovered || zoomIn || currentZoomIn) && (
<RootPortal>
<UserAvatar
style={{
left: x - (zoomIn ? 16 : 0),
top: y,
}}
className={cn(
"pointer-events-none fixed -bottom-6 p-0 duration-200 [&_*]:border-0",
"transform-gpu will-change-[left,top,height]",
zoomIn ? "z-[999] h-14" : "z-[-1] h-6",
)}
hideName
onTransitionEnd={() => {
if (!zoomIn && currentZoomIn) {
setCurrentZoomIn(false)
}
}}
/>
</RootPortal>
)}
</>
)
})
function PowerButton() {
const wallet = useWallet()
const { isLoading } = wallet
const myWallet = wallet.data?.[0]
return (
<div className="flex items-center gap-1">
<i className="i-mgc-power text-accent" />
{isLoading ? (
<span className="h-3 w-8 animate-pulse rounded-xl bg-theme-inactive" />
) : (
<Balance>
{BigInt(myWallet?.dailyPowerToken || 0n) + BigInt(myWallet?.cashablePowerToken || 0n)}
</Balance>
)}
</div>
)
}
function LevelButton() {
return (
<div className="flex items-center gap-1">
<i className="i-mgc-vip-2-cute-fi text-accent" />
<span>Lv.1</span>
<sub className="-translate-y-px text-[0.6rem] font-normal">x1</sub>
</div>
)
}
@@ -0,0 +1,86 @@
import { forwardRef } from "react"
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar"
import { useAuthQuery } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { defineQuery } from "~/lib/defineQuery"
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
import { cn } from "~/lib/utils"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { useSession } from "~/queries/auth"
import type { LoginProps } from "./LoginButton"
import { LoginButton } from "./LoginButton"
export const UserAvatar = forwardRef<
HTMLDivElement,
{
className?: string
avatarClassName?: string
hideName?: boolean
userId?: string
enableModal?: boolean
} & LoginProps &
React.HTMLAttributes<HTMLDivElement>
>(
(
{ className, avatarClassName, hideName, userId, enableModal, style, onClick, ...props },
ref,
) => {
const { session, status } = useSession({
enabled: !userId,
})
const presentUserProfile = usePresentUserProfileModal("drawer")
const profile = useAuthQuery(
defineQuery(["profiles", userId], async () => {
const res = await apiClient.profiles.$get({
query: { id: userId! },
})
return res.data
}),
{
enabled: !!userId,
},
)
if (!userId && status !== "authenticated") {
return <LoginButton {...props} />
}
const renderUserData = userId ? profile.data : session?.user
return (
<div
style={style}
ref={ref}
onClick={(e) => {
if (enableModal) {
presentUserProfile(userId)
}
onClick?.(e)
}}
{...props}
className={cn(
"flex h-20 items-center justify-center gap-2 px-5 py-2 font-medium text-zinc-600 dark:text-zinc-300",
className,
)}
>
<Avatar
className={cn(
"aspect-square h-full w-auto overflow-hidden rounded-full border bg-stone-300",
avatarClassName,
)}
>
<AvatarImage
className="duration-200 animate-in fade-in-0"
src={replaceImgUrlIfNeed(renderUserData?.image || undefined)}
/>
<AvatarFallback>{renderUserData?.name?.slice(0, 2)}</AvatarFallback>
</Avatar>
{!hideName && <div>{renderUserData?.name}</div>}
</div>
)
},
)
UserAvatar.displayName = "UserAvatar"
@@ -2,16 +2,15 @@ import { from } from "dnum"
import type { FC } from "react"
import { useState } from "react"
import { useWhoami } from "~/atoms/user"
import { Button } from "~/components/ui/button"
import { Divider } from "~/components/ui/divider"
import { LoadingWithIcon } from "~/components/ui/loading"
import { useCurrentModal } from "~/components/ui/modal"
import { RadioGroup } from "~/components/ui/radio-group"
import { RadioCard } from "~/components/ui/radio-group/RadioCard"
import { UserAvatar } from "~/components/user-button"
import { useI18n } from "~/hooks/common"
import { nextFrame } from "~/lib/dom"
import { UserAvatar } from "~/modules/user/UserAvatar"
import { useWallet, useWalletTipMutation } from "~/queries/wallet"
import { useFeedClaimModal } from "../claim"
@@ -21,8 +20,7 @@ import { Balance } from "./balance"
const DEFAULT_RECOMMENDED_TIP = 10
const useMyWallet = () => {
const user = useWhoami()
const myWallet = useWallet({ userId: user?.id })
const myWallet = useWallet()
return myWallet
}
+1 -1
View File
@@ -5,9 +5,9 @@ import { useLocation, useNavigate } from "react-router-dom"
import { Logo } from "~/components/icons/logo"
import { Button } from "~/components/ui/button"
import { UserAvatar } from "~/components/user-button"
import { useSignOut } from "~/hooks/biz/useSignOut"
import { LOGIN_CALLBACK_URL, loginHandler } from "~/lib/auth"
import { UserAvatar } from "~/modules/user/UserAvatar"
export function Component() {
return (
@@ -5,8 +5,8 @@ import { useNavigate } from "react-router-dom"
import { PoweredByFooter } from "~/components/common/PoweredByFooter"
import { Button } from "~/components/ui/button"
import { UserAvatar } from "~/components/user-button"
import { apiClient } from "~/lib/api-fetch"
import { UserAvatar } from "~/modules/user/UserAvatar"
export function Component() {
const navigate = useNavigate()
@@ -14,7 +14,10 @@ export function Component() {
const getCallbackUrl = async () => {
const { data } = await apiClient["auth-app"]["new-session"].$post({})
return `${DEEPLINK_SCHEME}auth?token=${data.sessionToken}`
return {
url: `${DEEPLINK_SCHEME}auth?token=${data.sessionToken}&userId=${data.userId}`,
userId: data.userId,
}
}
const onceRef = useRef(false)
@@ -24,7 +27,7 @@ export function Component() {
if (window.electron) {
navigate("/")
} else {
getCallbackUrl().then((url) => {
getCallbackUrl().then(({ url }) => {
window.open(url, "_top")
// If you are in development, you can use the following code to open the app
@@ -42,13 +45,22 @@ export function Component() {
{t("redirect.instruction", { app_name: APP_NAME })}
</h2>
<div className="center flex flex-col gap-4 sm:flex-row">
<Button variant="text" className="h-14 px-10 text-base" onClick={() => navigate("/")}>
<Button
variant="text"
className="h-14 px-10 text-base"
onClick={() => {
navigate("/")
}}
>
{t("redirect.continueInBrowser")}
</Button>
<Button
className="h-14 !rounded-full px-5 text-lg"
onClick={async () => window.open(await getCallbackUrl(), "_top")}
onClick={async () => {
const { url } = await getCallbackUrl()
window.open(url, "_top")
}}
>
{t("redirect.openApp", { app_name: APP_NAME })}
</Button>
@@ -54,8 +54,8 @@ export function Component() {
useSubViewTitle("words.discover")
return (
<>
<div className="text-2xl font-bold">{t("words.discover")}</div>
<div className="flex flex-col items-center gap-8">
<div className="pt-12 text-2xl font-bold">{t("words.discover")}</div>
<Tabs
value={search.get("type") || "search"}
onValueChange={(val) => {
@@ -72,7 +72,7 @@ export function Component() {
</TabsTrigger>
))}
<Trend />
<Trend className="relative bottom-0 left-1.5" />
</TabsList>
{tabs.map((tab) => (
<TabsContent key={tab.name} value={tab.value} className="mt-8">
@@ -83,7 +83,7 @@ export function Component() {
))}
</Tabs>
<Recommendations />
</>
</div>
)
}
@@ -1,13 +1,18 @@
import { atom, useAtomValue } from "jotai"
import { useHydrateAtoms } from "jotai/utils"
import type { ReactNode } from "react"
import { useI18n, useTitle } from "~/hooks/common"
const titleAtom = atom<string | null>(null)
export const useSubViewTitle = (title: I18nKeys) => {
const titleAtom = atom<string | ReactNode | null>(null)
export function useSubViewTitle(title: I18nKeys): void
export function useSubViewTitle(title: ReactNode, fallbackTitleString: string): void
export function useSubViewTitle(title: I18nKeys | ReactNode, fallbackTitleString?: string) {
const t = useI18n()
useTitle(t(title))
useHydrateAtoms([[titleAtom, t(title)]])
useTitle(typeof title === "string" ? t(title as I18nKeys) : fallbackTitleString)
useHydrateAtoms([[titleAtom, typeof title === "string" ? t(title as I18nKeys) : title]])
}
export const useSubViewTitleValue = () => useAtomValue(titleAtom)
@@ -33,7 +33,7 @@ export function Component() {
return () => {
$scroll.removeEventListener("scroll", handler)
}
}, [scrollRef, title])
}, [scrollRef])
const { t } = useTranslation()
return (
@@ -67,7 +67,7 @@ export function Component() {
flex
ref={setRef}
rootClassName="w-full"
viewportClassName="pb-10 pt-40 [&>div]:items-center [&>div]:gap-8"
viewportClassName="pb-10 pt-28 [&>div]:items-center"
>
<Outlet />
</ScrollArea.ScrollArea>
@@ -0,0 +1,29 @@
import { useTranslation } from "react-i18next"
import { MyWalletSection } from "~/modules/power/my-wallet-section"
import { TransactionsSection } from "~/modules/power/transaction-section"
import { useSubViewTitle } from "../hooks"
export function Component() {
const { t } = useTranslation()
useSubViewTitle(
<div className="flex items-center gap-2">
<i className="i-mgc-power size-4 text-accent" />
{t("words.power")}
</div>,
t("words.power"),
)
return (
<div className="w-[768px] px-10">
<div className="center mb-8 flex h-24 items-center gap-2 text-3xl font-bold">
<div className="motion-preset-shake center text-accent motion-delay-500">
<i className="i-mgc-power size-20" />
</div>
</div>
<MyWalletSection />
<TransactionsSection />
</div>
)
}
@@ -29,6 +29,8 @@ export function Component() {
containerRef,
onResizeEnd({ position }) {
setUISetting("entryColWidth", position)
// TODO: Remove this after useMeasure can get bounds in time
window.dispatchEvent(new Event("resize"))
},
})
@@ -1,16 +0,0 @@
import { SettingWallet } from "~/modules/settings/tabs/wallet"
import { defineSettingPageData } from "~/modules/settings/utils"
const iconName = `i-mgc-power-outline`
const priority = 1040
export const loader = defineSettingPageData({
iconName,
name: "titles.power",
priority,
headerIcon: `i-mgc-power text-accent`,
})
export function Component() {
return <SettingWallet />
}
@@ -136,7 +136,7 @@ const Item = memo(({ item }: { item: NativeMenuItem }) => {
className="flex items-center gap-2"
checked={item.checked}
>
{item.icon && (
{!!item.icon && (
<span className="absolute left-2 flex items-center justify-center">{item.icon}</span>
)}
<span className={cn(item.icon && "pl-6")}>{item.label}</span>
@@ -10,6 +10,7 @@ import { useModalStack } from "~/components/ui/modal"
import { useFollow } from "~/hooks/biz/useFollow"
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
import { useSettingModal } from "~/modules/settings/modal/hooks"
import { clearDataIfLoginOtherAccount } from "~/store/utils/clear"
export const ExtensionExposeProvider = () => {
const { present } = useModalStack()
@@ -28,6 +29,10 @@ export const ExtensionExposeProvider = () => {
getWebUrl() {
return window.location.origin
},
clearIfLoginOtherAccount(newUserId: string) {
clearDataIfLoginOtherAccount(newUserId)
},
})
}, [])
useEffect(() => {
+6 -59
View File
@@ -1,79 +1,26 @@
import { views } from "~/constants"
import { apiClient } from "~/lib/api-fetch"
import { defineQuery } from "~/lib/defineQuery"
import { translate } from "~/lib/translate"
import type { SupportedLanguages } from "~/models"
import type { FlatEntryModel } from "~/store/entry"
const LanguageMap: Record<
SupportedLanguages,
{
code: string
}
> = {
en: {
code: "eng",
},
ja: {
code: "jpn",
},
"zh-CN": {
code: "cmn",
},
"zh-TW": {
code: "cmn",
},
}
export const ai = {
translation: ({
entry,
view,
language,
extraFields,
part,
}: {
entry: FlatEntryModel
view?: number
language?: SupportedLanguages
extraFields?: string[]
part?: string
}) =>
defineQuery(["translation", entry?.entries?.id, language], async () => {
if (!language) {
return null
}
let fields =
entry.settings?.translation && view !== undefined ? views[view!].translation.split(",") : []
if (extraFields) {
fields = [...fields, ...extraFields]
}
const { franc } = await import("franc-min")
fields = fields.filter((field) => {
if (entry.settings?.translation && entry.entries[field]) {
const sourceLanguage = franc(entry.entries[field])
if (sourceLanguage === LanguageMap[entry.settings?.translation].code) {
return false
} else {
return true
}
} else {
return false
}
})
if (fields.length > 0) {
const res = await apiClient.ai.translation.$get({
query: {
id: entry.entries.id,
language,
fields: fields?.join(",") || "title",
},
})
return res.data
} else {
return null
}
}),
defineQuery(["translation", entry?.entries?.id, language, part], () =>
translate({ entry, view, language, extraFields, part }),
),
summary: ({ entryId, language }: { entryId: string; language?: SupportedLanguages }) =>
defineQuery(["summary", entryId, language], async () => {
const res = await apiClient.ai.summary.$get({
+1 -2
View File
@@ -44,8 +44,7 @@ export const wallet = {
},
}
export const useWallet = ({ userId }: { userId?: string } = {}) =>
useAuthQuery(wallet.get({ userId }), { enabled: !!userId })
export const useWallet = () => useAuthQuery(wallet.get())
export const useWalletTransactions = (query: Parameters<typeof wallet.transactions.get>[0] = {}) =>
useAuthQuery(wallet.transactions.get(query))
+1
View File
@@ -9,6 +9,7 @@ type EntriesIdTable = Record<FeedId, EntryId[]>
export type FlatEntryModel = Omit<CombinedEntryModel, "feeds"> & {
feedId: FeedId
view?: number
}
export interface EntryState {
/**
+12
View File
@@ -1,3 +1,6 @@
import { useMemo } from "react"
import { useWhoami } from "~/atoms/user"
import type { FeedViewType } from "~/lib/enum"
import type { ListModel } from "~/models"
@@ -9,3 +12,12 @@ export const useListById = (listId: Nullable<string>): ListModel | null =>
export const useListByView = (view: FeedViewType) => {
return useListStore((state) => Object.values(state.lists).filter((list) => list.view === view))
}
export const useOwnedList = (view: FeedViewType) => {
const whoami = useWhoami()
const viewLists = useListByView(view)
return useMemo(
() => viewLists.filter((list) => list.ownerUserId === whoami?.id),
[viewLists, whoami],
)
}
+15
View File
@@ -73,12 +73,27 @@ class ListActionStatic {
})
}
async deleteList(listId: string) {
set((state) => {
delete state.lists[listId]
return state
})
runTransactionInScope(() => ListService.bulkDelete([listId]))
}
async fetchListById(id: string) {
const res = await apiClient.lists.$get({ query: { listId: id } })
this.upsertMany([res.data.list])
return res.data
}
async clear() {
set((state) => {
state.lists = {}
})
}
}
export const listActions = new ListActionStatic()
+20 -1
View File
@@ -1,15 +1,25 @@
import { clearUISettings } from "~/atoms/settings/ui"
import { browserDB } from "~/database"
import { getStorageNS } from "~/lib/ns"
import { entryActions } from "../entry"
import { feedActions } from "../feed"
import { clearImageDimensionsDb } from "../image/db"
import { inboxActions } from "../inbox"
import { listActions } from "../list"
import { subscriptionActions } from "../subscription"
import { feedUnreadActions } from "../unread"
export const clearLocalPersistStoreData = async () => {
// All clear and reset method will aggregate here
;[entryActions, subscriptionActions, feedUnreadActions, feedActions].forEach((actions) => {
;[
entryActions,
subscriptionActions,
feedUnreadActions,
feedActions,
listActions,
inboxActions,
].forEach((actions) => {
actions.clear()
})
@@ -18,3 +28,12 @@ export const clearLocalPersistStoreData = async () => {
await clearImageDimensionsDb()
await browserDB.delete().catch(() => null)
}
const storedUserId = getStorageNS("user_id")
export const clearDataIfLoginOtherAccount = (newUserId: string) => {
const oldUserId = localStorage.getItem(storedUserId)
localStorage.setItem(storedUserId, newUserId)
if (oldUserId !== newUserId) {
return clearLocalPersistStoreData()
}
}
+23 -1
View File
@@ -1,5 +1,5 @@
// @ts-check
import { defineConfig } from "eslint-config-hyoban"
import { defineConfig, GLOB_TS_SRC } from "eslint-config-hyoban"
import checkI18nJson from "./plugins/eslint/eslint-check-i18n-json.js"
import noDebug from "./plugins/eslint/eslint-no-debug.js"
@@ -16,6 +16,26 @@ export default defineConfig(
"resources/**",
],
preferESM: false,
projectService: {
allowDefaultProject: ["apps/main/preload/index.d.ts"],
defaultProject: "tsconfig.json",
},
typeChecked: "essential",
},
{
files: GLOB_TS_SRC,
rules: {
"require-await": "off",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-misused-promises": [
"warn",
{
checksVoidReturn: { arguments: false, attributes: false },
},
],
},
},
{
settings: {
@@ -27,10 +47,12 @@ export default defineConfig(
"no-debug": noDebug,
},
rules: {
"@typescript-eslint/no-floating-promises": "off",
"no-debug/no-debug-stack": "error",
"unicorn/prefer-math-trunc": "off",
"@eslint-react/no-clone-element": 0,
"@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": 0,
"@typescript-eslint/no-misused-promises": 0,
// NOTE: Disable this temporarily
"react-compiler/react-compiler": 0,
"no-restricted-syntax": 0,
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="#fff" fill-opacity=".01" d="M24 0v24H0V0z"/><path fill="#10161F" fill-rule="evenodd" d="M10 4a2 2 0 1 1 2.987 1.74c.275.548.585 1.08.916 1.596.526.818 1.172 1.813 2.06 2.278 1.14.596 2.717.474 4.043.256a1.5 1.5 0 1 1 1.768 1.605l-1.51 3.902c-.449 1.156-.813 2.098-1.193 2.833-.396.767-.847 1.391-1.513 1.864-.719.512-1.562.744-2.43.838-.886.095-1.78.092-2.671.089L12 21l-.457.001c-.89.003-1.785.006-2.67-.09-.869-.093-1.712-.325-2.43-.837-.667-.473-1.118-1.098-1.514-1.864-.38-.735-.744-1.677-1.192-2.833l-1.511-3.902A1.5 1.5 0 1 1 3.994 9.87c1.326.218 2.902.34 4.043-.256.889-.465 1.534-1.46 2.06-2.278.332-.516.641-1.048.916-1.596A2 2 0 0 1 10 4" clip-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 763 B

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="#fff" fill-opacity=".01" d="M24 0v24H0V0z"/><path stroke="#10161F" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 4a1 1 0 1 1-2 0 1 1 0 0 1 2 0M12 20c2.573 0 3.86 0 4.862-.66a4.19 4.19 0 0 0 .116-.08c.978-.696 1.443-1.896 2.372-4.295l1.65-4.26s-3.7.736-5.5-.205C13.7 9.559 12 6 12 6s-1.7 3.765-3.5 4.706c-1.8.941-5.5 0-5.5 0l1.65 4.259c.929 2.4 1.394 3.599 2.372 4.295l.116.08C8.14 20 9.427 20 12 20"/><path fill="#10161F" d="M4 10a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M23 10a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"/></svg>

After

Width:  |  Height:  |  Size: 629 B

-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "فشل في الحفظ إلى Eagle.",
"entry_actions.failed_to_save_to_instapaper": "فشل في الحفظ إلى Instapaper.",
"entry_actions.failed_to_save_to_readwise": "فشل في الحفظ إلى Readwise.",
"entry_actions.link_copied": "تم نسخ الرابط إلى الحافظة.",
"entry_actions.mark_as_read": "تحديد كمقروء",
"entry_actions.mark_as_unread": "تحديد كغير مقروء",
"entry_actions.open_in_browser": "فتح في المتصفح",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "فشل في الحفظ إلى Eagle.",
"entry_actions.failed_to_save_to_instapaper": "فشل في الحفظ إلى Instapaper.",
"entry_actions.failed_to_save_to_readwise": "فشل في الحفظ إلى Readwise.",
"entry_actions.link_copied": "تم نسخ الرابط إلى الحافظة.",
"entry_actions.mark_as_read": "تحديد كمقروء",
"entry_actions.mark_as_unread": "تحديد كغير مقروء",
"entry_actions.open_in_browser": "فتح في المتصفح",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "فشل في الحفظ إلى Eagle.",
"entry_actions.failed_to_save_to_instapaper": "فشل في الحفظ إلى Instapaper.",
"entry_actions.failed_to_save_to_readwise": "فشل في الحفظ إلى Readwise.",
"entry_actions.link_copied": "تم نسخ الرابط إلى الحافظة.",
"entry_actions.mark_as_read": "وضع علامة كمقروء",
"entry_actions.mark_as_unread": "وضع علامة كغير مقروء",
"entry_actions.open_in_browser": "فتح في المتصفح",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "فشل الحفظ إلى Eagle.",
"entry_actions.failed_to_save_to_instapaper": "فشل الحفظ إلى Instapaper.",
"entry_actions.failed_to_save_to_readwise": "فشل الحفظ إلى Readwise.",
"entry_actions.link_copied": "تم نسخ الرابط إلى الحافظة.",
"entry_actions.mark_as_read": "وضع علامة كمقروء",
"entry_actions.mark_as_unread": "وضع علامة كغير مقروء",
"entry_actions.open_in_browser": "فتح في المتصفح",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "فشل في الحفظ إلى Eagle.",
"entry_actions.failed_to_save_to_instapaper": "فشل في الحفظ إلى Instapaper.",
"entry_actions.failed_to_save_to_readwise": "فشل في الحفظ إلى Readwise.",
"entry_actions.link_copied": "تم نسخ الرابط إلى الحافظة.",
"entry_actions.mark_as_read": "تحديد كمقروء",
"entry_actions.mark_as_unread": "تحديد كغير مقروء",
"entry_actions.open_in_browser": "فتح في المتصفح",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "فشل في الحفظ إلى Eagle.",
"entry_actions.failed_to_save_to_instapaper": "فشل في الحفظ إلى Instapaper.",
"entry_actions.failed_to_save_to_readwise": "فشل في الحفظ إلى Readwise.",
"entry_actions.link_copied": "تم نسخ الرابط إلى الحافظة.",
"entry_actions.mark_as_read": "وضع علامة كمقروء",
"entry_actions.mark_as_unread": "وضع علامة كغير مقروء",
"entry_actions.open_in_browser": "فتح في المتصفح",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "Speichern in Eagle fehlgeschlagen.",
"entry_actions.failed_to_save_to_instapaper": "Speichern in Instapaper fehlgeschlagen.",
"entry_actions.failed_to_save_to_readwise": "Speichern in Readwise fehlgeschlagen.",
"entry_actions.link_copied": "Link in die Zwischenablage kopiert.",
"entry_actions.mark_as_read": "Als gelesen markieren",
"entry_actions.mark_as_unread": "Als ungelesen markieren",
"entry_actions.open_in_browser": "Im Browser öffnen",
+39 -39
View File
@@ -51,30 +51,29 @@
"discover.target.label": "Search for",
"discover.target.lists": "Lists",
"early_access": "Early Access",
"entry_actions.copy_link": "Copy link",
"entry_actions.copy_title": "Copy title",
"entry_actions.copied_notify": "{{which}} copied to clipboard.",
"entry_actions.copy_link": "Copy Link",
"entry_actions.copy_title": "Copy Title",
"entry_actions.failed_to_save_to_eagle": "Failed to save to Eagle.",
"entry_actions.failed_to_save_to_instapaper": "Failed to save to Instapaper.",
"entry_actions.failed_to_save_to_readwise": "Failed to save to Readwise.",
"entry_actions.link_copied": "Link copied to clipboard.",
"entry_actions.mark_as_read": "Mark as read",
"entry_actions.mark_as_unread": "Mark as unread",
"entry_actions.open_in_browser": "Open in {{which}}",
"entry_actions.mark_as_read": "Mark as Read",
"entry_actions.mark_as_unread": "Mark as Unread",
"entry_actions.open_in_browser": "Open In {{which}}",
"entry_actions.recent_reader": "Recent reader:",
"entry_actions.save_media_to_eagle": "Save media to Eagle",
"entry_actions.save_to_instapaper": "Save to Instapaper",
"entry_actions.save_to_readwise": "Save to Readwise",
"entry_actions.saved_to_eagle": "Saved to Eagle.",
"entry_actions.saved_to_instapaper": "Saved to Instapaper.",
"entry_actions.saved_to_readwise": "Saved to Readwise.",
"entry_actions.save_media_to_eagle": "Save Media To Eagle",
"entry_actions.save_to_instapaper": "Save To Instapaper",
"entry_actions.save_to_readwise": "Save To Readwise",
"entry_actions.saved_to_eagle": "Saved To Eagle.",
"entry_actions.saved_to_instapaper": "Saved To Instapaper.",
"entry_actions.saved_to_readwise": "Saved To Readwise.",
"entry_actions.share": "Share",
"entry_actions.star": "Star",
"entry_actions.starred": "Starred.",
"entry_actions.tip": "Tip",
"entry_actions.title_copied": "Title copied to clipboard.",
"entry_actions.unstar": "Unstar",
"entry_actions.unstarred": "Unstarred.",
"entry_actions.view_source_content": "View source content",
"entry_actions.view_source_content": "View Source Content",
"entry_column.filtered_content_tip": "You have filtered content hidden.",
"entry_column.filtered_content_tip_2": "In addition to the entries shown above, there is also filtered content.",
"entry_column.refreshing": "Refreshing new entries...",
@@ -200,33 +199,33 @@
"sidebar.category_remove_dialog.title": "Remove Category",
"sidebar.feed_actions.claim": "Claim",
"sidebar.feed_actions.claim_feed": "Claim Feed",
"sidebar.feed_actions.copy_email_address": "Copy email address",
"sidebar.feed_actions.copy_feed_id": "Copy feed ID",
"sidebar.feed_actions.copy_feed_url": "Copy feed URL",
"sidebar.feed_actions.copy_list_id": "Copy list ID",
"sidebar.feed_actions.copy_list_url": "Copy list URL",
"sidebar.feed_actions.create_list": "Create New list",
"sidebar.feed_actions.copy_email_address": "Copy Email Address",
"sidebar.feed_actions.copy_feed_id": "Copy Feed ID",
"sidebar.feed_actions.copy_feed_url": "Copy Feed URL",
"sidebar.feed_actions.copy_list_id": "Copy List ID",
"sidebar.feed_actions.copy_list_url": "Copy List URL",
"sidebar.feed_actions.create_list": "Create New List",
"sidebar.feed_actions.edit": "Edit",
"sidebar.feed_actions.edit_feed": "Edit feed",
"sidebar.feed_actions.edit_inbox": "Edit inbox",
"sidebar.feed_actions.edit_list": "Edit list",
"sidebar.feed_actions.edit_feed": "Edit Feed",
"sidebar.feed_actions.edit_inbox": "Edit Inbox",
"sidebar.feed_actions.edit_list": "Edit List",
"sidebar.feed_actions.feed_owned_by_you": "This feed is owned by you",
"sidebar.feed_actions.list_owned_by_you": "This list is owned by you",
"sidebar.feed_actions.mark_all_as_read": "Mark all as read",
"sidebar.feed_actions.navigate_to_feed": "Navigate to feed",
"sidebar.feed_actions.navigate_to_list": "Navigate to list",
"sidebar.feed_actions.new_inbox": "New inbox",
"sidebar.feed_actions.open_feed_in_browser": "Open feed in {{which}}",
"sidebar.feed_actions.open_list_in_browser": "Open list in {{which}}",
"sidebar.feed_actions.open_site_in_browser": "Open site in {{which}}",
"sidebar.feed_actions.list_owned_by_you": "This List is owned by you",
"sidebar.feed_actions.mark_all_as_read": "Mark All as Read",
"sidebar.feed_actions.navigate_to_feed": "Navigate to Feed",
"sidebar.feed_actions.navigate_to_list": "Navigate to List",
"sidebar.feed_actions.new_inbox": "New Inbox",
"sidebar.feed_actions.open_feed_in_browser": "Open Feed in {{which}}",
"sidebar.feed_actions.open_list_in_browser": "Open List in {{which}}",
"sidebar.feed_actions.open_site_in_browser": "Open Site in {{which}}",
"sidebar.feed_actions.unfollow": "Unfollow",
"sidebar.feed_actions.unfollow_feed": "Unfollow feed",
"sidebar.feed_column.context_menu.add_feeds_to_list": "Add feeds to list",
"sidebar.feed_column.context_menu.change_to_other_view": "Switch to another view",
"sidebar.feed_column.context_menu.delete_category": "Delete category",
"sidebar.feed_column.context_menu.delete_category_confirmation": "Delete category {{folderName}}?",
"sidebar.feed_column.context_menu.mark_as_read": "Mark as read",
"sidebar.feed_column.context_menu.rename_category": "Rename category",
"sidebar.feed_actions.unfollow_feed": "Unfollow Feed",
"sidebar.feed_column.context_menu.add_feeds_to_list": "Add Feeds to List",
"sidebar.feed_column.context_menu.change_to_other_view": "Switch to Another View",
"sidebar.feed_column.context_menu.delete_category": "Delete Category",
"sidebar.feed_column.context_menu.delete_category_confirmation": "Delete Category {{folderName}}?",
"sidebar.feed_column.context_menu.mark_as_read": "Mark as Read",
"sidebar.feed_column.context_menu.rename_category": "Rename Category",
"sidebar.select_sort_method": "Select a sort method",
"signin.continue_with_github": "Continue with GitHub",
"signin.continue_with_google": "Continue with Google",
@@ -234,7 +233,6 @@
"sync_indicator.disabled": "Due to security reasons, sync is disabled.",
"sync_indicator.offline": "Offline",
"sync_indicator.synced": "Synced with server",
"test": "Mark <which /> as readdddd",
"tip_modal.amount": "Amount",
"tip_modal.claim_feed": "Claim this feed",
"tip_modal.create_wallet": "Create For Free",
@@ -273,6 +271,7 @@
"words.inbox": "Inbox",
"words.items": "Items",
"words.language": "Language",
"words.link": "Link",
"words.lists": "Lists",
"words.load_archived_entries": "Load archived entries",
"words.login": "Login",
@@ -284,6 +283,7 @@
"words.rsshub": "RSSHub",
"words.search": "Search",
"words.starred": "Starred",
"words.title": "Title",
"words.trending": "Trending",
"words.undo": "Undo",
"words.unread": "Unread",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "Tallennus Eagleen epäonnistui.",
"entry_actions.failed_to_save_to_instapaper": "Tallennus Instapaperiin epäonnistui.",
"entry_actions.failed_to_save_to_readwise": "Tallennus Readwiseen epäonnistui.",
"entry_actions.link_copied": "Linkki kopioitu leikepöydälle.",
"entry_actions.mark_as_read": "Merkitse luetuksi",
"entry_actions.mark_as_unread": "Merkitse lukemattomaksi",
"entry_actions.open_in_browser": "Avaa selaimessa",
-1
View File
@@ -19,7 +19,6 @@
"entry_actions.failed_to_save_to_eagle": "Échec de l'enregistrement sur Eagle.",
"entry_actions.failed_to_save_to_instapaper": "Échec de l'enregistrement sur Instapaper.",
"entry_actions.failed_to_save_to_readwise": "Échec de l'enregistrement sur Readwise.",
"entry_actions.link_copied": "Lien copié dans le presse-papiers.",
"entry_actions.mark_as_read": "Marquer comme lu",
"entry_actions.mark_as_unread": "Marquer comme non lu",
"entry_actions.open_in_browser": "Ouvrir dans le navigateur",

Some files were not shown because too many files have changed in this diff Show More