diff --git a/.github/workflows/auto-fix-lint-format-commit.yml b/.github/workflows/auto-fix-lint-format-commit.yml new file mode 100644 index 000000000..d8b4cb1de --- /dev/null +++ b/.github/workflows/auto-fix-lint-format-commit.yml @@ -0,0 +1,63 @@ +name: Auto Fix Lint and Format + +on: + pull_request_target: + types: [opened, synchronize] + +jobs: + auto-fix: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Run linter and fix issues + run: pnpm run lint:fix + + - name: Run formatter + run: pnpm run format + + - name: Check for changes + id: check_changes + run: | + git diff --exit-code || echo "has_changes=true" >> $GITHUB_ENV + + - name: Commit and push changes + if: steps.check_changes.outputs.has_changes == 'true' || env.has_changes == 'true' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore: auto-fix linting and formatting issues" + commit_options: "--no-verify" + file_pattern: "." + + - name: Add PR comment + if: steps.check_changes.outputs.has_changes == 'true' || env.has_changes == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Linting and formatting issues were automatically fixed. Please review the changes.' + }); diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c4b801a0..e73176ce8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,14 +51,6 @@ jobs: fetch-depth: 1 lfs: true - - name: Cache pnpm modules - uses: actions/cache@v4 - with: - path: ~/.pnpm-store - key: ${{ matrix.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ matrix.os }}- - - name: Setup pnpm uses: pnpm/action-setup@v4 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index fef4b2064..b6d5a4013 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -54,7 +54,36 @@ jobs: if: runner.os == 'macOS' run: pnpm add -g appdmg - # ... (macOS certificate and provisioning profile setup steps) ... + - name: Install the Apple certificate and provisioning profile + if: runner.os == 'macOS' + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + PP_PATH=$RUNNER_TEMP/build_pp.provisionprofile + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + + # import certificate and provisioning profile from secrets + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH + echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH + + # create temporary keychain + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + + # import certificate to keychain + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + + # apply provisioning profile + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles - name: Install dependencies run: pnpm i diff --git a/CHANGELOG.md b/CHANGELOG.md index b465d468c..dee3848f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## [0.0.1-alpha.16](https://github.com/RSSNext/follow/compare/v0.0.1-alpha.3...v0.0.1-alpha.16) (2024-09-22) +## [0.0.1-alpha.17](https://github.com/RSSNext/follow/compare/v0.0.1-alpha.3...v0.0.1-alpha.17) (2024-09-23) ### Bug Fixes @@ -44,6 +44,7 @@ * allow prod and dev builds running in the same time ([#479](https://github.com/RSSNext/follow/issues/479)) ([7140751](https://github.com/RSSNext/follow/commit/7140751bc2c068782b6e9e9255754629d89152c9)) * allow toggle switch by clicking label ([#185](https://github.com/RSSNext/follow/issues/185)) ([5d98eb4](https://github.com/RSSNext/follow/commit/5d98eb42303e4ba6bbe0bfd37d8a17b31f66658a)) * alpha typo ([961a75c](https://github.com/RSSNext/follow/commit/961a75cd46227c7bb11bae3743b970b2884ccc44)) +* app width limit to 1024px ([09d7765](https://github.com/RSSNext/follow/commit/09d77657a07f81d69f80c3eea1620efe1ddb9da9)) * audio player async logic and auto pause logic ([ba40b44](https://github.com/RSSNext/follow/commit/ba40b44ce91bb8acd118b9c6d846ed8d5b9b022c)) * audioCover animation and estimatedMins style ([#523](https://github.com/RSSNext/follow/issues/523)) ([11ff31b](https://github.com/RSSNext/follow/commit/11ff31bd40af1884a1760d0d1ca5b9a726f13620)) * auto completion can not open when focus in modal ([591f13b](https://github.com/RSSNext/follow/commit/591f13b17f8a22c0c39718d67a88b2024c57efb7)) @@ -58,6 +59,8 @@ * catch access stylesheet error ([bbc2bef](https://github.com/RSSNext/follow/commit/bbc2bef800c5b01669742bb004e2656c9087f82f)) * category in route should encodeURLComponent ([d5b79cb](https://github.com/RSSNext/follow/commit/d5b79cba8a5d6d8fe18efee5d58da5610fc3ce68)) * check undefined view ([71712f4](https://github.com/RSSNext/follow/commit/71712f464d2ab3043b602d4d2c311e4cc851e046)) +* ci ([a5a4de0](https://github.com/RSSNext/follow/commit/a5a4de00e3612b7799869d133b893817dbcf82f4)) +* ci ([8852a81](https://github.com/RSSNext/follow/commit/8852a81d4cfe80a0704bcf52220c39e9ccbe98de)) * ci and tootip portal ([3729917](https://github.com/RSSNext/follow/commit/37299173c8fcaf88d44b1a54baf7ddc03aa20ca6)) * ci env `NODE_OPTIONS` max-old-space-size ([b4f9b1b](https://github.com/RSSNext/follow/commit/b4f9b1b8ea326b1613ca291ed5bbcd932c5e837a)) * **ci:** fetch all depth ([a504a12](https://github.com/RSSNext/follow/commit/a504a127bca93a6675b3ff02bcea0b1eca6e9707)) @@ -111,6 +114,7 @@ * entry preview modal content ([8492c2a](https://github.com/RSSNext/follow/commit/8492c2afb3af79726b9448359a63b432b04a3518)) * entry read history more not showing on desktop ([0c6494b](https://github.com/RSSNext/follow/commit/0c6494b5682078fa1da1ea2e6f5d81aa436a5155)) * entry view tracker params ([0c05a8b](https://github.com/RSSNext/follow/commit/0c05a8b88c1c385b7809f1ea9e3355f0d11e69dd)) +* **eslint:** json sort key ([5a81dd6](https://github.com/RSSNext/follow/commit/5a81dd6786b7c0e4a533f3cb4e50d7900d005875)) * exit full screen before hiding window ([#341](https://github.com/RSSNext/follow/issues/341)) ([bd5b08f](https://github.com/RSSNext/follow/commit/bd5b08f314ddaddb9b079b3d10b6928d28962df5)) * **exteral:** edit or follow in web app when login ([0ccadf7](https://github.com/RSSNext/follow/commit/0ccadf762bf5c761115a485ab4e68be938c527e6)) * **external-page:** feed list overlay style ([1dcffc6](https://github.com/RSSNext/follow/commit/1dcffc60d26596065bc024653d69a109a1941578)) @@ -158,7 +162,10 @@ * icon fallback line height ([02cd98d](https://github.com/RSSNext/follow/commit/02cd98d9cc9c09006a91277a5b976d753054738d)) * image url replacement ([8e75a8c](https://github.com/RSSNext/follow/commit/8e75a8cc6931b354e3206ea22917842c991d4c45)) * import circular and copywrite i18n ([725f9f5](https://github.com/RSSNext/follow/commit/725f9f5509c3b34079923fad47096b108568ccd6)) +* import circular and copywrite i18n ([caf5fe5](https://github.com/RSSNext/follow/commit/caf5fe5c839cc68aec786114b5a659cc8352d167)) +* import type error ([0658c4a](https://github.com/RSSNext/follow/commit/0658c4ab6bd3e9bbbb87a9faf07d00fc04aa0bc1)) * improve code block parser ([e72cb2d](https://github.com/RSSNext/follow/commit/e72cb2df3f1f5cd314feeb4a9bcc20e30204bca5)) +* improve input component display on focus ([#581](https://github.com/RSSNext/follow/issues/581)) ([d8ddffb](https://github.com/RSSNext/follow/commit/d8ddffbc481dc086c8d1d2cd0c80bdef9126f306)) * incorrect tooltip in read history ([#385](https://github.com/RSSNext/follow/issues/385)) ([cabe210](https://github.com/RSSNext/follow/commit/cabe210aaf8f4a1133fa653532874fa86d02c252)) * inline table style ([5837bd4](https://github.com/RSSNext/follow/commit/5837bd4089b59855d0b583aed5d0e97fce04e094)) * Input issues fixed [#535](https://github.com/RSSNext/follow/issues/535),[#536](https://github.com/RSSNext/follow/issues/536) ([3d48637](https://github.com/RSSNext/follow/commit/3d486379b91dff13bfbcc90532efd3e186405a13)) @@ -172,7 +179,10 @@ * link underline style when selected ([781b120](https://github.com/RSSNext/follow/commit/781b1200f8eae3f61b39dc53151c5a688fa36d1b)) * lint ([ef0d80d](https://github.com/RSSNext/follow/commit/ef0d80d8546c804b1b52c58fca7640d2f541188a)) * list item overlay style ([20ef773](https://github.com/RSSNext/follow/commit/20ef77342e73d205409644386c162dc164da009e)) +* list manage Modal button zh-cn word wrap ([#590](https://github.com/RSSNext/follow/issues/590)) ([0a89c2f](https://github.com/RSSNext/follow/commit/0a89c2ff73a0fde28c85b87401185332975264e0)) * **list:** adjust power fee ([47fc1ff](https://github.com/RSSNext/follow/commit/47fc1ff7c40961d102caf31c30d9a1eed8a98475)) +* lists date group ([b57f43f](https://github.com/RSSNext/follow/commit/b57f43fbcc407fe6d6e81b6c6cfbbc38a7d52f68)) +* lists edit follow modal in external page ([9cfe2ab](https://github.com/RSSNext/follow/commit/9cfe2ab68531384c0448806cd7366e5c4722461c)) * loadFile options hash ([b41fa66](https://github.com/RSSNext/follow/commit/b41fa665fa334f0037de294d8e0585a5cf94c649)) * loading circle clip path ([ba396be](https://github.com/RSSNext/follow/commit/ba396beaa78eae3c1b250fd846cc8434c2abc07f)) * loading style ([61ee2cc](https://github.com/RSSNext/follow/commit/61ee2ccb3e30d3ab82de0bfe6aca35df38794dca)) @@ -237,6 +247,7 @@ * remove windows under blur and ensure main window in the screen bounds ([d772343](https://github.com/RSSNext/follow/commit/d7723435a1527e5f9c065c36bf1d1d81b3b43ec4)) * rename category input composition and style ([1ab3770](https://github.com/RSSNext/follow/commit/1ab3770f0279eb043f7a37a1b5251e5ead0ef0b6)) * reorganize package.json ([b2c48a4](https://github.com/RSSNext/follow/commit/b2c48a49e3789cb3dfd9e9170f5371fc6b25c4b1)) +* require title for list form ([#575](https://github.com/RSSNext/follow/issues/575)) ([b5aeada](https://github.com/RSSNext/follow/commit/b5aeada3cbe1f9f1b1a856c5a3a766a886e29d0d)) * reset is archived state on reset ([b701dd6](https://github.com/RSSNext/follow/commit/b701dd6e1badeaf0d0470bcff28abc3fb4057893)) * resizeable panel ([e2664c2](https://github.com/RSSNext/follow/commit/e2664c2dda663343fa8f53536d6b625daaba6103)) * Respect app light/dark mode over OS preference [#228](https://github.com/RSSNext/follow/issues/228) ([ecef3e9](https://github.com/RSSNext/follow/commit/ecef3e961a79ac9c99bf9a419fa7573433148da0)) @@ -302,6 +313,7 @@ * toc scroll logic ([261d12e](https://github.com/RSSNext/follow/commit/261d12e5600028a5bff3b2c1451271ee962403ed)) * tooltip in dark mode shadow ([55266ce](https://github.com/RSSNext/follow/commit/55266ce2cceea4e348c33989398f8f9bb92644a7)) * tooltip style in dark mode ([a61c79e](https://github.com/RSSNext/follow/commit/a61c79ee7d4bd73fdf35fa5565c711297a29c7a0)) +* transcation table text overflow ([a026c6e](https://github.com/RSSNext/follow/commit/a026c6e34c0eeac1ee6acec1c8181c009ca0ab36)) * translation markdown tooltip wrapper style ([639bace](https://github.com/RSSNext/follow/commit/639bace313311db6319fb1fe168b68af7aa1e8e0)) * try fix vercel config ([968dea9](https://github.com/RSSNext/follow/commit/968dea91f474a76298091de6a23f3ba7a11fb22f)) * try to fix some sentry error ([0b31c1e](https://github.com/RSSNext/follow/commit/0b31c1e998212900dda0044acda8a3d4d5df1189)) @@ -312,6 +324,7 @@ * type error ([c7f11f9](https://github.com/RSSNext/follow/commit/c7f11f99f28bf918aaf8c03b74145b2f9b126a72)) * type error ([5cd41ad](https://github.com/RSSNext/follow/commit/5cd41ad10ccbd241083d6f951509eb0bafe6e25f)) * type error ([60f8347](https://github.com/RSSNext/follow/commit/60f8347eec118176681a9ad7fcab7f45e383fc1b)) +* types ([831f0f8](https://github.com/RSSNext/follow/commit/831f0f892ac32bdb2963267e94c3130805924b59)) * types ([a116dd4](https://github.com/RSSNext/follow/commit/a116dd4018f90886239f7583cbc82b511ff2a902)) * types ([3c5b224](https://github.com/RSSNext/follow/commit/3c5b224904e8db1c8ba6b78cfb87d09cd81de98c)) * types ([7f5bb1e](https://github.com/RSSNext/follow/commit/7f5bb1e9343243f5259f9fde8ee3ac44bf993913)) @@ -336,6 +349,7 @@ * upgrade tip when player open ([033831b](https://github.com/RSSNext/follow/commit/033831bdab0a85a2f1f02af85c6da2278e40de5e)) * upload sentry sourcemap ([b23365f](https://github.com/RSSNext/follow/commit/b23365faad9927826140948b642c0caca542f135)) * use feed enabled condition ([9726d43](https://github.com/RSSNext/follow/commit/9726d4396673e2be02c60ce049ed07c5bf978380)) +* use insertedAt as cursor for list ([#580](https://github.com/RSSNext/follow/issues/580)) ([e420451](https://github.com/RSSNext/follow/commit/e420451afc4eba6308ecf72ff710f390ee2b0b8b)) * use official embed player in bilibili video when use web ([#219](https://github.com/RSSNext/follow/issues/219)) ([9177a34](https://github.com/RSSNext/follow/commit/9177a349e087cdc60b22e2338146caaefd377694)) * user avatar use profile data if userId passed, fixed [#550](https://github.com/RSSNext/follow/issues/550) ([176afa7](https://github.com/RSSNext/follow/commit/176afa72ba1e0801ac383982f826cc19b215b242)) * user button color in dark mode ([04e3c38](https://github.com/RSSNext/follow/commit/04e3c386c5699e6b0907de2a98701668fc7f278b)) @@ -377,6 +391,7 @@ * add i18n detector ([7eb8a32](https://github.com/RSSNext/follow/commit/7eb8a322c78c7e075ed842036971e9aa5f094341)) * add link parser for audio timestamp navigate ([1478fa5](https://github.com/RSSNext/follow/commit/1478fa5a9343384f45a57431d029480a96b8441c)) * add manual setting lang lock keyu ([b9c6a8b](https://github.com/RSSNext/follow/commit/b9c6a8b58099c86a178494ffe4c875f7c31760a3)) +* add more words i18n ([#516](https://github.com/RSSNext/follow/issues/516)) ([e2b8ec8](https://github.com/RSSNext/follow/commit/e2b8ec88624ad1e8e7f6136a624fc284ae3fb77b)) * add object-cover to feed icon, add zh-HK and zh-TW errors lang ([#508](https://github.com/RSSNext/follow/issues/508)) ([9351a8f](https://github.com/RSSNext/follow/commit/9351a8fe735977ae02320370f9aa6a83854d7adf)) * add og image, fixed [#242](https://github.com/RSSNext/follow/issues/242) ([5d4e958](https://github.com/RSSNext/follow/commit/5d4e9586569e4afe212138d2001ed9007ce9950b)) * add player download src ([fc50751](https://github.com/RSSNext/follow/commit/fc5075139f2f82a66c703349a719927c35b11b09)) @@ -408,6 +423,7 @@ * clearer social media images ([02176d3](https://github.com/RSSNext/follow/commit/02176d3e49fcc4b1248d1c6a9700369ff316374d)) * clickable entry id in ai daily ([0ffe1e5](https://github.com/RSSNext/follow/commit/0ffe1e5b6d74f9ad09775b9100fef2e53d3a6595)) * collapseable user profile subscription, refer [#489](https://github.com/RSSNext/follow/issues/489) ([d22f4e5](https://github.com/RSSNext/follow/commit/d22f4e5d2b4212673652c266247eac78fbdcd059)) +* compatible profile query by username ([09eae80](https://github.com/RSSNext/follow/commit/09eae80f3e3ed2756a207368df83799fd176be07)) * compatible with feeds without siteURL ([87dc225](https://github.com/RSSNext/follow/commit/87dc2251b42a96628bdcb9cdcd36c998a8829c5e)) * context sub menu ([2d18c53](https://github.com/RSSNext/follow/commit/2d18c53de0cb8c99336d0e915941b1fdee36df98)) * copy logo svg ([512699c](https://github.com/RSSNext/follow/commit/512699c07080f3064f984f23a21e28356ef9fcc0)) @@ -418,6 +434,7 @@ * display certification in discover form ([1e212ef](https://github.com/RSSNext/follow/commit/1e212effad12bab751179dc9a94d71a37a3b5ed8)) * display claimed feed list in settings ([d9ae277](https://github.com/RSSNext/follow/commit/d9ae277cfa861c4e558542820896bde821341dc4)) * display feed certification in discover result ([425b8c3](https://github.com/RSSNext/follow/commit/425b8c3003b552215350d534640e18512e9d819b)) +* display feed list in lists external page ([0c4c3c5](https://github.com/RSSNext/follow/commit/0c4c3c5873c80c3854d26c213991bffc44e429c9)) * display power purchase and tx ([dbe7aee](https://github.com/RSSNext/follow/commit/dbe7aee9151ee04147edbce7d34e1275edfc1254)) * double click to video fullscreen ([c066820](https://github.com/RSSNext/follow/commit/c066820ce8baeed808b788e9c780f75c53ba8909)) * dual code theme ([#511](https://github.com/RSSNext/follow/issues/511)) ([f278377](https://github.com/RSSNext/follow/commit/f278377d1017f9edf89c583a4fb24eb48451daf1)) @@ -436,6 +453,8 @@ * filter unused params ([cb9860d](https://github.com/RSSNext/follow/commit/cb9860d4b3fce913c2e9ecba0dd607c75592b8cf)) * flip for power claim toast ([7469ed2](https://github.com/RSSNext/follow/commit/7469ed243376a13d9bcb463d6d6af445293d7b97)) * follow feed by feed id ([30d1851](https://github.com/RSSNext/follow/commit/30d1851e3aefcc2da06981537627ccd415bb082c)) +* followed status for external follow button ([3a7ed50](https://github.com/RSSNext/follow/commit/3a7ed50c55071fb3065ba082fceef3a70214d798)) +* force lists to be sorted by alphabetical ([c3b9fc9](https://github.com/RSSNext/follow/commit/c3b9fc9e7510f777a129063a2e09ae33658b3813)) * guess code language ([03ba85a](https://github.com/RSSNext/follow/commit/03ba85a37302d41f3403d629849b1b4d3db915ba)) * hoverable translation design, fixes [#268](https://github.com/RSSNext/follow/issues/268) ([3ff11dc](https://github.com/RSSNext/follow/commit/3ff11dce35061de2b784621519eee79f87a93993)) * i18n for biz error ([c26bc52](https://github.com/RSSNext/follow/commit/c26bc5298bac31840de1c3c051ad1f91021a016f)) @@ -454,8 +473,10 @@ * **i18n:** complete Traditional Chinese translation for native file ([#506](https://github.com/RSSNext/follow/issues/506)) ([2059329](https://github.com/RSSNext/follow/commit/2059329691b375a73cd9cb4f2389b68bbb544e41)) * **i18n:** fill out and optimized partial Chinese translations ([#431](https://github.com/RSSNext/follow/issues/431)) ([5f87190](https://github.com/RSSNext/follow/commit/5f87190f018fea7f34c3ccbfad081fd8b855f5b8)) * **i18n:** improve zh-CN ([#410](https://github.com/RSSNext/follow/issues/410)) ([0b0304e](https://github.com/RSSNext/follow/commit/0b0304eaa1dfa8396e78612a9a6a50653ce9669e)) +* **i18n:** Korean and fallback language name ([#582](https://github.com/RSSNext/follow/issues/582)) ([2ae12c9](https://github.com/RSSNext/follow/commit/2ae12c9d2b976c8165414cc74c7494b2cfd7ea7c)) * **i18n:** Optimized Chinese translations ([#443](https://github.com/RSSNext/follow/issues/443)) ([77e14cf](https://github.com/RSSNext/follow/commit/77e14cf651a44578c540cdd681a2ee1ea5a2f557)) * **i18n:** Simplified Chinese (partial) ([#353](https://github.com/RSSNext/follow/issues/353)) ([140d01a](https://github.com/RSSNext/follow/commit/140d01a521a472b56f420585f57b577727dee996)) +* **i18n:** Update Chinese Translation ([#572](https://github.com/RSSNext/follow/issues/572)) ([d24139b](https://github.com/RSSNext/follow/commit/d24139b82233ea04674c8b93ddee323d2c84a8ef)) * ignore feed errors within 9 hours ([b71926e](https://github.com/RSSNext/follow/commit/b71926ec286b77dd1b9fc25df459176063b194da)) * impl cmd+b ([ea8a832](https://github.com/RSSNext/follow/commit/ea8a83271e9be37c277540eb605651d7166d2ea4)) * impl masonry in view mark read and scroll to mark read ([4263658](https://github.com/RSSNext/follow/commit/4263658e3240850ca74fcaa666bf8145553f8874)) @@ -472,6 +493,7 @@ * language indicator ([bf7da04](https://github.com/RSSNext/follow/commit/bf7da0431fdffc45cf0136b9e5709bb1952f1036)) * larger text for date item ([c1ea43f](https://github.com/RSSNext/follow/commit/c1ea43fee280bf539d61b1f3c439a7031cf4ed3e)) * lighter unread number ([e7dba4f](https://github.com/RSSNext/follow/commit/e7dba4f18e8a078889e7923d1760cb08c29873fc)) +* list api in subscription modal ([46e246a](https://github.com/RSSNext/follow/commit/46e246aa1734dfbc565533243ca4fb560d42ced7)) * lists ([#533](https://github.com/RSSNext/follow/issues/533)) ([ffcc6c9](https://github.com/RSSNext/follow/commit/ffcc6c90d53b372d2d180f53d32fa47dff9daac4)) * load archived entries ([d7f4bb6](https://github.com/RSSNext/follow/commit/d7f4bb6b9f388849565a7d8fc21d2eafc0610d08)) * loading component new design ([91d0d76](https://github.com/RSSNext/follow/commit/91d0d76efecab753f1c0ff574c0982d45e29eece)) @@ -503,6 +525,7 @@ * preview social media ai daily ([0252bc0](https://github.com/RSSNext/follow/commit/0252bc022306123973ffd27b1cb211aadffae052)) * prompt the full categories when editing the feed ([#392](https://github.com/RSSNext/follow/issues/392)) ([d5ce474](https://github.com/RSSNext/follow/commit/d5ce4744fe28c5d4d05844af6fe344fdf7849424)) * read clipboard ([e115b6d](https://github.com/RSSNext/follow/commit/e115b6de66df93422465044bc2d2930aa7a073fc)) +* read image proxy url from ab value ([d81f57d](https://github.com/RSSNext/follow/commit/d81f57d2ad24ab9176a6d342f427676065c0f5f6)) * readability support ([#178](https://github.com/RSSNext/follow/issues/178)) ([6c052b8](https://github.com/RSSNext/follow/commit/6c052b881b77e75763a9c4117cd562d21a58044d)) * redesign image preview swiper style ([23971b5](https://github.com/RSSNext/follow/commit/23971b53f383dc1d6793c3b0dd4ca58a71c5b71e)) * reduce motion use fade-in and fade-out transition ([78053c1](https://github.com/RSSNext/follow/commit/78053c17fd91ccd7568fe57af3767cd6636929e2)) @@ -524,6 +547,7 @@ * show reasons for profile update failure ([#484](https://github.com/RSSNext/follow/issues/484)) ([b8b94ac](https://github.com/RSSNext/follow/commit/b8b94ac6c4e97088144f20cb8abd8f1d8080f8fd)) * smaller and fixed unread dot ([72aa3a8](https://github.com/RSSNext/follow/commit/72aa3a8cae968893b7ca3b0f8abf11c50c739c74)) * some optimize ([5f61579](https://github.com/RSSNext/follow/commit/5f6157972c7ce2bf45b6e7b4026d9e727795c9a3)) +* sort list by insertedat ([36fbbdd](https://github.com/RSSNext/follow/commit/36fbbddc6d8880f13b99fb38042692894383ecfa)) * sort the query results by the number of followers in asc order ([#379](https://github.com/RSSNext/follow/issues/379)) ([304cb7f](https://github.com/RSSNext/follow/commit/304cb7f59f8622cb076e5bf2b240b1a3f6c2614c)) * sortable feed list ([5dc93af](https://github.com/RSSNext/follow/commit/5dc93af2a77d6a81222c70f5d7b588e087d72af4)) * sortable feed list ([fdd2623](https://github.com/RSSNext/follow/commit/fdd26235548e0a5e24bd1e1eee679a14cd0bb527)) diff --git a/apps/renderer/package.json b/apps/renderer/package.json index 55b3817f1..d68e858dd 100644 --- a/apps/renderer/package.json +++ b/apps/renderer/package.json @@ -8,7 +8,6 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@egjs/react-infinitegrid": "4.12.0", "@egoist/tipc": "0.3.2", "@electron-toolkit/preload": "^3.0.1", "@follow/electron-main": "workspace:*", @@ -71,6 +70,7 @@ "lethargy": "1.0.9", "linkedom": "^0.18.5", "lodash-es": "4.17.21", + "masonic": "4.0.1", "nanoid": "5.0.7", "ofetch": "1.4.0", "path-to-regexp": "8.1.0", diff --git a/apps/renderer/src/@types/constants.ts b/apps/renderer/src/@types/constants.ts index c2ed46209..8411b454e 100644 --- a/apps/renderer/src/@types/constants.ts +++ b/apps/renderer/src/@types/constants.ts @@ -18,8 +18,8 @@ export const currentSupportedLanguages = [ "it", "ru", "es", + "ko", ] - export const dayjsLocaleImportMap = { en: ["en", () => import("dayjs/locale/en")], ["zh-CN"]: ["zh-cn", () => import("dayjs/locale/zh-cn")], @@ -38,6 +38,7 @@ export const dayjsLocaleImportMap = { ["ar-KW"]: ["ar-kw", () => import("dayjs/locale/ar-kw")], ["ar-TN"]: ["ar-tn", () => import("dayjs/locale/ar-tn")], ["zh-HK"]: ["zh-hk", () => import("dayjs/locale/zh-hk")], + ["ko"]: ["ko", () => import("dayjs/locale/ko")], } export const ns = ["app", "common", "lang", "settings", "shortcuts", "errors"] as const export const defaultNS = "app" as const diff --git a/apps/renderer/src/@types/default-resource.ts b/apps/renderer/src/@types/default-resource.ts index a033ec603..346c7f5a0 100644 --- a/apps/renderer/src/@types/default-resource.ts +++ b/apps/renderer/src/@types/default-resource.ts @@ -13,6 +13,7 @@ import common_fi from "../../../../locales/common/fi.json" import common_fr from "../../../../locales/common/fr.json" import common_it from "../../../../locales/common/it.json" import common_ja from "../../../../locales/common/ja.json" +import common_ko from "../../../../locales/common/ko.json" import common_pt from "../../../../locales/common/pt.json" import common_ru from "../../../../locales/common/ru.json" import common_zhCN from "../../../../locales/common/zh-CN.json" @@ -31,6 +32,7 @@ import lang_fi from "../../../../locales/lang/fi.json" import lang_fr from "../../../../locales/lang/fr.json" import lang_it from "../../../../locales/lang/it.json" import lang_ja from "../../../../locales/lang/ja.json" +import lang_ko from "../../../../locales/lang/ko.json" import lang_pt from "../../../../locales/lang/pt.json" import lang_ru from "../../../../locales/lang/ru.json" import lang_zhCN from "../../../../locales/lang/zh-CN.json" @@ -75,4 +77,5 @@ export const defaultResources = { "ar-IQ": { lang: lang_ariq, common: common_ariq }, "ar-KW": { lang: lang_arkw, common: common_arkw }, "ar-TN": { lang: lang_artn, common: common_artn }, + ko: { lang: lang_ko, common: common_ko }, } diff --git a/apps/renderer/src/components/feed-certification.tsx b/apps/renderer/src/components/feed-certification.tsx index 16870ab45..2a62d0c15 100644 --- a/apps/renderer/src/components/feed-certification.tsx +++ b/apps/renderer/src/components/feed-certification.tsx @@ -40,10 +40,7 @@ export const FeedCertification = ({ diff --git a/apps/renderer/src/components/feed-icon.tsx b/apps/renderer/src/components/feed-icon.tsx index f015a1058..1ccb43ef9 100644 --- a/apps/renderer/src/components/feed-icon.tsx +++ b/apps/renderer/src/components/feed-icon.tsx @@ -1,4 +1,5 @@ import { Avatar, AvatarFallback, AvatarImage } from "@radix-ui/react-avatar" +import { m } from "framer-motion" import type { ReactNode } from "react" import { forwardRef, useMemo } from "react" @@ -145,7 +146,7 @@ export function FeedIcon({ ImageElement = ( - + ) break @@ -158,7 +159,12 @@ export function FeedIcon({ }) ImageElement = ( - + ) break @@ -207,11 +213,7 @@ export function FeedIcon({ if (fallback && !!finalSrc) { return ( - + {ImageElement} {fallbackIcon} @@ -224,7 +226,7 @@ export function FeedIcon({ // Else return ( - + {ImageElement} diff --git a/apps/renderer/src/components/ui/Masonry.tsx b/apps/renderer/src/components/ui/Masonry.tsx new file mode 100644 index 000000000..cb152efc3 --- /dev/null +++ b/apps/renderer/src/components/ui/Masonry.tsx @@ -0,0 +1,212 @@ +import { clearRequestTimeout, requestTimeout } from "@essentials/request-timeout" +import { useWindowSize } from "@react-hook/window-size" +import { useForceUpdate } from "framer-motion" +import { throttle } from "lodash-es" +import type { ContainerPosition, MasonryProps, MasonryScrollerProps, Positioner } from "masonic" +import { createResizeObserver, useMasonry, usePositioner, useScrollToIndex } from "masonic" +import * as React from "react" + +import { useScrollViewElement } from "./scroll-area/hooks" +/** + * A "batteries included" masonry grid which includes all of the implementation details below. This component is the + * easiest way to get off and running in your app, before switching to more advanced implementations, if necessary. + * It will change its column count to fit its container's width and will decide how many rows to render based upon + * the height of the browser `window`. + * + * @param props + */ +export const Masonry = (props: MasonryProps) => { + const [scrollTop, setScrollTop] = React.useState(0) + const [isScrolling, setIsScrolling] = React.useState(false) + const scrollElement = useScrollViewElement() + + const fps = props.scrollFps || 12 + React.useEffect(() => { + if (!scrollElement) return + + const scrollTimer: number | null = null + const handleScroll = throttle(() => { + setIsScrolling(true) + setScrollTop(scrollElement.scrollTop) + }, 1000 / fps) + + scrollElement.addEventListener("scroll", handleScroll) + + return () => { + scrollElement.removeEventListener("scroll", handleScroll) + if (scrollTimer) { + clearTimeout(scrollTimer) + } + } + }, [fps, scrollElement]) + const didMount = React.useRef(0) + React.useEffect(() => { + if (didMount.current === 1) setIsScrolling(true) + let didUnsubscribe = false + const to = requestTimeout( + () => { + if (didUnsubscribe) return + // This is here to prevent premature bail outs while maintaining high resolution + // unsets. Without it there will always bee a lot of unnecessary DOM writes to style. + setIsScrolling(false) + }, + 40 + 1000 / fps, + ) + didMount.current = 1 + return () => { + didUnsubscribe = true + clearRequestTimeout(to) + } + }, [fps, scrollTop]) + + const containerRef = React.useRef(null) + const windowSize = useWindowSize({ + initialWidth: props.ssrWidth, + initialHeight: props.ssrHeight, + }) + const containerPos = useContainerPosition(containerRef, windowSize) + + const nextProps = Object.assign( + { + offset: containerPos.offset, + width: containerPos.width || windowSize[0], + height: containerPos.height || windowSize[1], + containerRef, + }, + props, + ) as any + + // Workaround for https://github.com/jaredLunde/masonic/issues/12 + const itemCounter = React.useRef(props.items.length) + + let shrunk = false + + if (props.items.length !== itemCounter.current) { + if (props.items.length < itemCounter.current) shrunk = true + + itemCounter.current = props.items.length + } + + nextProps.positioner = usePositioner(nextProps, [shrunk && Math.random()]) + + nextProps.resizeObserver = useResizeObserver(nextProps.positioner) + nextProps.scrollTop = scrollTop + nextProps.isScrolling = isScrolling + nextProps.height = window.innerHeight + + const scrollToIndex = useScrollToIndex(nextProps.positioner, { + height: nextProps.height, + offset: containerPos.offset, + align: typeof props.scrollToIndex === "object" ? props.scrollToIndex.align : void 0, + }) + const index = + props.scrollToIndex && + (typeof props.scrollToIndex === "number" ? props.scrollToIndex : props.scrollToIndex.index) + + React.useEffect(() => { + if (index !== void 0) scrollToIndex(index) + }, [index, scrollToIndex]) + + return React.createElement(MasonryScroller, nextProps) +} + +function MasonryScroller( + props: MasonryScrollerProps & { + scrollTop: number + isScrolling: boolean + }, +) { + // We put this in its own layer because it's the thing that will trigger the most updates + // and we don't want to slower ourselves by cycling through all the functions, objects, and effects + // of other hooks + // const { scrollTop, isScrolling } = useScroller(props.offset, props.scrollFps) + // This is an update-heavy phase and while we could just Object.assign here, + // it is way faster to inline and there's a relatively low hit to he bundle + // size. + + return useMasonry({ + scrollTop: props.scrollTop, + isScrolling: props.isScrolling, + positioner: props.positioner, + resizeObserver: props.resizeObserver, + items: props.items, + onRender: props.onRender, + as: props.as, + id: props.id, + className: props.className, + style: props.style, + role: props.role, + tabIndex: props.tabIndex, + containerRef: props.containerRef, + itemAs: props.itemAs, + itemStyle: props.itemStyle, + itemHeightEstimate: props.itemHeightEstimate, + itemKey: props.itemKey, + overscanBy: props.overscanBy, + height: props.height, + render: props.render, + }) +} + +function useContainerPosition( + elementRef: React.MutableRefObject, + deps: React.DependencyList = [], +): ContainerPosition & { + height: number +} { + const [containerPosition, setContainerPosition] = React.useState< + ContainerPosition & { + height: number + } + >({ + offset: 0, + width: 0, + height: 0, + }) + + React.useLayoutEffect(() => { + const { current } = elementRef + if (current !== null) { + let offset = 0 + let el = current + + do { + offset += el.offsetTop || 0 + el = el.offsetParent as HTMLElement + } while (el) + + if (offset !== containerPosition.offset || current.offsetWidth !== containerPosition.width) { + setContainerPosition({ + offset, + width: current.offsetWidth, + height: current.offsetHeight, + }) + } + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, deps) + + React.useEffect(() => { + const resizeObserver = new ResizeObserver(() => { + setContainerPosition((prev) => ({ + ...prev, + width: elementRef.current?.offsetWidth || 0, + })) + }) + resizeObserver.observe(elementRef.current as HTMLElement) + return () => { + resizeObserver.disconnect() + } + }, [containerPosition, elementRef]) + + return containerPosition +} + +function useResizeObserver(positioner: Positioner) { + const [forceUpdate] = useForceUpdate() + const resizeObserver = createResizeObserver(positioner, throttle(forceUpdate, 1000 / 12)) + // Cleans up the resize observers when they change or the + // component unmounts + React.useEffect(() => () => resizeObserver.disconnect(), [resizeObserver]) + return resizeObserver +} diff --git a/apps/renderer/src/hooks/biz/useAb.ts b/apps/renderer/src/hooks/biz/useAb.ts new file mode 100644 index 000000000..2d7db02ea --- /dev/null +++ b/apps/renderer/src/hooks/biz/useAb.ts @@ -0,0 +1,37 @@ +import { useAtomValue } from "jotai" +import PostHog from "posthog-js" +import { useFeatureFlagEnabled } from "posthog-js/react" + +import { jotaiStore } from "~/lib/jotai" +import type { FeatureKeys } from "~/modules/ab/atoms" +import { debugFeaturesAtom, enableDebugOverrideAtom, IS_DEBUG_ENV } from "~/modules/ab/atoms" +import { abPayloadFallback } from "~/modules/ab/fallback" + +export const useAb = (feature: FeatureKeys) => { + const isEnableDebugOverrides = useAtomValue(enableDebugOverrideAtom) + const debugFeatureOverrides = useAtomValue(debugFeaturesAtom) + + const isEnabled = useFeatureFlagEnabled(feature) + + if (IS_DEBUG_ENV && isEnableDebugOverrides) return debugFeatureOverrides[feature] + + return isEnabled +} + +export const isAbEnabled = (feature: FeatureKeys) => { + const featureFlag = PostHog.getFeatureFlag(feature) + const enabled = typeof featureFlag === "boolean" ? featureFlag : featureFlag === "enabled" + const debugOverride = jotaiStore.get(debugFeaturesAtom) + + const isEnableOverride = jotaiStore.get(enableDebugOverrideAtom) + + if (isEnableOverride) { + return debugOverride[feature] + } + + return enabled +} + +export const getAbValue = (feature: FeatureKeys) => { + return PostHog.getFeatureFlagPayload(feature) || abPayloadFallback[feature] +} diff --git a/apps/renderer/src/hooks/biz/useFeedActions.tsx b/apps/renderer/src/hooks/biz/useFeedActions.tsx index 6ed7d9af4..3b6c6b8a4 100644 --- a/apps/renderer/src/hooks/biz/useFeedActions.tsx +++ b/apps/renderer/src/hooks/biz/useFeedActions.tsx @@ -46,7 +46,9 @@ export const useFeedActions = ({ shortcut: "E", click: () => { present({ - title: t("sidebar.feed_actions.edit_feed"), + title: isList + ? t("sidebar.feed_actions.edit_list") + : t("sidebar.feed_actions.edit_feed"), content: ({ dismiss }) => ( ), diff --git a/apps/renderer/src/hooks/biz/useFeedFormModal.tsx b/apps/renderer/src/hooks/biz/useFeedFormModal.tsx index fc7d15211..c962a190b 100644 --- a/apps/renderer/src/hooks/biz/useFeedFormModal.tsx +++ b/apps/renderer/src/hooks/biz/useFeedFormModal.tsx @@ -12,14 +12,30 @@ export const usePresentFeedFormModal = () => { const me = useWhoami() const t = useI18n() return useCallback( - (feedId: string) => { + ( + params: + | { + feedId: string + } + | { + listId: string + }, + ) => { if (me) { + const isList = !!("listId" in params) present({ - title: t("sidebar.feed_actions.edit_feed"), - content: ({ dismiss }) => , + title: isList ? t("sidebar.feed_actions.edit_list") : t("sidebar.feed_actions.edit_feed"), + content: ({ dismiss }) => ( + + ), }) } else { - window.location.href = `${DEEPLINK_SCHEME}add?id=${feedId}` + window.location.href = `${DEEPLINK_SCHEME}add?id=${"feedId" in params ? params.feedId : params.listId}` } }, [me, present, t], diff --git a/apps/renderer/src/hooks/biz/useSubscriptionActions.tsx b/apps/renderer/src/hooks/biz/useSubscriptionActions.tsx index b79212f53..a90fcd610 100644 --- a/apps/renderer/src/hooks/biz/useSubscriptionActions.tsx +++ b/apps/renderer/src/hooks/biz/useSubscriptionActions.tsx @@ -1,5 +1,6 @@ import { useMutation } from "@tanstack/react-query" import { useHotkeys } from "react-hotkeys-hook" +import { Trans, useTranslation } from "react-i18next" import { toast } from "sonner" import { Kbd } from "~/components/ui/kbd/Kbd" @@ -13,8 +14,10 @@ import { feedUnreadActions } from "~/store/unread" import { navigateEntry } from "./useNavigateEntry" import { getRouteParams } from "./useRouteParams" -export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void }) => - useMutation({ +export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void }) => { + const { t } = useTranslation() + + return useMutation({ mutationFn: async (subscription: SubscriptionFlatModel) => subscriptionActions.unfollow(subscription.feedId).then((feed) => { subscriptionQuery.byView(subscription.view).invalidate() @@ -39,12 +42,13 @@ export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void }) toast.dismiss(toastId) } + const toastId = toast(, { duration: 3000, action: { label: ( - Undo + {t("words.undo")} Meta+Z @@ -68,6 +72,7 @@ export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void }) } }, }) +} const UnfollowInfo = ({ title, undo }: { title: string; undo: () => any }) => { useHotkeys("ctrl+z,meta+z", undo, { @@ -76,7 +81,13 @@ const UnfollowInfo = ({ title, undo }: { title: string; undo: () => any }) => { }) return ( <> - Feed {title} has been unfollowed. + {title}, + }} + /> ) } diff --git a/apps/renderer/src/initialize/index.ts b/apps/renderer/src/initialize/index.ts index df82fada9..dc043da67 100644 --- a/apps/renderer/src/initialize/index.ts +++ b/apps/renderer/src/initialize/index.ts @@ -97,13 +97,12 @@ export const initializeApp = async () => { }) // should after hydrateSettings - const { dataPersist: enabledDataPersist, sendAnonymousData } = getGeneralSettings() + const { dataPersist: enabledDataPersist } = getGeneralSettings() initSentry() + initPostHog() await apm("i18n", initI18n) - if (sendAnonymousData) initPostHog() - let dataHydratedTime: undefined | number // Initialize the database if (enabledDataPersist) { diff --git a/apps/renderer/src/initialize/posthog.ts b/apps/renderer/src/initialize/posthog.ts index c5a367f88..018851061 100644 --- a/apps/renderer/src/initialize/posthog.ts +++ b/apps/renderer/src/initialize/posthog.ts @@ -1,6 +1,8 @@ import { env } from "@follow/shared/env" import type { CaptureOptions, Properties } from "posthog-js" +import { posthog } from "posthog-js" +import { getGeneralSettings } from "~/atoms/settings/general" import { whoami } from "~/atoms/user" declare global { @@ -12,9 +14,6 @@ declare global { } } export const initPostHog = async () => { - if (import.meta.env.DEV) return - const { default: posthog } = await import("posthog-js") - if (env.VITE_POSTHOG_KEY === undefined) return posthog.init(env.VITE_POSTHOG_KEY, { person_profiles: "identified_only", @@ -25,6 +24,10 @@ export const initPostHog = async () => { window.posthog = { reset, capture(event_name: string, properties?: Properties | null, options?: CaptureOptions) { + if (import.meta.env.DEV) return + if (!getGeneralSettings().sendAnonymousData) { + return + } return capture.apply(posthog, [ event_name, { diff --git a/apps/renderer/src/lib/img-proxy.ts b/apps/renderer/src/lib/img-proxy.ts index 91a5428bd..8345002bd 100644 --- a/apps/renderer/src/lib/img-proxy.ts +++ b/apps/renderer/src/lib/img-proxy.ts @@ -1,6 +1,7 @@ -import { env } from "@follow/shared/env" import { imageRefererMatches } from "@follow/shared/image" +import { getAbValue, isAbEnabled } from "~/hooks/biz/useAb" + export const getImageProxyUrl = ({ url, width, @@ -9,7 +10,14 @@ export const getImageProxyUrl = ({ url: string width: number height: number -}) => `${env.VITE_IMGPROXY_URL}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}` +}) => { + const abValue = getAbValue("Image_Proxy_V2") + if (isAbEnabled("Image_Proxy_V2")) { + return `${abValue}?url=${encodeURIComponent(url)}&width=${width}&height=${height}` + } else { + return `${abValue}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}` + } +} export const replaceImgUrlIfNeed = (url: string) => { for (const rule of imageRefererMatches) { diff --git a/apps/renderer/src/modules/ab/atoms.ts b/apps/renderer/src/modules/ab/atoms.ts new file mode 100644 index 000000000..f45068326 --- /dev/null +++ b/apps/renderer/src/modules/ab/atoms.ts @@ -0,0 +1,15 @@ +import FEATURES from "@constants/flags.json" +import { atom } from "jotai" +import { atomWithStorage } from "jotai/utils" + +import { getStorageNS } from "~/lib/ns" + +export type FeatureKeys = keyof typeof FEATURES + +export const debugFeaturesAtom = atomWithStorage(getStorageNS("ab"), FEATURES, undefined, { + getOnInit: true, +}) + +export const IS_DEBUG_ENV = import.meta.env.DEV || import.meta.env["PREVIEW_MODE"] + +export const enableDebugOverrideAtom = atom(IS_DEBUG_ENV) diff --git a/apps/renderer/src/modules/ab/fallback.ts b/apps/renderer/src/modules/ab/fallback.ts new file mode 100644 index 000000000..ecac73508 --- /dev/null +++ b/apps/renderer/src/modules/ab/fallback.ts @@ -0,0 +1,5 @@ +import type { FeatureKeys } from "./atoms" + +export const abPayloadFallback: Record = { + Image_Proxy_V2: "https://thumbor.follow.is", +} diff --git a/apps/renderer/src/modules/ab/hoc.tsx b/apps/renderer/src/modules/ab/hoc.tsx new file mode 100644 index 000000000..823e9bfb9 --- /dev/null +++ b/apps/renderer/src/modules/ab/hoc.tsx @@ -0,0 +1,30 @@ +import type { FC } from "react" +import { forwardRef } from "react" + +import { useAb } from "~/hooks/biz/useAb" + +import type { FeatureKeys } from "./atoms" + +const Noop = () => null +export const withFeature = + (feature: FeatureKeys) => + ( + Component: FC, + + FallbackComponent: any = Noop, + ) => { + // @ts-expect-error + const WithFeature = forwardRef((props: T, ref: any) => { + const isEnabled = useAb(feature) + + if (isEnabled === undefined) return null + + return isEnabled ? ( + + ) : ( + + ) + }) + + return WithFeature + } diff --git a/apps/renderer/src/modules/ab/providers.tsx b/apps/renderer/src/modules/ab/providers.tsx new file mode 100644 index 000000000..ce0f8f0ab --- /dev/null +++ b/apps/renderer/src/modules/ab/providers.tsx @@ -0,0 +1,84 @@ +import { useAtomValue, useSetAtom } from "jotai" + +import { Divider } from "~/components/ui/divider" +import { Label } from "~/components/ui/label" +import { useModalStack } from "~/components/ui/modal" +import { RootPortal } from "~/components/ui/portal" +import { Switch } from "~/components/ui/switch" + +import type { FeatureKeys } from "./atoms" +import { debugFeaturesAtom, enableDebugOverrideAtom, IS_DEBUG_ENV } from "./atoms" + +export const FeatureFlagDebugger = () => { + if (IS_DEBUG_ENV) return + + return null +} + +const DebugToggle = () => { + const { present } = useModalStack() + return ( + +
{ + present({ + title: "A/B", + content: ABModalContent, + }) + }} + className="fixed bottom-5 right-0 flex size-5 items-center justify-center opacity-40 duration-200 hover:opacity-100" + > + +
+
+ ) +} + +const SwitchInternal = ({ Key }: { Key: FeatureKeys }) => { + const enabled = useAtomValue(debugFeaturesAtom)[Key] + const setDebugFeatures = useSetAtom(debugFeaturesAtom) + return ( + { + setDebugFeatures((prev) => ({ ...prev, [Key]: checked })) + }} + /> + ) +} + +const ABModalContent = () => { + const features = useAtomValue(debugFeaturesAtom) + + const enableOverride = useAtomValue(enableDebugOverrideAtom) + const setEnableDebugOverride = useSetAtom(enableDebugOverrideAtom) + return ( +
+ + + + +
+ {Object.keys(features).map((key) => { + return ( +
+ +
+ ) + })} +
+
+ ) +} diff --git a/apps/renderer/src/modules/claim/hooks.ts b/apps/renderer/src/modules/claim/hooks.ts index 89bd5b7e2..27b78139c 100644 --- a/apps/renderer/src/modules/claim/hooks.ts +++ b/apps/renderer/src/modules/claim/hooks.ts @@ -1,4 +1,5 @@ import { createElement, useCallback } from "react" +import { useTranslation } from "react-i18next" import { useModalStack } from "~/components/ui/modal/stacked/hooks" import { getFeedById } from "~/store/feed" @@ -7,6 +8,7 @@ import { FeedClaimModalContent } from "./feed-claim-modal" export const useFeedClaimModal = ({ feedId }: { feedId?: string }) => { const { present } = useModalStack() + const { t } = useTranslation() return useCallback(() => { if (!feedId) return @@ -16,7 +18,7 @@ export const useFeedClaimModal = ({ feedId }: { feedId?: string }) => { if (!feed) return present({ - title: "Feed Claim", + title: t("feed_claim_modal.title"), content: () => createElement(FeedClaimModalContent, { feedId }), modalClassName: "!h-auto !max-h-screen", }) diff --git a/apps/renderer/src/modules/discover/feed-form.tsx b/apps/renderer/src/modules/discover/feed-form.tsx index 3e0125c09..4547a03bc 100644 --- a/apps/renderer/src/modules/discover/feed-form.tsx +++ b/apps/renderer/src/modules/discover/feed-form.tsx @@ -88,7 +88,16 @@ export const FeedForm: Component<{ )} {feed ? ( - + ) : feedQuery.isLoading ? (
@@ -156,16 +165,23 @@ const FeedInnerForm = ({ url, asWidget, onSuccess, + subscriptionData, }: { defaultValues?: z.infer url?: string id?: string asWidget?: boolean onSuccess?: () => void + subscriptionData?: { + view?: number + category?: string | null + isPrivate?: boolean + title?: string | null + } }) => { - const subscription = useSubscriptionByFeedId(id || "") - const buttonRef = useRef(null) + const subscription = useSubscriptionByFeedId(id || "") || subscriptionData const isSubscribed = !!subscription + const buttonRef = useRef(null) const feed = useFeedByIdOrUrl({ id, url })! const isList = feed?.type === "list" diff --git a/apps/renderer/src/modules/discover/form.tsx b/apps/renderer/src/modules/discover/form.tsx index a82500ec6..13507a566 100644 --- a/apps/renderer/src/modules/discover/form.tsx +++ b/apps/renderer/src/modules/discover/form.tsx @@ -311,36 +311,31 @@ const SearchCard: FC<{ )} - {item.isSubscribed ? ( - - ) : ( - - )} +
{item.subscriptionCount} diff --git a/apps/renderer/src/modules/discover/import.tsx b/apps/renderer/src/modules/discover/import.tsx index 044cc5b7f..d3c59e52e 100644 --- a/apps/renderer/src/modules/discover/import.tsx +++ b/apps/renderer/src/modules/discover/import.tsx @@ -2,7 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod" import { useMutation } from "@tanstack/react-query" import { Fragment } from "react/jsx-runtime" import { useForm } from "react-hook-form" -import { useTranslation } from "react-i18next" +import { Trans, useTranslation } from "react-i18next" import { z } from "zod" import { Button } from "~/components/ui/button" @@ -35,20 +35,26 @@ const formSchema = z.object({ }), }) -const list = [ +const NumberDisplay = ({ value }) => {value ?? 0} + +const list: { + key: string + title: I18nKeys + className: string +}[] = [ { key: "parsedErrorItems", - title: "Parsed Error Items", + title: "discover.import.parsedErrorItems", className: "text-red-500", }, { key: "successfulItems", - title: "Successful Items", + title: "discover.import.successfulItems", className: "text-green-500", }, { key: "conflictItems", - title: "Conflict Items", + title: "discover.import.conflictItems", className: "text-yellow-500", }, ] @@ -88,6 +94,7 @@ export function DiscoverImport() { function onSubmit(values: z.infer) { mutation.mutate(values.file) } + const { t } = useTranslation() return ( @@ -99,7 +106,7 @@ export function DiscoverImport() { name="file" render={({ field: { value, onChange, ...fieldProps } }) => ( - OPML file + {t("discover.import.opml")}