chore: Release v0.2.6-beta.0 (#2025)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
name: 🐞 Bug report
|
||||
description: Report an issue
|
||||
labels: [pending triage]
|
||||
type: Bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
name: 🚀 New feature proposal
|
||||
description: Propose a new feature
|
||||
labels: [enhancement]
|
||||
type: Feature
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@@ -3,6 +3,10 @@ on:
|
||||
push:
|
||||
branches: [main, dev]
|
||||
|
||||
env:
|
||||
VITE_WEB_URL: ${{ vars.VITE_WEB_URL }}
|
||||
VITE_API_URL: ${{ vars.VITE_API_URL }}
|
||||
|
||||
name: CI Format, Typecheck and Lint
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-lint
|
||||
|
||||
+65
-1
@@ -1,6 +1,6 @@
|
||||
# CHANGELOG
|
||||
|
||||
## [0.2.5-beta.0](https://github.com/RSSNext/follow/compare/v0.2.0-beta.2...v0.2.5-beta.0) (2024-11-28)
|
||||
## [0.2.6-beta.0](https://github.com/RSSNext/follow/compare/v0.2.0-beta.2...v0.2.6-beta.0) (2024-12-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
@@ -22,6 +22,7 @@
|
||||
* add turbo build in ci ([7b848cd](https://github.com/RSSNext/follow/commit/7b848cd08aa4f97b1df35666166561d6fc30c5c9))
|
||||
* add type checking to test script ([#1666](https://github.com/RSSNext/follow/issues/1666)) ([518a32f](https://github.com/RSSNext/follow/commit/518a32f2ce1498f21cff87e0b95d0a4fd0a0f4a0))
|
||||
* adjust activation toast style ([e81245e](https://github.com/RSSNext/follow/commit/e81245e395ce1829f0c185a5a184c4cba8f8406c))
|
||||
* ai daily report layout in mobile ([64c7df1](https://github.com/RSSNext/follow/commit/64c7df1dda3e4a30a6152b24bcea0dd135e12ca9))
|
||||
* align notification skeleton to left ([fa08d1a](https://github.com/RSSNext/follow/commit/fa08d1a0cb8421ca40e38dddd0d74415389f7a80)), closes [#1672](https://github.com/RSSNext/follow/issues/1672)
|
||||
* allow click when selecting ([c514458](https://github.com/RSSNext/follow/commit/c51445873249ed7340d86bcb7901dbeca98d096e)), closes [#1512](https://github.com/RSSNext/follow/issues/1512)
|
||||
* allow collect entry from list ([706f484](https://github.com/RSSNext/follow/commit/706f4847576fbb0237925434d4dace5c22fdbf93))
|
||||
@@ -32,12 +33,17 @@
|
||||
* app update logic ([9680351](https://github.com/RSSNext/follow/commit/9680351f2c5f6c6ca6542396a722719a69fa5064))
|
||||
* app upgrade toast open link should in new window ([fc81546](https://github.com/RSSNext/follow/commit/fc81546bed6b07626215a57543a735001728f520))
|
||||
* app upgraded toast href error ([#1444](https://github.com/RSSNext/follow/issues/1444)) ([c875d69](https://github.com/RSSNext/follow/commit/c875d697b2a1cd9e49f3c91397531a82928e1bc8))
|
||||
* app version ([c5854f4](https://github.com/RSSNext/follow/commit/c5854f45795bf6cb78a9d24f05678fe548ceba06))
|
||||
* assets rewrite ([#1204](https://github.com/RSSNext/follow/issues/1204)) ([488e8ef](https://github.com/RSSNext/follow/commit/488e8effc6f00769df7dbf68d4e6d1e4e950b8e7))
|
||||
* attempt to fix the page freeze issue when re-opening modal after closing ([36d235e](https://github.com/RSSNext/follow/commit/36d235eeb8d08c841d475db2a354ad05d3f268d7))
|
||||
* audio cover style ([21a93c7](https://github.com/RSSNext/follow/commit/21a93c757dfbc161d67f28500f0129bde1959662))
|
||||
* audio player on mobile ([1e936e2](https://github.com/RSSNext/follow/commit/1e936e2c593adafa92d54ddc542ff30688c0e3bc))
|
||||
* audio player width, fixed [#1934](https://github.com/RSSNext/follow/issues/1934) ([238938a](https://github.com/RSSNext/follow/commit/238938a4da5b854f9f3422b93059b9f82f60d09b))
|
||||
* **auth:** redirect url ([e7d5576](https://github.com/RSSNext/follow/commit/e7d5576b63a77cd4f4e25a3124f9685f408a73de))
|
||||
* auto archived list flash ([#1269](https://github.com/RSSNext/follow/issues/1269)) ([8d2478c](https://github.com/RSSNext/follow/commit/8d2478c6a93aa9f5a99fddc55bbb8e532e1a0fe1))
|
||||
* auto load achieved entries when show achieved button is available ([074a60d](https://github.com/RSSNext/follow/commit/074a60d3cf93bcede88ea4d70b07cf7480be4229))
|
||||
* **boost:** card text align center ([632d5d4](https://github.com/RSSNext/follow/commit/632d5d42d67999523e602fb18f59ca72543b7d7a))
|
||||
* **bridge:** window call should catch error ([7bdf100](https://github.com/RSSNext/follow/commit/7bdf10050cef7f39b0f485b89ca0445c49116d81))
|
||||
* build ([740783a](https://github.com/RSSNext/follow/commit/740783a537f85e0bc215cd38ce37bf5bd6fc9b1a))
|
||||
* build pre script ([8bd2de8](https://github.com/RSSNext/follow/commit/8bd2de84b898ffc1a4863d29d7056a0b9e7a9e2f))
|
||||
* bump config ([117bd1b](https://github.com/RSSNext/follow/commit/117bd1ba08e4c287dc071669614567197e470d12))
|
||||
@@ -45,18 +51,25 @@
|
||||
* can not exit entry by close button ([e654c3a](https://github.com/RSSNext/follow/commit/e654c3ac165e5eb276ba51dc4ae0ab2da230a9d1)), closes [#1311](https://github.com/RSSNext/follow/issues/1311)
|
||||
* can not keep text selection, fixed [#1895](https://github.com/RSSNext/follow/issues/1895) ([4330a69](https://github.com/RSSNext/follow/commit/4330a693968abe16eeb0908943e643890a7b26a5))
|
||||
* can not play bilibili video ([11ff813](https://github.com/RSSNext/follow/commit/11ff813c450fb519292b187a15236abe7d900abb)), closes [#1376](https://github.com/RSSNext/follow/issues/1376)
|
||||
* can not show context menu on subscription sheet ([0155792](https://github.com/RSSNext/follow/commit/0155792a38088e38bfe41b0cd10f062ac21e88a0))
|
||||
* can not translate title by action ([ef68bae](https://github.com/RSSNext/follow/commit/ef68baeb29fbaba8a9d78a47656a8a7f852cc093)), closes [#1957](https://github.com/RSSNext/follow/issues/1957)
|
||||
* center dialog ([4a1ae06](https://github.com/RSSNext/follow/commit/4a1ae0668855b24513cf85b2a6527edf20c2da47))
|
||||
* change invitation code placeholder font to theme font ([#1978](https://github.com/RSSNext/follow/issues/1978)) ([d78f7cd](https://github.com/RSSNext/follow/commit/d78f7cdc178388f5e0c83be4ce49e32f68863efa))
|
||||
* changelog ([f84aa0b](https://github.com/RSSNext/follow/commit/f84aa0b0cfdc350f26e79ce68c75788cc090321d))
|
||||
* ci ([#1943](https://github.com/RSSNext/follow/issues/1943)) ([f7eca73](https://github.com/RSSNext/follow/commit/f7eca73f5b2a5f1d3d24a3189fd4708da282b45b))
|
||||
* **ci:** concurrency group ([fb0152e](https://github.com/RSSNext/follow/commit/fb0152eaec76b28ed9fc26381917ca7ec2aecb0b))
|
||||
* **ci:** forge build error ([#1500](https://github.com/RSSNext/follow/issues/1500)) ([a5e3e02](https://github.com/RSSNext/follow/commit/a5e3e0228c7088e78061801466267ebdbd288e2c))
|
||||
* **ci:** turbo not found ([c812bd7](https://github.com/RSSNext/follow/commit/c812bd71aabc63b5c9ebbe032f25aba5ac51bd64))
|
||||
* **ci:** windows build ([9f72c26](https://github.com/RSSNext/follow/commit/9f72c263a6945fe90899f85f732c0866c7f61b25))
|
||||
* claim modal style in mobile ([a360235](https://github.com/RSSNext/follow/commit/a3602350236cf642825b24caad5801f37e7d093d))
|
||||
* claim modal width ([5c328ba](https://github.com/RSSNext/follow/commit/5c328babad21d51d91051cb83249df538e33dbee))
|
||||
* clear cache permission in windows ([0ce6546](https://github.com/RSSNext/follow/commit/0ce6546d7f563c44de7d06a4f2dff8ed8f318c1a))
|
||||
* clear selected feed ids when switching view ([c42cfdb](https://github.com/RSSNext/follow/commit/c42cfdb7db6fd2ac5722fe50006d7fd7675e17df))
|
||||
* clear selection when pointer down, fixed [#1448](https://github.com/RSSNext/follow/issues/1448) ([33d3906](https://github.com/RSSNext/follow/commit/33d39067b5c5fdc8f302ca3ea13a740bbb014088))
|
||||
* click outside to click area ([51194ac](https://github.com/RSSNext/follow/commit/51194aca6c51c9550703f416fa204f367d8a00de))
|
||||
* **cmdk:** change default cmdk search type to feed ([4a8fdea](https://github.com/RSSNext/follow/commit/4a8fdea84a4df90313f8c577d77d3944a34aa149))
|
||||
* condition key ([ffb3b94](https://github.com/RSSNext/follow/commit/ffb3b943b0c502cf940d7f3c0d4d506489b65d37))
|
||||
* content ([5a30f38](https://github.com/RSSNext/follow/commit/5a30f384082949f17a71f6d1f837b30966368157))
|
||||
* context menu for multi select ([d68de79](https://github.com/RSSNext/follow/commit/d68de7933235351d64df68e3e2c49623184f4284))
|
||||
* corner player style on safari ([e740d4d](https://github.com/RSSNext/follow/commit/e740d4da78032547c48014a31a25968fe1ad192f))
|
||||
* correct z-index in toast ([6507744](https://github.com/RSSNext/follow/commit/6507744847b6ceee093adb17076292993d525313))
|
||||
@@ -69,6 +82,7 @@
|
||||
* debug html ([e9afc79](https://github.com/RSSNext/follow/commit/e9afc7944f4dc42be2ea530b4852e9c2f6207ac8))
|
||||
* debug proxy html env inejct ([f98ae93](https://github.com/RSSNext/follow/commit/f98ae93ff4d0d25216e0570c44ef657cd36657e0))
|
||||
* debug proxy page ([#1439](https://github.com/RSSNext/follow/issues/1439)) ([c8d1230](https://github.com/RSSNext/follow/commit/c8d1230be753109bd7eaef45e7d0ad0399d8bd4d))
|
||||
* **debug:** inject `import.env` ([810516a](https://github.com/RSSNext/follow/commit/810516ae7d9b4196c047249cb0f889de8b012b99))
|
||||
* delete condition item ([8b9750d](https://github.com/RSSNext/follow/commit/8b9750da1219f3d046b78c70c1966e284b086348))
|
||||
* delete last condition ([72d894a](https://github.com/RSSNext/follow/commit/72d894a754ba3a0c3b6c4e030b3b274dc98de6b6))
|
||||
* detecting windows11 ([#1170](https://github.com/RSSNext/follow/issues/1170)) ([2813f1d](https://github.com/RSSNext/follow/commit/2813f1d6540fcb215287dd32cbc0f8cf87cb1cb0))
|
||||
@@ -78,6 +92,7 @@
|
||||
* disable auto load archive for inbox and list ([7825e16](https://github.com/RSSNext/follow/commit/7825e16b6d1230ba2c13e5ef00474fc05cc510e5))
|
||||
* disable horizontal auto-scroll ([8666b41](https://github.com/RSSNext/follow/commit/8666b41f2dded5b6b5cb86b7824683b48582cf1d)), closes [#1512](https://github.com/RSSNext/follow/issues/1512)
|
||||
* disable overscroll-behavior ([5b32e33](https://github.com/RSSNext/follow/commit/5b32e33cf144ea2077ef08fba8008e0d6df022b7))
|
||||
* disable sw in dev ([150cdea](https://github.com/RSSNext/follow/commit/150cdea5ea4947ada1b968b23e4a278350d98e43))
|
||||
* **discover:** card text truncate ([557e912](https://github.com/RSSNext/follow/commit/557e91228af27251663904dfd3211c535b5b5415))
|
||||
* dismiss non-important modal when click outside, fix [#1468](https://github.com/RSSNext/follow/issues/1468) ([cda2264](https://github.com/RSSNext/follow/commit/cda226420f6c42679d594c02fd7f6fb103bfc236))
|
||||
* dnd and scroll ([#1528](https://github.com/RSSNext/follow/issues/1528)) ([b1e28be](https://github.com/RSSNext/follow/commit/b1e28be2b0049eae73d51a18cd9180b077a512ca))
|
||||
@@ -85,6 +100,7 @@
|
||||
* do not exclude required path params ([f6cbace](https://github.com/RSSNext/follow/commit/f6cbacec853dd8aa901c93c8c86820bbbf1f8232)), closes [#1623](https://github.com/RSSNext/follow/issues/1623)
|
||||
* do not update action setting for archived query ([4adcded](https://github.com/RSSNext/follow/commit/4adcded02179b8d42f1a906b75b10fd403438f8d))
|
||||
* don't cache user session ([e8d7e6c](https://github.com/RSSNext/follow/commit/e8d7e6ce64d09bb1f2b8f3e26f7aba250c3cca84))
|
||||
* don't inject pwa into debug html ([5fec56e](https://github.com/RSSNext/follow/commit/5fec56e9b02ec8a3dbed7c99a7328edf51d41035))
|
||||
* downgrade radix scrollview ([199e0bc](https://github.com/RSSNext/follow/commit/199e0bc7c514822233c42f048691926f4f7cb190))
|
||||
* **dx:** merge script and fix host rewrite ([3fa3bd5](https://github.com/RSSNext/follow/commit/3fa3bd5fc5b730421f6abc4dd2938beea67322dc))
|
||||
* dynamic import dexie-export-import ([48aea7b](https://github.com/RSSNext/follow/commit/48aea7b88e4d72d20e52ce7a5037ef239d80611d))
|
||||
@@ -93,6 +109,7 @@
|
||||
* entry thumbnail keep origin aspect ratio ([6e04e6e](https://github.com/RSSNext/follow/commit/6e04e6eacd6346bd2869c683ec417932a0d13807))
|
||||
* entry title bar margin-left in zen mode ([25abd8f](https://github.com/RSSNext/follow/commit/25abd8ff1c42a37b741676e1b3a3312f99decb8a))
|
||||
* entry title can selectable, fixed [#1428](https://github.com/RSSNext/follow/issues/1428) ([6320c00](https://github.com/RSSNext/follow/commit/6320c00373a98846cdd92235b044fa1fd1b8266e))
|
||||
* entry title truncate ([685ce3c](https://github.com/RSSNext/follow/commit/685ce3cc4165c35918e92b06951d2479ce5adb37))
|
||||
* **entry-column:** pre-render cached entries ([5065c8e](https://github.com/RSSNext/follow/commit/5065c8e52dcba1a8d8f16ce3729b7c2eb7f5a192))
|
||||
* escape for seo meta tags ([9564257](https://github.com/RSSNext/follow/commit/9564257564e417e18bdeedded9397d469e6daf14)), closes [#1232](https://github.com/RSSNext/follow/issues/1232)
|
||||
* explicitly assign a value to `cancelId` for ‘Clear All Data' dialog ([#1624](https://github.com/RSSNext/follow/issues/1624)) ([fdb87cf](https://github.com/RSSNext/follow/commit/fdb87cf5cdf9623f16eafa7e9ae25f4fc7950e05))
|
||||
@@ -112,10 +129,13 @@
|
||||
* float sidebar missing background ([b9982e0](https://github.com/RSSNext/follow/commit/b9982e0a6b44f476621daf30f93f8e740a544a02))
|
||||
* follow external server fetch ua ([072dec0](https://github.com/RSSNext/follow/commit/072dec02b787bcdd8af7f5c0bf25398e2da8c15e))
|
||||
* form button align center ([589c6e4](https://github.com/RSSNext/follow/commit/589c6e469b3fecb1c46f1ec2735494da3367abec))
|
||||
* form content width ([42d66ce](https://github.com/RSSNext/follow/commit/42d66ce19487678a3fd56059b03496d5b50f3b3d))
|
||||
* group date item z index ([8c5c62e](https://github.com/RSSNext/follow/commit/8c5c62e0d698f3a0d72a2ef0595e44986c95320b))
|
||||
* handle tipUsers migration for older feed versions ([#1384](https://github.com/RSSNext/follow/issues/1384)) ([2ca6d80](https://github.com/RSSNext/follow/commit/2ca6d807e3c0626eca79dd6789ae20cdc0639fc3))
|
||||
* handle undefined arguments in executeJavaScript call ([#1958](https://github.com/RSSNext/follow/issues/1958)) ([51519e2](https://github.com/RSSNext/follow/commit/51519e2d7a1a7aee81041c88ec978864903d0b2d))
|
||||
* handling default port in proxy configuration ([0bd76a2](https://github.com/RSSNext/follow/commit/0bd76a24a240951782d44b7e38040c305bb2b9b9))
|
||||
* hide cache control in web ([961bd0f](https://github.com/RSSNext/follow/commit/961bd0fccd63e7e9a21c9bea62cd426bac9a8423))
|
||||
* hide debug in mobile ([930be73](https://github.com/RSSNext/follow/commit/930be73c7e543d695bde22b677d37f42cd5d7b94))
|
||||
* hide to tray on close window ([392135b](https://github.com/RSSNext/follow/commit/392135b8c4b4ec00aa49e66b28bcb0e77390683a))
|
||||
* hide viewSourceContent on mobile ([#1711](https://github.com/RSSNext/follow/issues/1711)) ([86caeb6](https://github.com/RSSNext/follow/commit/86caeb6df42451a8bf8dbb9092d7e0aa8fdd1535))
|
||||
* hot key switch view ([45d0fd9](https://github.com/RSSNext/follow/commit/45d0fd914f374bb7217e9a48c48bc1df4a5a8c6e))
|
||||
@@ -132,12 +152,19 @@
|
||||
* inline image style ([1d0eca1](https://github.com/RSSNext/follow/commit/1d0eca1ca16621634d0d0957b1d4d6c5f037498c)), closes [#1318](https://github.com/RSSNext/follow/issues/1318)
|
||||
* input and toast font style use user custom font ([#1322](https://github.com/RSSNext/follow/issues/1322)) ([c40becf](https://github.com/RSSNext/follow/commit/c40becff782e129c42984b354f2004b82c7f2615))
|
||||
* lint ([dafaf0a](https://github.com/RSSNext/follow/commit/dafaf0a97d40a6df659a7869d7c11f5cf529dfe7))
|
||||
* list unread dot position ([dad33a1](https://github.com/RSSNext/follow/commit/dad33a12db4b270801da6b8c621b3049e6672c27))
|
||||
* load dynamic render assets ([3499535](https://github.com/RSSNext/follow/commit/3499535b4091e3a82734c416528b0766e70f0b63))
|
||||
* load instagram image fail ([f8fd58f](https://github.com/RSSNext/follow/commit/f8fd58f78ec11bc221eb9190ac7b6a66dd858f9c)), closes [#1539](https://github.com/RSSNext/follow/issues/1539)
|
||||
* localeCompare is undefined ([ab28156](https://github.com/RSSNext/follow/commit/ab28156cb8bd998ec1bc6b43b9a44bd2ecd17137))
|
||||
* lock ([97c1ece](https://github.com/RSSNext/follow/commit/97c1ece9e3d855c7dbcf7238e7953e9bd206811c))
|
||||
* mark as read when navigating ([423777e](https://github.com/RSSNext/follow/commit/423777e1372631b8ea8d06913ce55fbdf97f1f07))
|
||||
* mark feed unread dirty, refetch unread next time, fixed [#1830](https://github.com/RSSNext/follow/issues/1830) ([58d0e9c](https://github.com/RSSNext/follow/commit/58d0e9c1902157c2e9fb1444bc1c0db0b775485b))
|
||||
* mark single feed as all read ([a4acd2f](https://github.com/RSSNext/follow/commit/a4acd2fb65335f228875ed5b38f03a9c71b76e1b))
|
||||
* md lint ([c8e556a](https://github.com/RSSNext/follow/commit/c8e556a3ac861cab4a4a7aff1aa2fa51aaca1f42))
|
||||
* media item dot position on mobile ([c67248f](https://github.com/RSSNext/follow/commit/c67248ffc8d77cbdeac289f5ed398248dff41cb3))
|
||||
* missing site url in feed selector ([ea677ac](https://github.com/RSSNext/follow/commit/ea677ac6a3a43489a9508a32ecb22fa38ecf4f27))
|
||||
* mobile need login modal ([0fb16f2](https://github.com/RSSNext/follow/commit/0fb16f2352e9776731522204b838be59f66127a4))
|
||||
* mobile pop back to entry list will refresh data ([3c18768](https://github.com/RSSNext/follow/commit/3c18768968aeb4635933ae616c52de55b6fad2ab))
|
||||
* modal bottom buttons align ([#1216](https://github.com/RSSNext/follow/issues/1216)) ([b97096d](https://github.com/RSSNext/follow/commit/b97096dbd06bb7687b6c1313de45d8e91dee25af))
|
||||
* modal close button overlaps the select content ([#1166](https://github.com/RSSNext/follow/issues/1166)) ([3c103ed](https://github.com/RSSNext/follow/commit/3c103ed15daeb1f57a001d615c047c303087ba46))
|
||||
* **modal:** close button can not click on electron ([c544dfc](https://github.com/RSSNext/follow/commit/c544dfcc8d4613e8d4f6025dd8a60cf679881680))
|
||||
@@ -147,10 +174,14 @@
|
||||
* **modal:** repeat user profile dialog ([#1155](https://github.com/RSSNext/follow/issues/1155)) ([ad86372](https://github.com/RSSNext/follow/commit/ad86372bfb345b6f921da783c401be30cdbe4b89))
|
||||
* motion button motion style in mobile ([611d2cf](https://github.com/RSSNext/follow/commit/611d2cf0349be360aa86601ed4eb0522118bad49))
|
||||
* multi select state ([f476483](https://github.com/RSSNext/follow/commit/f476483fe3b944371c0327495d53ec3d42006dda))
|
||||
* nightly auto updater ([27b3bf4](https://github.com/RSSNext/follow/commit/27b3bf4f50badb8fac4b497d18a25002ed3b1981))
|
||||
* not showing feed certification icon on the sidebar ([#1442](https://github.com/RSSNext/follow/issues/1442)) ([b395891](https://github.com/RSSNext/follow/commit/b395891b66a581254f24aae75d0d61869fb6fb33))
|
||||
* omit cacheDimensions from img attributes in MediaImpl ([ec12b35](https://github.com/RSSNext/follow/commit/ec12b3538f42c8596c4e700ae2284a02b4d7791e))
|
||||
* only show ComboboxOptions when there are suggestions ([136aa20](https://github.com/RSSNext/follow/commit/136aa205794b6193826d1839350e65228d2b4f20))
|
||||
* only use discussion for feed error ([e30783b](https://github.com/RSSNext/follow/commit/e30783bfaaa9e40815493d28b49ba7c41ac86414))
|
||||
* open native context menu when select text in social media item, fixed [#1454](https://github.com/RSSNext/follow/issues/1454) ([e7b8f66](https://github.com/RSSNext/follow/commit/e7b8f660bb8b6c2edfc04c0dda8702f881971aed))
|
||||
* optimize audio source comparison in audio player ([#1987](https://github.com/RSSNext/follow/issues/1987)) ([322435a](https://github.com/RSSNext/follow/commit/322435a20f5e076ecd23001d9d677dd0857e1726))
|
||||
* optimize no audio cover list item style, fixed [#1979](https://github.com/RSSNext/follow/issues/1979) ([8de8501](https://github.com/RSSNext/follow/commit/8de8501bb7022b3d1d31caed03558666afc64f57))
|
||||
* optimize print mode ([6f1eb26](https://github.com/RSSNext/follow/commit/6f1eb26eb110b8ad061473e05c451debc9c69074))
|
||||
* optimize some styles ([9b99bf4](https://github.com/RSSNext/follow/commit/9b99bf4428cf6f1ca3218a3074a944af4d014f57))
|
||||
* optimize the animation of the Follow button on the User Profile Modal ([#1156](https://github.com/RSSNext/follow/issues/1156)) ([87717d6](https://github.com/RSSNext/follow/commit/87717d642607cca4254f11d673a8a910fc6ab076))
|
||||
@@ -181,16 +212,24 @@
|
||||
* remove gcore icon ([#1220](https://github.com/RSSNext/follow/issues/1220)) ([486fa20](https://github.com/RSSNext/follow/commit/486fa202ee9488981a733f235f95c90a073e7166))
|
||||
* remove hardcode minfest ([0432618](https://github.com/RSSNext/follow/commit/04326186b71dc840e1454e6a1573257c97db32c8))
|
||||
* remove immer set to avoid object extensible ([7e5a791](https://github.com/RSSNext/follow/commit/7e5a79155a083a8242579dee18d019049b7ad6f5))
|
||||
* remove mouse enter event on mobile ([279e402](https://github.com/RSSNext/follow/commit/279e4025a5b14ad5cf5972bf439d2a30ce7d7d79))
|
||||
* remove prev entries ids ref ([996629c](https://github.com/RSSNext/follow/commit/996629c14c752f76b65d423ebc23d60b315dee77))
|
||||
* remove skeleton when app load but in 404 ([54d4e52](https://github.com/RSSNext/follow/commit/54d4e529c796e6cc22c36b2a9a1e949b1dad5b37))
|
||||
* remove stack when close sheet ([eeb785d](https://github.com/RSSNext/follow/commit/eeb785de3f822166a04b3e6916fc107fb600db25)), closes [#1910](https://github.com/RSSNext/follow/issues/1910)
|
||||
* remove vercel header rewrite ([#1463](https://github.com/RSSNext/follow/issues/1463)) ([#1480](https://github.com/RSSNext/follow/issues/1480)) ([94971da](https://github.com/RSSNext/follow/commit/94971dad4e1d828aa4c90d8f02445cc04a8500c9))
|
||||
* remove vercel header rewrite for assets ([79e6f48](https://github.com/RSSNext/follow/commit/79e6f483265216773e0ccf5ac0690d06300d3e80))
|
||||
* remove wdyr in prod ([70e3b72](https://github.com/RSSNext/follow/commit/70e3b72b0ae88a722e2ff9e7d6027003f88829e2))
|
||||
* replace Avatar component with UserAvatar in ranking and transaction sections ([#1759](https://github.com/RSSNext/follow/issues/1759)) ([52c3695](https://github.com/RSSNext/follow/commit/52c3695355ed3962d9ad53e61a612d88c54ab650))
|
||||
* response error toast style ([7748588](https://github.com/RSSNext/follow/commit/77485886089e9faea54cf80a96a48a0bedd2a39e))
|
||||
* revalidate when switch from subscription startupScreen ([e63c12c](https://github.com/RSSNext/follow/commit/e63c12c27227341a2477eb06fa039e2b0a2a00e5))
|
||||
* revert electron bump ([#1991](https://github.com/RSSNext/follow/issues/1991)) ([200415c](https://github.com/RSSNext/follow/commit/200415c77f52d11a43c2610c5c58c61fbbfb23f8))
|
||||
* revert merge chunk ([4a9679b](https://github.com/RSSNext/follow/commit/4a9679bad109a786b80939ca9ead32f1505be186))
|
||||
* scroll bar z index ([5057999](https://github.com/RSSNext/follow/commit/50579995367b871e84768c5983b3302f75f8e077)), closes [#1233](https://github.com/RSSNext/follow/issues/1233)
|
||||
* scroll out mark read logic ([eaecb25](https://github.com/RSSNext/follow/commit/eaecb252d322b5f2e8e89873523dfbe8d213848c))
|
||||
* scroll out to mark read in mobile ([a44d598](https://github.com/RSSNext/follow/commit/a44d59820ba7e62b5db9de478f813cd9f287f670))
|
||||
* scroll state for mobile float bar ([126206b](https://github.com/RSSNext/follow/commit/126206b995f47c17ed60c2a07296987dd0b8dc95))
|
||||
* **security:** add dompurify for raw document string pre-cleaning on readability to avoid xss attack ([#2000](https://github.com/RSSNext/follow/issues/2000)) ([f2ed678](https://github.com/RSSNext/follow/commit/f2ed678afc5a17b099a5931aa5af3a36138750d0))
|
||||
* selected id state ([36cdbbd](https://github.com/RSSNext/follow/commit/36cdbbd706c41b10b6fd19d84756b35f8c0a3f8b))
|
||||
* selecting state ([146fe8f](https://github.com/RSSNext/follow/commit/146fe8fa5ccf4c6211bb5d72be9efbb0714de878))
|
||||
* server styles ([ff6b0f7](https://github.com/RSSNext/follow/commit/ff6b0f780d80d43bb974736f8579f70a45e1be61))
|
||||
* **server:** complie esmodule ([c438119](https://github.com/RSSNext/follow/commit/c438119ea8208f4da14da2294a381a6c34a14e25))
|
||||
@@ -203,6 +242,7 @@
|
||||
* setting loader type error ([#1469](https://github.com/RSSNext/follow/issues/1469)) ([6ef5622](https://github.com/RSSNext/follow/commit/6ef5622a32eaaebfeec32cca1000bf908f742e34))
|
||||
* **share:** normal list item layout ([3a0c039](https://github.com/RSSNext/follow/commit/3a0c0393e01e09ebf86ab1415b3d84bca6d2b882))
|
||||
* **share:** og image grid width and image align top to description ([14e37da](https://github.com/RSSNext/follow/commit/14e37da0cebbdb1b283c562c21acc2f8ba385bf9))
|
||||
* sheet stack dismiss transition ([6a30f23](https://github.com/RSSNext/follow/commit/6a30f2363e3d99c95b3b7a5415c4fd898d1c12a4))
|
||||
* shiki editor paste rich-text ployfill ([9d0bc51](https://github.com/RSSNext/follow/commit/9d0bc515ade4243fef018c8c606532654d5c76ef))
|
||||
* **shortcut:** add cmd+k to guide ([e9ab9b6](https://github.com/RSSNext/follow/commit/e9ab9b6f379abe426ac751961e3767c8aa20b663))
|
||||
* should remove app skeleton in error page ([4073632](https://github.com/RSSNext/follow/commit/4073632dbf236e19926e013d5048f59f90d9b3ae))
|
||||
@@ -221,17 +261,23 @@
|
||||
* **store:** immer draft should to raw ([3a3992d](https://github.com/RSSNext/follow/commit/3a3992d63f0f62cd37aa5accb4910ad79e3190e8))
|
||||
* **store:** singleton store guard ([5a8725b](https://github.com/RSSNext/follow/commit/5a8725b50767bb6faddca6e0af6cef2cfb28da29))
|
||||
* **stream:** prevent request if no ids ([a92ef49](https://github.com/RSSNext/follow/commit/a92ef49dedf480f519525cf8f25a0e5383b27059))
|
||||
* style ([ce1942a](https://github.com/RSSNext/follow/commit/ce1942a29a96f1cf72fc516ce54b28007b4fd40c))
|
||||
* style for audio item ([7e4653f](https://github.com/RSSNext/follow/commit/7e4653f01cc987614843db06871b2d3bd30221f5))
|
||||
* **style:** add missing sticky border ([cff217a](https://github.com/RSSNext/follow/commit/cff217aeead10622e0982a7668f7d14eab53e1a7))
|
||||
* **styles:** radio group label margin ([c6deefc](https://github.com/RSSNext/follow/commit/c6deefc66167b7e8eb91bd565c2bac86eb8662a2))
|
||||
* sw register ([5bbfb2d](https://github.com/RSSNext/follow/commit/5bbfb2d4e23fb49dde949cbeffe2a2c748e21595))
|
||||
* sync active view after close sheet ([6f751a4](https://github.com/RSSNext/follow/commit/6f751a4a21796652d8cfc38b6209d7bfb4016ade))
|
||||
* sync unread when fetch unread ([196b717](https://github.com/RSSNext/follow/commit/196b717a7fbdd362d9c2128223272c6616363bc5))
|
||||
* text wrap for feed title ([f123e5c](https://github.com/RSSNext/follow/commit/f123e5c0555976b496a5e79f3d5c7937984ebdeb))
|
||||
* text wrap not always ([3cb6364](https://github.com/RSSNext/follow/commit/3cb6364462a3c738af3a7b86eae17513ccb6705c))
|
||||
* the volume bar can click and adjust style. ([#1474](https://github.com/RSSNext/follow/issues/1474)) ([c409a5c](https://github.com/RSSNext/follow/commit/c409a5c7945eb178fca5274dd6ac64f82025821d))
|
||||
* theme cannot be switched ([#1157](https://github.com/RSSNext/follow/issues/1157)) ([d5be028](https://github.com/RSSNext/follow/commit/d5be0287ad03e47635be057222ca7155a033ae80))
|
||||
* **tip-modal:** radio cards align center ([6f041f9](https://github.com/RSSNext/follow/commit/6f041f9ef9099090d9f995d152a4adb32a8e8848))
|
||||
* **toc:** fix text truncate in title line ([f9b1a61](https://github.com/RSSNext/follow/commit/f9b1a61c0185b449184b34df5f3a3869a4e722a4))
|
||||
* **toc:** should focus when toc item clicked ([f51dfdd](https://github.com/RSSNext/follow/commit/f51dfddc9ef40f4a7f226f32f9357e03a04f6ee0))
|
||||
* translate form style ([6f3bb61](https://github.com/RSSNext/follow/commit/6f3bb61023dde1d58164425d8649c90bb4f680c6)), closes [#1184](https://github.com/RSSNext/follow/issues/1184)
|
||||
* **translations:** update zh-CN locale files for accuracy ([#1739](https://github.com/RSSNext/follow/issues/1739)) ([83c9f71](https://github.com/RSSNext/follow/commit/83c9f717dd7092dc4a4b1106961d746988066fd9))
|
||||
* trending api based on language ([83ca873](https://github.com/RSSNext/follow/commit/83ca87349598acc361c8128bbcb014d89fcb56cf))
|
||||
* trial limit ([eee2bf8](https://github.com/RSSNext/follow/commit/eee2bf8771d2d30bba1f534984e3ca8d5e26cf04))
|
||||
* try fix dayjs init ([093f80d](https://github.com/RSSNext/follow/commit/093f80d9da223c567125285cc0f312f419bb4042))
|
||||
* try fix float bar inset bottom ([3110f95](https://github.com/RSSNext/follow/commit/3110f953da896302a90bb65bd44de034fbb87ec4))
|
||||
@@ -253,10 +299,14 @@
|
||||
* update version toast ([25e7cea](https://github.com/RSSNext/follow/commit/25e7cea3c139335960c3de2922cf0ffa9c9c6c39)), closes [#1450](https://github.com/RSSNext/follow/issues/1450)
|
||||
* **upgrade:** changelog container should w-full ([1551bf6](https://github.com/RSSNext/follow/commit/1551bf648c511cbf615f515b2e2d93077b0e42b4))
|
||||
* use external link for login button ([d1975c2](https://github.com/RSSNext/follow/commit/d1975c20217290b2b7dc39866826c99f803dbd57))
|
||||
* use replace for discover form navigation ([63602f2](https://github.com/RSSNext/follow/commit/63602f266390781a3552a14eefa35455f19c92b6))
|
||||
* use turbo run concurrently task ([742f915](https://github.com/RSSNext/follow/commit/742f91517d87d136bc8dc6ee65008e9b6880d435))
|
||||
* validate file format for OPML and XML in import schema ([2f9bd43](https://github.com/RSSNext/follow/commit/2f9bd43775dd0260ade8aac80f7067b927edba7a))
|
||||
* vercel do not support `__` prefix for api route ([45a66e0](https://github.com/RSSNext/follow/commit/45a66e0f972d18831795d92b1d3c1f3893f396dc))
|
||||
* vercel rewrite config ([#1203](https://github.com/RSSNext/follow/issues/1203)) ([c954d61](https://github.com/RSSNext/follow/commit/c954d61f074e282a9a86cbf1d1546748871c20e7))
|
||||
* video media can not play in video view ([4cbf8a5](https://github.com/RSSNext/follow/commit/4cbf8a54fcf11fb71ff935baee52c79a83f5035c)), closes [#1645](https://github.com/RSSNext/follow/issues/1645)
|
||||
* When pasting the entire URL, auto adjust the URL prefix ([#1762](https://github.com/RSSNext/follow/issues/1762)) ([3c7aeac](https://github.com/RSSNext/follow/commit/3c7aeacc90cbdcbe6bf4b06572d74f269f2c8854)), closes [#1761](https://github.com/RSSNext/follow/issues/1761)
|
||||
* window titlebar maximize state sync, fixed [#1982](https://github.com/RSSNext/follow/issues/1982) ([#1989](https://github.com/RSSNext/follow/issues/1989)) ([7ad1e30](https://github.com/RSSNext/follow/commit/7ad1e305c3167633d58b6b621dba2cd63d1cf528))
|
||||
* wrap with Ellipsis ([3ba9093](https://github.com/RSSNext/follow/commit/3ba90936931ad36790a68ee90a2c1582054bb90a))
|
||||
* zoom width limit ([eaf33d2](https://github.com/RSSNext/follow/commit/eaf33d272f8675cd929eb7227578b6364716e60a))
|
||||
|
||||
@@ -274,14 +324,18 @@
|
||||
* add follow user button in profile modal ([#1147](https://github.com/RSSNext/follow/issues/1147)) ([7c60d5e](https://github.com/RSSNext/follow/commit/7c60d5e91dd4a21872217427bd99fe8eae688ce1))
|
||||
* add hydrate data type-safe helper ([cb6a65b](https://github.com/RSSNext/follow/commit/cb6a65b7cc1651d86b83b5b4089a7145cd59b0be))
|
||||
* add image preview in picture gallery images ([59728a8](https://github.com/RSSNext/follow/commit/59728a89295c2a9c6130651d06699eef027fef5e))
|
||||
* add mobile top timeline setting ([fe48d7c](https://github.com/RSSNext/follow/commit/fe48d7cf02a202a1f14bbfe3abe4c813629ac968))
|
||||
* add more actions to entry header ([#1993](https://github.com/RSSNext/follow/issues/1993)) ([5c4b5f0](https://github.com/RSSNext/follow/commit/5c4b5f0095cff53f1ce70d66f2275d0a9c73e985))
|
||||
* add old browser check ([a4796ce](https://github.com/RSSNext/follow/commit/a4796ce4c9a0d1558b9467b80f1f0806dfaba321))
|
||||
* add random color for user fallback bg ([dcbae89](https://github.com/RSSNext/follow/commit/dcbae89020e88947be693c100c644ee603519e96))
|
||||
* add reveal log file ([adbdf74](https://github.com/RSSNext/follow/commit/adbdf7472b6789a365489b2c5b09dd503ec648e9))
|
||||
* add sentry trace id ([40843ac](https://github.com/RSSNext/follow/commit/40843ac79f390d0db81490522475a3557f57b2e4))
|
||||
* add server announcement toast ([7b34357](https://github.com/RSSNext/follow/commit/7b3435749b8516466eae388172694f22d6b26a83))
|
||||
* add updatelog modal ([84228bc](https://github.com/RSSNext/follow/commit/84228bc5c8755c4b957bc901e6e552ef176ed00c))
|
||||
* add zen mode quick menu item and reduce check show sidebar interval ([f5d43d6](https://github.com/RSSNext/follow/commit/f5d43d6480727e0e5e3f341c0c4c3e7a1f73ce81))
|
||||
* adjust more ui ([08929ab](https://github.com/RSSNext/follow/commit/08929ab3ae15758850d04b82f7773358579c4a78))
|
||||
* allow disable auto group behavior ([23fd936](https://github.com/RSSNext/follow/commit/23fd9368baea10b15b89baf27a422e5695a08f7b)), closes [#1602](https://github.com/RSSNext/follow/issues/1602)
|
||||
* allow fille default title when editing feed ([495b29e](https://github.com/RSSNext/follow/commit/495b29e5898f18506577016dfe358f9c0add8035)), closes [#1503](https://github.com/RSSNext/follow/issues/1503)
|
||||
* and or condition for action ([#1616](https://github.com/RSSNext/follow/issues/1616)) ([4193a6b](https://github.com/RSSNext/follow/commit/4193a6b14d284a5e399fe94d9f305146179a75b4))
|
||||
* **app:** support cache limit and clean cache ([dee294d](https://github.com/RSSNext/follow/commit/dee294dda589ca9e2eaee8a7e55197635b6323c7))
|
||||
* bring rehypeUrlToAnchor back ([6f0cc4d](https://github.com/RSSNext/follow/commit/6f0cc4d566c9f2f552f0fedf1a8e570a817e0f56)), closes [#1373](https://github.com/RSSNext/follow/issues/1373)
|
||||
@@ -297,18 +351,22 @@
|
||||
* **external:** new open by deeplink logic ([71fcf50](https://github.com/RSSNext/follow/commit/71fcf50d0fd3ac30f8e9c45db90314672904a615))
|
||||
* fetch stream entry content ([1739208](https://github.com/RSSNext/follow/commit/173920802edf1f4e13eee68bf5d541391ca6ebf9))
|
||||
* focusable ([eb01d03](https://github.com/RSSNext/follow/commit/eb01d030129f6196d6e9855be42a218be9d5668b))
|
||||
* fold the long text content of social media ([e46b30a](https://github.com/RSSNext/follow/commit/e46b30a07fe74e1bacb234962b1542c849d2177d))
|
||||
* hide trend ([2b92599](https://github.com/RSSNext/follow/commit/2b92599e18d3d33fd0371d4d3a5f3e3a6d94aeb6))
|
||||
* **i18n:** added multiple text translations (zh-TW) ([#1621](https://github.com/RSSNext/follow/issues/1621)) ([a15f23a](https://github.com/RSSNext/follow/commit/a15f23a5c7bb697c75c7fecf8603612b2584baa8))
|
||||
* **i18n:** discover categories and mark all read undo button ([#1506](https://github.com/RSSNext/follow/issues/1506)) ([06bdf6c](https://github.com/RSSNext/follow/commit/06bdf6cfb90b03e1624189ebc05a389495e8bedc))
|
||||
* **i18n:** translations (zh-TW) ([#1942](https://github.com/RSSNext/follow/issues/1942)) ([fea74b4](https://github.com/RSSNext/follow/commit/fea74b47829921822e0c701ea36ab1d4ac1e2083))
|
||||
* **icon:** use gradient fallback background ([e827002](https://github.com/RSSNext/follow/commit/e8270025e469d9a0463d267d3da591a2991951bd))
|
||||
* image zoom ([1e47ba2](https://github.com/RSSNext/follow/commit/1e47ba25671000408e69fc3bae2c4626d0bd664e)), closes [#1183](https://github.com/RSSNext/follow/issues/1183)
|
||||
* **infra:** electron app can hot update renderer layer ([#1209](https://github.com/RSSNext/follow/issues/1209)) ([ca4751a](https://github.com/RSSNext/follow/commit/ca4751acd275579614a477d133ed643fca3fbf1a))
|
||||
* **integration:** add outline integration ([#1229](https://github.com/RSSNext/follow/issues/1229)) ([0d0266b](https://github.com/RSSNext/follow/commit/0d0266b25189a74efdc63ce0062f3a379d4a0729))
|
||||
* **integration:** Add readeck integration ([#1972](https://github.com/RSSNext/follow/issues/1972)) ([1ce3f5b](https://github.com/RSSNext/follow/commit/1ce3f5b8ba95b16ad1b12e702027cede3590491a))
|
||||
* List delete add secondary confirmation ([#1254](https://github.com/RSSNext/follow/issues/1254)) ([14f2bac](https://github.com/RSSNext/follow/commit/14f2bac8f3ba7e8f2dbd3958a4394c5b11ea2537))
|
||||
* load archived entries automatically ([5fe9e0c](https://github.com/RSSNext/follow/commit/5fe9e0c0e24460ca0fe435db03b753e9dcd3df17))
|
||||
* manual action ([#1867](https://github.com/RSSNext/follow/issues/1867)) ([0eedbba](https://github.com/RSSNext/follow/commit/0eedbbadc263b474e2d4bfd5b6c498ac39c16c34))
|
||||
* **mark-all-button:** add countdown to auto-confirm message ([#1414](https://github.com/RSSNext/follow/issues/1414)) ([e1a5fc6](https://github.com/RSSNext/follow/commit/e1a5fc63f20c941140071789c9b67685da19ea5c))
|
||||
* merge redirect page into login page ([2fa16b7](https://github.com/RSSNext/follow/commit/2fa16b75d376fe04472e6c91675c67e725da8633))
|
||||
* migrate to better auth ([#1951](https://github.com/RSSNext/follow/issues/1951)) ([9102203](https://github.com/RSSNext/follow/commit/910220395631bcf86f56bfc2b2168ac95852444c))
|
||||
* mobile design ([#1568](https://github.com/RSSNext/follow/issues/1568)) ([edd4f9e](https://github.com/RSSNext/follow/commit/edd4f9e5a6dc041e9eae2cee5ddf4eb624527ef5)), closes [#1575](https://github.com/RSSNext/follow/issues/1575)
|
||||
* move hideExtraBadge ([2f14c30](https://github.com/RSSNext/follow/commit/2f14c30307a895bc866ac57989df1dc624eab4e6))
|
||||
* multi select with shift ([2158b1c](https://github.com/RSSNext/follow/commit/2158b1cc255baf3ff5e4e1a5806d85b7df64bd55)), closes [#1256](https://github.com/RSSNext/follow/issues/1256)
|
||||
@@ -326,9 +384,12 @@
|
||||
* separate packaging for macOS x64 and arm64 architectures ([#1389](https://github.com/RSSNext/follow/issues/1389)) ([3e8de30](https://github.com/RSSNext/follow/commit/3e8de308a3b3a07c58ab3fd7d26aad5aa2328c99))
|
||||
* set default unreadOnly to true ([8c8c765](https://github.com/RSSNext/follow/commit/8c8c765ff518b6ccc6457959fdf3fe8a4ddeee22))
|
||||
* show progress in searching ([e592e97](https://github.com/RSSNext/follow/commit/e592e97c9e0e6da8451c09b9b5f27612e6dbb971)), closes [#1457](https://github.com/RSSNext/follow/issues/1457)
|
||||
* **social:** improve image gallery grid ([5dc6d9e](https://github.com/RSSNext/follow/commit/5dc6d9ee227fa714f39957ff6e744e3079a3e57d))
|
||||
* support alway on top, fixed [#1740](https://github.com/RSSNext/follow/issues/1740) ([09df663](https://github.com/RSSNext/follow/commit/09df663a1c0b9a5ec5d30f2609a36b09c3e66e56))
|
||||
* support drag-and-drop when importing opml ([#2001](https://github.com/RSSNext/follow/issues/2001)) ([bad7be9](https://github.com/RSSNext/follow/commit/bad7be9a8fa0d49c92d2cd17d441303643564f57))
|
||||
* support markdown for announcement content ([539ec03](https://github.com/RSSNext/follow/commit/539ec03293fc6e3a11dbec69bbf78fe1c5dd2e8c))
|
||||
* support zen mode sidebar entry timeline selector ([4ab132c](https://github.com/RSSNext/follow/commit/4ab132c593a7acce0167d02f6025030775a9fac5))
|
||||
* **trending:** support language filter ([1cb5b73](https://github.com/RSSNext/follow/commit/1cb5b73eb5901f242d79f357d52bca7af5d8c8b3))
|
||||
* unified feed title ([b86afe5](https://github.com/RSSNext/follow/commit/b86afe5a9789ad13c5a026adf553d2c6bc333bff))
|
||||
* uniq macos entry column position ([4b63023](https://github.com/RSSNext/follow/commit/4b63023389e125353de343b679840e5fbca1a4d3))
|
||||
* update og image ([c58df35](https://github.com/RSSNext/follow/commit/c58df35d1f48e7374973a393c9b7efea38d12494))
|
||||
@@ -336,6 +397,7 @@
|
||||
* update server hono ([5beaca3](https://github.com/RSSNext/follow/commit/5beaca3c772d7bc097fd53779c581eb6b41c9eaa))
|
||||
* update text ([5aae827](https://github.com/RSSNext/follow/commit/5aae8273dcd999bc11904bc8c9d7b72e769fa200))
|
||||
* update text ([89bef43](https://github.com/RSSNext/follow/commit/89bef43267199f60de376c3998d3cfff26faad23))
|
||||
* update zh-HK file ([#1955](https://github.com/RSSNext/follow/issues/1955)) ([9364761](https://github.com/RSSNext/follow/commit/936476169caba5cbacafe6f4d35f7857add32802))
|
||||
* upload arm64 dmg separately ([1d77c09](https://github.com/RSSNext/follow/commit/1d77c092ce18fbabe6cfbbd21d9a96e3445795da))
|
||||
* use FeedTitle ([73d2c30](https://github.com/RSSNext/follow/commit/73d2c30416ad3f2da626db003996c0fb036025ac))
|
||||
* **ux:** support native space key to page down, fixed [#1121](https://github.com/RSSNext/follow/issues/1121) ([baa66fe](https://github.com/RSSNext/follow/commit/baa66feaf19416d2b9e5efe6b79f6af1b3966404))
|
||||
@@ -348,6 +410,7 @@
|
||||
|
||||
* add code cache cleaner ([a0fd15f](https://github.com/RSSNext/follow/commit/a0fd15f4abbab340264da4281f2e4ca9f89ffffa))
|
||||
* batch profile ([#1464](https://github.com/RSSNext/follow/issues/1464)) ([a3e9c0e](https://github.com/RSSNext/follow/commit/a3e9c0edc83628d9c0ceb998d95184c5fd635f6f))
|
||||
* enable router navigation transition ([24e1aea](https://github.com/RSSNext/follow/commit/24e1aead5e9bbb98b59194166fa4fd07eb167353))
|
||||
* lazy show action, reduce lcp time ([fcf775c](https://github.com/RSSNext/follow/commit/fcf775c976591258f83dea6e34ca3161b539b15e))
|
||||
* modify some animations to CSS animations ([9ec3fe5](https://github.com/RSSNext/follow/commit/9ec3fe562bf3527ad4279a9a57c0b0bb5934dba1))
|
||||
* optmize masonry perfermance ([d1748c6](https://github.com/RSSNext/follow/commit/d1748c6ce93f7075270d8cc6e88cbd944d165d50))
|
||||
@@ -359,6 +422,7 @@
|
||||
|
||||
### Reverts
|
||||
|
||||
* Revert "build: use pnpm catalogs" ([37164a3](https://github.com/RSSNext/follow/commit/37164a3674fa0bdf5b10919e788142a3d1b1cce3))
|
||||
* Revert "perf: reduce the number of items rendered on the first render" ([9e45d04](https://github.com/RSSNext/follow/commit/9e45d0441ef16fb334af555c22276f7d77a72733)), closes [#1659](https://github.com/RSSNext/follow/issues/1659)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ If you prefer to develop in Electron, follow these steps:
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
> **Tip:** If you encounter login issues, copy the `authjs.session-token` from your browser's cookies into the app.
|
||||
> **Tip:** If you encounter login issues, copy the `better-auth.session_token` from your browser's cookies into the app.
|
||||
|
||||
## Contribution Guidelines
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ pnpm run dev
|
||||
Since it is not very convenient to develop in Electron, the first way to develop and contribute is recommended at this stage.
|
||||
|
||||
> [!TIP]
|
||||
> If you can't log in to the app, copy the `authjs.session-token` in the cookie from your browser into the app.
|
||||
> If you can't log in to the app, copy the `better-auth.session_token` in the cookie from your browser into the app.
|
||||
|
||||
## 📝 License
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
import "../../types/vite"
|
||||
import "../../types/authjs"
|
||||
|
||||
declare global {
|
||||
const GIT_COMMIT_HASH: string
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
"@openpanel/web": "1.0.1",
|
||||
"@sentry/electron": "5.7.0",
|
||||
"builder-util-runtime": "9.2.10",
|
||||
"dompurify": "~3.2.2",
|
||||
"electron-context-menu": "4.0.4",
|
||||
"electron-log": "5.2.3",
|
||||
"electron-squirrel-startup": "1.0.1",
|
||||
"electron-updater": "^6.3.9",
|
||||
"es-toolkit": "1.27.0",
|
||||
"es-toolkit": "1.29.0",
|
||||
"fast-folder-size": "2.3.0",
|
||||
"font-list": "1.5.1",
|
||||
"i18next": "^24.0.2",
|
||||
@@ -51,9 +52,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/node": "^22.10.0",
|
||||
"@types/node": "^22.10.1",
|
||||
"electron": "33.2.0",
|
||||
"electron-devtools-installer": "3.2.0",
|
||||
"hono": "4.6.11"
|
||||
"hono": "4.6.12"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import os from "node:os"
|
||||
|
||||
import { version as appVersion } from "@pkg"
|
||||
|
||||
export const mode = process.env.NODE_ENV
|
||||
export const isDev = mode === "development"
|
||||
|
||||
export const channel: "development" | "beta" | "alpha" | "stable" = isDev ? "development" : "beta"
|
||||
export const isNightlyBuild = appVersion.includes("nightly")
|
||||
|
||||
export const channel: "development" | "beta" | "alpha" | "stable" | "nightly" = isDev
|
||||
? "development"
|
||||
: isNightlyBuild
|
||||
? "nightly"
|
||||
: "beta"
|
||||
|
||||
const { platform } = process
|
||||
export const isMacOS = platform === "darwin"
|
||||
|
||||
+7
-15
@@ -14,7 +14,7 @@ import { updateProxy } from "./lib/proxy"
|
||||
import { handleUrlRouting } from "./lib/router"
|
||||
import { store } from "./lib/store"
|
||||
import { registerAppTray } from "./lib/tray"
|
||||
import { setAuthSessionToken, updateNotificationsToken } from "./lib/user"
|
||||
import { setBetterAuthSessionCookie, updateNotificationsToken } from "./lib/user"
|
||||
import { registerUpdater } from "./updater"
|
||||
import { cleanupOldRender } from "./updater/hot-updater"
|
||||
import {
|
||||
@@ -189,24 +189,16 @@ function bootstrap() {
|
||||
const urlObj = new URL(url)
|
||||
|
||||
if (urlObj.hostname === "auth" || urlObj.pathname === "//auth") {
|
||||
const token = urlObj.searchParams.get("token")
|
||||
const ck = urlObj.searchParams.get("ck")
|
||||
const userId = urlObj.searchParams.get("userId")
|
||||
|
||||
if (token && apiURL) {
|
||||
setAuthSessionToken(token)
|
||||
if (ck && apiURL) {
|
||||
setBetterAuthSessionCookie(ck)
|
||||
const cookie = atob(ck)
|
||||
mainWindow.webContents.session.cookies.set({
|
||||
url: apiURL,
|
||||
name: "authjs.session-token",
|
||||
value: token,
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
domain: new URL(apiURL).hostname,
|
||||
sameSite: "no_restriction",
|
||||
})
|
||||
mainWindow.webContents.session.cookies.set({
|
||||
url: apiURL,
|
||||
name: "authjs.callback-url",
|
||||
value: env.VITE_WEB_URL,
|
||||
name: cookie.split("=")[0],
|
||||
value: cookie.split("=")[1],
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
domain: new URL(apiURL).hostname,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { hc } from "hono/client"
|
||||
import { ofetch } from "ofetch"
|
||||
|
||||
import { logger } from "../logger"
|
||||
import { getAuthSessionToken, getUser } from "./user"
|
||||
import { getBetterAuthSessionCookie, getUser } from "./user"
|
||||
|
||||
const abortController = new AbortController()
|
||||
export const apiFetch = ofetch.create({
|
||||
@@ -14,8 +14,8 @@ export const apiFetch = ofetch.create({
|
||||
signal: abortController.signal,
|
||||
retry: false,
|
||||
onRequest({ request }) {
|
||||
const authSessionToken = getAuthSessionToken()
|
||||
if (!authSessionToken) {
|
||||
const betterAuthSessionCookie = getBetterAuthSessionCookie()
|
||||
if (!betterAuthSessionCookie) {
|
||||
abortController.abort()
|
||||
return
|
||||
}
|
||||
@@ -32,12 +32,12 @@ export const apiFetch = ofetch.create({
|
||||
export const apiClient = hc<AppType>("", {
|
||||
fetch: async (input, options = {}) => apiFetch(input.toString(), options),
|
||||
headers() {
|
||||
const authSessionToken = getAuthSessionToken()
|
||||
const betterAuthSessionCookie = getBetterAuthSessionCookie()
|
||||
const user = getUser()
|
||||
return {
|
||||
"X-App-Version": PKG.version,
|
||||
"X-App-Dev": process.env.NODE_ENV === "development" ? "1" : "0",
|
||||
Cookie: authSessionToken ? `authjs.session-token=${authSessionToken}` : "",
|
||||
Cookie: betterAuthSessionCookie ? atob(betterAuthSessionCookie) : "",
|
||||
"User-Agent": `Follow/${PKG.version}${user?.id ? ` uid: ${user.id}` : ""}`,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ const streamPipeline = promisify(pipeline)
|
||||
export async function downloadFile(url: string, dest: string) {
|
||||
const res = await fetch(url)
|
||||
|
||||
// 检查响应是否成功
|
||||
// Check whether it responds successfully.
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to fetch ${url}: ${res.statusText}`)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Readability } from "@mozilla/readability"
|
||||
import { name, version } from "@pkg"
|
||||
import DOMPurify from "dompurify"
|
||||
import { parseHTML } from "linkedom"
|
||||
import { fetch } from "ofetch"
|
||||
|
||||
@@ -8,7 +9,7 @@ import { isDev } from "~/env"
|
||||
const userAgents = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 ${name}/${version}`
|
||||
|
||||
export async function readability(url: string) {
|
||||
const documentString = await fetch(url, {
|
||||
const dirtyDocumentString = await fetch(url, {
|
||||
headers: {
|
||||
"User-Agent": userAgents,
|
||||
Accept: "text/html",
|
||||
@@ -26,11 +27,14 @@ export async function readability(url: string) {
|
||||
return res.text()
|
||||
})
|
||||
|
||||
// For avoid xss attack from readability, the raw document string should be purified.
|
||||
const cleanedDocumentString = DOMPurify.sanitize(dirtyDocumentString)
|
||||
|
||||
// FIXME: linkedom does not handle relative addresses in strings. Refer to
|
||||
// @see https://github.com/WebReflection/linkedom/issues/153
|
||||
// JSDOM handles it correctly, but JSDOM introduces canvas binding.
|
||||
|
||||
const { document } = parseHTML(documentString)
|
||||
const { document } = parseHTML(cleanedDocumentString)
|
||||
const baseUrl = new URL(url).origin
|
||||
|
||||
document.querySelectorAll("a").forEach((a) => {
|
||||
|
||||
+16
-10
@@ -1,13 +1,15 @@
|
||||
import type { User } from "@auth/core/types"
|
||||
import type { Credentials } from "@eneris/push-receiver/dist/types"
|
||||
|
||||
import { logger } from "~/logger"
|
||||
|
||||
import { apiClient } from "./api-client"
|
||||
import { store } from "./store"
|
||||
|
||||
const AuthKey = "authSessionToken"
|
||||
export const setAuthSessionToken = (token: string) => store.set(AuthKey, token)
|
||||
export const getAuthSessionToken = (): string | null => store.get(AuthKey)
|
||||
export const cleanAuthSessionToken = () => store.set(AuthKey, null)
|
||||
const BetterAuthKey = "betterAuthSessionCookie"
|
||||
export const setBetterAuthSessionCookie = (cookie: string) => store.set(BetterAuthKey, cookie)
|
||||
export const getBetterAuthSessionCookie = (): string | null => store.get(BetterAuthKey)
|
||||
export const cleanBetterAuthSessionCookie = () => store.set(BetterAuthKey, null)
|
||||
|
||||
const UserKey = "user"
|
||||
export const setUser = (user: User) => store.set(UserKey, JSON.stringify(user))
|
||||
@@ -24,11 +26,15 @@ export const updateNotificationsToken = async (newCredentials?: Credentials) =>
|
||||
}
|
||||
const credentials = newCredentials || store.get("notifications-credentials")
|
||||
if (credentials?.fcm?.token) {
|
||||
await apiClient.messaging.$post({
|
||||
json: {
|
||||
token: credentials.fcm.token,
|
||||
channel: "desktop",
|
||||
},
|
||||
})
|
||||
try {
|
||||
await apiClient.messaging.$post({
|
||||
json: {
|
||||
token: credentials.fcm.token,
|
||||
channel: "desktop",
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
logger.error("updateNotificationsToken error: ", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { fileURLToPath } from "node:url"
|
||||
|
||||
import { getRendererHandlers } from "@egoist/tipc/main"
|
||||
import { callWindowExpose } from "@follow/shared/bridge"
|
||||
import { app, BrowserWindow, clipboard, dialog, screen, shell } from "electron"
|
||||
import { app, BrowserWindow, clipboard, dialog, shell } from "electron"
|
||||
|
||||
import { registerMenuAndContextMenu } from "~/init"
|
||||
import { clearAllData, getCacheSize } from "~/lib/cleaner"
|
||||
@@ -15,10 +15,10 @@ import { registerAppTray } from "~/lib/tray"
|
||||
import { logger, revealLogFile } from "~/logger"
|
||||
import { cleanupOldRender, loadDynamicRenderEntry } from "~/updater/hot-updater"
|
||||
|
||||
import { isDev, isWindows11 } from "../env"
|
||||
import { isDev } from "../env"
|
||||
import { downloadFile } from "../lib/download"
|
||||
import { i18n } from "../lib/i18n"
|
||||
import { cleanAuthSessionToken, cleanUser } from "../lib/user"
|
||||
import { cleanBetterAuthSessionCookie, cleanUser } from "../lib/user"
|
||||
import type { RendererHandlers } from "../renderer-handlers"
|
||||
import { quitAndInstall } from "../updater"
|
||||
import { getMainWindow } from "../window"
|
||||
@@ -144,31 +144,13 @@ export const appRoute = {
|
||||
}
|
||||
}
|
||||
}),
|
||||
getWindowIsMaximized: t.procedure.input<void>().action(async ({ context }) => {
|
||||
const window: BrowserWindow | null = (context.sender as Sender).getOwnerBrowserWindow()
|
||||
|
||||
if (isWindows11 && window) {
|
||||
const size = screen.getDisplayMatching(window.getBounds()).workAreaSize
|
||||
|
||||
const windowSize = window.getSize()
|
||||
const windowPosition = window.getPosition()
|
||||
const isMaximized =
|
||||
windowSize[0] === size.width &&
|
||||
windowSize[1] === size.height &&
|
||||
windowPosition[0] === 0 &&
|
||||
windowPosition[1] === 0
|
||||
|
||||
return !!isMaximized
|
||||
}
|
||||
|
||||
return window?.isMaximized()
|
||||
}),
|
||||
quitAndInstall: t.procedure.action(async () => {
|
||||
quitAndInstall()
|
||||
}),
|
||||
|
||||
cleanAuthSessionToken: t.procedure.action(async () => {
|
||||
cleanAuthSessionToken()
|
||||
cleanBetterAuthSessionCookie: t.procedure.action(async () => {
|
||||
cleanBetterAuthSessionCookie()
|
||||
cleanUser()
|
||||
}),
|
||||
/// clipboard
|
||||
|
||||
@@ -51,27 +51,34 @@ export const readerRoute = {
|
||||
try {
|
||||
const voices = await tts.getVoices()
|
||||
return voices
|
||||
} catch (error: any) {
|
||||
if (!window) {
|
||||
} catch (error) {
|
||||
console.error("Failed to get voices", error)
|
||||
if (!window) return
|
||||
if (error instanceof Error) {
|
||||
void callWindowExpose(window).toast.error(error.message, { duration: 1000 })
|
||||
return
|
||||
}
|
||||
void callWindowExpose(window).toast.error(error.message, {
|
||||
duration: 1000,
|
||||
})
|
||||
callWindowExpose(window).toast.error("Failed to get voices", { duration: 1000 })
|
||||
}
|
||||
}),
|
||||
|
||||
setVoice: t.procedure.input<string>().action(async ({ input, context: { sender } }) => {
|
||||
const window = BrowserWindow.fromWebContents(sender)
|
||||
if (!window) {
|
||||
return
|
||||
}
|
||||
if (!window) return
|
||||
|
||||
await tts.setMetadata(input, OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS).catch((error) => {
|
||||
return callWindowExpose(window).toast.error(error.message, {
|
||||
duration: 1000,
|
||||
await tts
|
||||
.setMetadata(input, OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS)
|
||||
.catch((error: unknown) => {
|
||||
console.error("Failed to set voice", error)
|
||||
if (error instanceof Error) {
|
||||
return callWindowExpose(window).toast.error(error.message, {
|
||||
duration: 1000,
|
||||
})
|
||||
}
|
||||
return callWindowExpose(window).toast.error("Failed to set voice", {
|
||||
duration: 1000,
|
||||
})
|
||||
})
|
||||
})
|
||||
}),
|
||||
|
||||
detectCodeStringLanguage: t.procedure
|
||||
|
||||
@@ -8,7 +8,6 @@ export const appUpdaterConfig = {
|
||||
// Disable renderer hot update will trigger app update when available
|
||||
enableRenderHotUpdate: !isDev && isNightlyBuild,
|
||||
// Disable app update will also disable renderer hot update
|
||||
// enableAppUpdate: true,
|
||||
enableAppUpdate: !isDev,
|
||||
|
||||
app: {
|
||||
|
||||
+22
-1
@@ -3,7 +3,7 @@ import { fileURLToPath } from "node:url"
|
||||
|
||||
import { is } from "@electron-toolkit/utils"
|
||||
import { APP_PROTOCOL } from "@follow/shared"
|
||||
import { callWindowExpose } from "@follow/shared/bridge"
|
||||
import { callWindowExpose, WindowState } from "@follow/shared/bridge"
|
||||
import type { BrowserWindowConstructorOptions } from "electron"
|
||||
import { app, BrowserWindow, screen, shell } from "electron"
|
||||
import type { Event } from "electron/main"
|
||||
@@ -197,6 +197,27 @@ export function createWindow(
|
||||
})
|
||||
}
|
||||
|
||||
// async render and main state
|
||||
window.on("maximize", async () => {
|
||||
const caller = callWindowExpose(window)
|
||||
await caller.setWindowState(WindowState.MAXIMIZED)
|
||||
})
|
||||
|
||||
window.on("unmaximize", async () => {
|
||||
const caller = callWindowExpose(window)
|
||||
await caller.setWindowState(WindowState.NORMAL)
|
||||
})
|
||||
|
||||
window.on("minimize", async () => {
|
||||
const caller = callWindowExpose(window)
|
||||
await caller.setWindowState(WindowState.MINIMIZED)
|
||||
})
|
||||
|
||||
window.on("restore", async () => {
|
||||
const caller = callWindowExpose(window)
|
||||
await caller.setWindowState(WindowState.NORMAL)
|
||||
})
|
||||
|
||||
return window
|
||||
}
|
||||
export const windowStateStoreKey = "windowState"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Debug Proxy</title>
|
||||
<script type="module" src="./__debug_proxy.ts"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
@@ -1,95 +0,0 @@
|
||||
globalThis["__DEBUG_PROXY__"] = true
|
||||
|
||||
const searchParams = new URLSearchParams(window.location.search)
|
||||
const debugHost = searchParams.get("debug-host")
|
||||
|
||||
const resetSessionStorage = () => {
|
||||
sessionStorage.removeItem("debug-host")
|
||||
}
|
||||
|
||||
const resetParams = searchParams.get("reset")
|
||||
if (resetParams) {
|
||||
resetSessionStorage()
|
||||
}
|
||||
|
||||
const debugHostInSessionStorage = sessionStorage.getItem("debug-host")
|
||||
|
||||
const host = debugHost || debugHostInSessionStorage || "https://localhost:2233"
|
||||
if (debugHost) {
|
||||
sessionStorage.setItem("debug-host", debugHost)
|
||||
}
|
||||
|
||||
const createRefreshRuntimeScript = `
|
||||
import RefreshRuntime from "${host}/@react-refresh";
|
||||
RefreshRuntime.injectIntoGlobalHook(window);
|
||||
window.$RefreshReg$ = () => {};
|
||||
window.$RefreshSig$ = () => (type) => type;
|
||||
window.__vite_plugin_react_preamble_installed__ = true;
|
||||
`
|
||||
const $script = document.createElement("script")
|
||||
$script.innerHTML = createRefreshRuntimeScript
|
||||
$script.type = "module"
|
||||
document.head.append($script)
|
||||
|
||||
fetch(`${host}`)
|
||||
.then((res) => res.text())
|
||||
.then((html) => {
|
||||
const parser = new DOMParser()
|
||||
const doc = parser.parseFromString(html, "text/html")
|
||||
|
||||
const scripts = doc.querySelectorAll("script")
|
||||
|
||||
scripts.forEach((script) => {
|
||||
script.remove()
|
||||
})
|
||||
|
||||
// header meta
|
||||
|
||||
const $meta = doc.head.querySelectorAll("meta")
|
||||
$meta.forEach((meta) => {
|
||||
document.head.append(meta)
|
||||
})
|
||||
|
||||
const $style = doc.head.querySelectorAll("style")
|
||||
$style.forEach((style) => {
|
||||
document.head.append(style)
|
||||
})
|
||||
|
||||
document.body.innerHTML = doc.body.innerHTML
|
||||
|
||||
scripts.forEach((script) => {
|
||||
const $script = document.createElement("script")
|
||||
$script.type = "module"
|
||||
$script.crossOrigin = script.crossOrigin
|
||||
|
||||
if (script.src) {
|
||||
$script.src = new URL(
|
||||
script.src.startsWith("http") ? new URL(script.src).pathname : script.src,
|
||||
host,
|
||||
).toString()
|
||||
} else if (script.innerHTML) {
|
||||
$script.innerHTML = script.innerHTML
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
document.body.append($script)
|
||||
})
|
||||
})
|
||||
|
||||
const injectScript = (apiUrl: string) => {
|
||||
const upstreamOrigin = window.location.origin
|
||||
const template = `function injectEnv(env2) {
|
||||
for (const key in env2) {
|
||||
if (env2[key] === void 0) continue;
|
||||
globalThis["__followEnv"] ??= {};
|
||||
globalThis["__followEnv"][key] = env2[key];
|
||||
}
|
||||
}
|
||||
injectEnv({"VITE_API_URL":"${apiUrl}","VITE_EXTERNAL_API_URL":"${apiUrl}","VITE_WEB_URL":"${upstreamOrigin}"})`
|
||||
const $script = document.createElement("script")
|
||||
$script.innerHTML = template
|
||||
document.head.prepend($script)
|
||||
}
|
||||
|
||||
injectScript(import.meta.env.VITE_API_URL)
|
||||
@@ -0,0 +1,105 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Debug Proxy</title>
|
||||
|
||||
<script type="module">
|
||||
globalThis["__DEBUG_PROXY__"] = true
|
||||
|
||||
const searchParams = new URLSearchParams(window.location.search)
|
||||
const debugHost = searchParams.get("debug-host")
|
||||
|
||||
const resetSessionStorage = () => {
|
||||
sessionStorage.removeItem("debug-host")
|
||||
}
|
||||
|
||||
const resetParams = searchParams.get("reset")
|
||||
if (resetParams) {
|
||||
resetSessionStorage()
|
||||
}
|
||||
|
||||
const debugHostInSessionStorage = sessionStorage.getItem("debug-host")
|
||||
|
||||
const host = debugHost || debugHostInSessionStorage || "https://localhost:2233"
|
||||
if (debugHost) {
|
||||
sessionStorage.setItem("debug-host", debugHost)
|
||||
}
|
||||
|
||||
const createRefreshRuntimeScript = `
|
||||
import RefreshRuntime from "${host}/@react-refresh";
|
||||
RefreshRuntime.injectIntoGlobalHook(window);
|
||||
window.$RefreshReg$ = () => {};
|
||||
window.$RefreshSig$ = () => (type) => type;
|
||||
window.__vite_plugin_react_preamble_installed__ = true;
|
||||
`
|
||||
const $script = document.createElement("script")
|
||||
$script.innerHTML = createRefreshRuntimeScript
|
||||
$script.type = "module"
|
||||
document.head.append($script)
|
||||
|
||||
fetch(`${host}`)
|
||||
.then((res) => res.text())
|
||||
.then((html) => {
|
||||
const parser = new DOMParser()
|
||||
const doc = parser.parseFromString(html, "text/html")
|
||||
|
||||
const scripts = doc.querySelectorAll("script")
|
||||
|
||||
scripts.forEach((script) => {
|
||||
script.remove()
|
||||
})
|
||||
|
||||
// header meta
|
||||
|
||||
const $meta = doc.head.querySelectorAll("meta")
|
||||
$meta.forEach((meta) => {
|
||||
document.head.append(meta)
|
||||
})
|
||||
|
||||
const $style = doc.head.querySelectorAll("style")
|
||||
$style.forEach((style) => {
|
||||
document.head.append(style)
|
||||
})
|
||||
|
||||
document.body.innerHTML = doc.body.innerHTML
|
||||
|
||||
scripts.forEach((script) => {
|
||||
const $script = document.createElement("script")
|
||||
$script.type = "module"
|
||||
$script.crossOrigin = script.crossOrigin
|
||||
|
||||
if (script.src) {
|
||||
$script.src = new URL(
|
||||
script.src.startsWith("http") ? new URL(script.src).pathname : script.src,
|
||||
host,
|
||||
).toString()
|
||||
} else if (script.innerHTML) {
|
||||
$script.innerHTML = script.innerHTML
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
document.body.append($script)
|
||||
})
|
||||
})
|
||||
|
||||
const injectScript = (apiUrl) => {
|
||||
const upstreamOrigin = window.location.origin
|
||||
const template = `function injectEnv(env2) {
|
||||
for (const key in env2) {
|
||||
if (env2[key] === void 0) continue;
|
||||
globalThis["__followEnv"] ??= {};
|
||||
globalThis["__followEnv"][key] = env2[key];
|
||||
}
|
||||
}
|
||||
injectEnv({"VITE_API_URL":"${apiUrl}","VITE_EXTERNAL_API_URL":"${apiUrl}","VITE_WEB_URL":"${upstreamOrigin}"})`
|
||||
const $script = document.createElement("script")
|
||||
$script.innerHTML = template
|
||||
document.head.prepend($script)
|
||||
}
|
||||
|
||||
injectScript(import.meta.env.VITE_API_URL)
|
||||
</script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
Vendored
-2
@@ -1,5 +1,3 @@
|
||||
import "../../types/authjs"
|
||||
|
||||
import type { ElectronAPI } from "@electron-toolkit/preload"
|
||||
|
||||
declare global {
|
||||
|
||||
+16
-17
@@ -18,9 +18,8 @@
|
||||
"@follow/shared": "workspace:*",
|
||||
"@fontsource/sn-pro": "5.1.0",
|
||||
"@headlessui/react": "2.2.0",
|
||||
"@hono/auth-js": "1.0.15",
|
||||
"@hookform/resolvers": "3.9.1",
|
||||
"@lottiefiles/dotlottie-react": "0.10.0",
|
||||
"@lottiefiles/dotlottie-react": "0.10.1",
|
||||
"@microflash/remark-callout-directives": "4.3.2",
|
||||
"@openpanel/web": "1.0.1",
|
||||
"@radix-ui/react-avatar": "1.1.1",
|
||||
@@ -32,12 +31,13 @@
|
||||
"@radix-ui/react-popover": "1.1.2",
|
||||
"@radix-ui/react-slider": "^1.2.1",
|
||||
"@radix-ui/react-slot": "1.1.0",
|
||||
"@sentry/react": "8.40.0",
|
||||
"@shikijs/transformers": "1.23.1",
|
||||
"@tanstack/query-sync-storage-persister": "5.61.4",
|
||||
"@tanstack/react-query": "5.61.4",
|
||||
"@tanstack/react-query-devtools": "5.61.4",
|
||||
"@tanstack/react-query-persist-client": "5.61.4",
|
||||
"@sentry/react": "8.41.0",
|
||||
"@shikijs/transformers": "1.24.0",
|
||||
"@tanstack/query-sync-storage-persister": "5.62.0",
|
||||
"@tanstack/react-query": "5.62.0",
|
||||
"@tanstack/react-query-devtools": "5.62.0",
|
||||
"@tanstack/react-query-persist-client": "5.62.0",
|
||||
"@tanstack/react-virtual": "3.10.9",
|
||||
"@use-gesture/react": "10.3.1",
|
||||
"@welldone-software/why-did-you-render": "8.0.3",
|
||||
"@yornaath/batshit": "0.10.1",
|
||||
@@ -52,10 +52,10 @@
|
||||
"electron-log": "5.2.3",
|
||||
"embla-carousel-react": "8.5.1",
|
||||
"embla-carousel-wheel-gestures": "8.0.1",
|
||||
"es-toolkit": "catalog:",
|
||||
"es-toolkit": "1.29.0",
|
||||
"firebase": "11.0.2",
|
||||
"foxact": "0.2.42",
|
||||
"framer-motion": "11.11.17",
|
||||
"framer-motion": "11.12.0",
|
||||
"franc-min": "6.2.0",
|
||||
"fuse.js": "7.0.0",
|
||||
"hast-util-to-jsx-runtime": "2.3.2",
|
||||
@@ -81,14 +81,13 @@
|
||||
"react-fast-marquee": "1.6.5",
|
||||
"react-hook-form": "7.53.2",
|
||||
"react-hotkeys-hook": "4.6.1",
|
||||
"react-i18next": "^15.1.2",
|
||||
"react-i18next": "^15.1.3",
|
||||
"react-intersection-observer": "9.13.1",
|
||||
"react-ios-pwa-prompt": "^2.0.6",
|
||||
"react-resizable-layout": "npm:@innei/react-resizable-layout@0.7.3-fork.1",
|
||||
"react-router": "7.0.1",
|
||||
"react-selecto": "^1.26.3",
|
||||
"react-shadow": "20.5.0",
|
||||
"react-virtuoso": "4.12.2",
|
||||
"react-zoom-pan-pinch": "^3.6.1",
|
||||
"rehype-infer-description-meta": "2.0.0",
|
||||
"rehype-parse": "9.0.1",
|
||||
@@ -99,9 +98,9 @@
|
||||
"remark-gh-alerts": "0.0.3",
|
||||
"remark-parse": "11.0.0",
|
||||
"remark-rehype": "11.1.1",
|
||||
"shiki": "1.23.1",
|
||||
"shiki": "1.24.0",
|
||||
"sonner": "1.7.0",
|
||||
"tldts": "6.1.64",
|
||||
"tldts": "6.1.65",
|
||||
"unified": "11.0.5",
|
||||
"unist-util-visit-parents": "^6.0.1",
|
||||
"use-context-selector": "2.0.0",
|
||||
@@ -126,14 +125,14 @@
|
||||
"@follow/utils": "workspace:*",
|
||||
"@hono/node-server": "1.13.7",
|
||||
"@types/katex": "0.16.7",
|
||||
"@types/node": "^22.10.0",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vite-pwa/assets-generator": "^0.2.6",
|
||||
"fake-indexeddb": "6.0.0",
|
||||
"happy-dom": "15.11.6",
|
||||
"happy-dom": "15.11.7",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-scan": "0.0.33"
|
||||
"react-scan": "0.0.35"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,14 @@ import camelcaseKeys from "camelcase-keys"
|
||||
import { apiFetch } from "~/lib/api-fetch"
|
||||
|
||||
const v1ApiPrefix = "/v1"
|
||||
export const getTrendingAggregates = async () => {
|
||||
const data = await apiFetch<Models.TrendingAggregates>(`${v1ApiPrefix}/trendings`)
|
||||
export const getTrendingAggregates = async (params: { language: string }) => {
|
||||
const data = await apiFetch<Models.TrendingAggregates>(
|
||||
`${v1ApiPrefix}/trendings?language=${params.language}`,
|
||||
{
|
||||
params: {
|
||||
language: params.language,
|
||||
},
|
||||
},
|
||||
)
|
||||
return camelcaseKeys(data as any, { deep: true }) as Models.TrendingAggregates
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { WindowState } from "@follow/shared/bridge"
|
||||
import { atom } from "jotai"
|
||||
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
@@ -5,3 +6,8 @@ import { createAtomHooks } from "~/lib/jotai"
|
||||
export const [, , useAppIsReady, , appIsReady, setAppIsReady] = createAtomHooks(atom(false))
|
||||
|
||||
export const [, , useAppSearchOpen, , , setAppSearchOpen] = createAtomHooks(atom(false))
|
||||
|
||||
// For electron
|
||||
export const [, , useWindowState, , windowState, setWindowState] = createAtomHooks(
|
||||
atom<WindowState>(WindowState.NORMAL),
|
||||
)
|
||||
|
||||
@@ -80,8 +80,12 @@ export const AudioPlayer = {
|
||||
show: true,
|
||||
listId: routeParams.listId,
|
||||
})
|
||||
const currentUrl = URL.canParse(this.audio.src)
|
||||
? new URL(this.audio.src).toString()
|
||||
: this.audio.src
|
||||
const newUrl = URL.canParse(v.src) ? new URL(v.src).toString() : v.src
|
||||
|
||||
if (this.audio.src !== v.src) {
|
||||
if (currentUrl !== newUrl) {
|
||||
this.audio.src = v.src
|
||||
this.audio.currentTime = v.currentTime ?? curV.currentTime ?? 0
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ const createDefaultSettings = (): GeneralSettings => ({
|
||||
dataPersist: true,
|
||||
sendAnonymousData: true,
|
||||
reduceRefetch: true,
|
||||
showQuickTimeline: true,
|
||||
|
||||
autoGroup: true,
|
||||
|
||||
|
||||
@@ -14,11 +14,6 @@ export const createDefaultSettings = (): IntegrationSettings => ({
|
||||
instapaperUsername: "",
|
||||
instapaperPassword: "",
|
||||
|
||||
// omnivore
|
||||
enableOmnivore: false,
|
||||
omnivoreEndpoint: "",
|
||||
omnivoreToken: "",
|
||||
|
||||
// obsidian
|
||||
enableObsidian: false,
|
||||
obsidianVaultPath: "",
|
||||
@@ -28,6 +23,11 @@ export const createDefaultSettings = (): IntegrationSettings => ({
|
||||
outlineEndpoint: "",
|
||||
outlineToken: "",
|
||||
outlineCollection: "",
|
||||
|
||||
// readeck
|
||||
enableReadeck: false,
|
||||
readeckEndpoint: "",
|
||||
readeckToken: "",
|
||||
})
|
||||
|
||||
export const {
|
||||
|
||||
@@ -60,7 +60,7 @@ export const uiServerSyncWhiteListKeys: (keyof UISettings)[] = [
|
||||
"uiFontFamily",
|
||||
"readerFontFamily",
|
||||
"opaqueSidebar",
|
||||
"customCSS",
|
||||
// "customCSS",
|
||||
]
|
||||
|
||||
export const useIsZenMode = () => useAtomValue(zenModeAtom)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { User } from "@auth/core/types"
|
||||
import type { UserRole } from "@follow/constants"
|
||||
import type { AuthSession } from "@follow/shared/hono"
|
||||
import { atom } from "jotai"
|
||||
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
|
||||
export const [, , useWhoami, , whoami, setWhoami] = createAtomHooks(atom<Nullable<User>>(null))
|
||||
export const [, , useWhoami, , whoami, setWhoami] = createAtomHooks(
|
||||
atom<Nullable<NonNullable<AuthSession>["user"]>>(null),
|
||||
)
|
||||
|
||||
export const [, , useLoginModalShow, useSetLoginModalShow, getLoginModalShow, setLoginModalShow] =
|
||||
createAtomHooks(atom<boolean>(false))
|
||||
|
||||
@@ -42,9 +42,6 @@ export function ReloadPrompt() {
|
||||
// }, [offlineReady, close])
|
||||
|
||||
useEffect(() => {
|
||||
const isPwa = window.matchMedia("(display-mode: standalone)").matches
|
||||
if (!isPwa) return
|
||||
|
||||
if (needRefresh) {
|
||||
toast.info("New version available", {
|
||||
action: {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
@apply mr-5;
|
||||
}
|
||||
|
||||
/* 撑开没有内容的行 */
|
||||
/* Expand the row without content */
|
||||
&::after {
|
||||
content: " ";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { DragEvent, ReactNode } from "react"
|
||||
import { useCallback, useRef, useState } from "react"
|
||||
|
||||
// Ported from https://github.com/react-dropzone/react-dropzone/issues/753#issuecomment-774782919
|
||||
const useDragAndDrop = ({ callback }: { callback: (file: FileList) => void | Promise<void> }) => {
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
const dragCounter = useRef(0)
|
||||
|
||||
const onDrop = useCallback(
|
||||
async (event: DragEvent<HTMLLabelElement>) => {
|
||||
event.preventDefault()
|
||||
setIsDragging(false)
|
||||
if (event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length > 0) {
|
||||
dragCounter.current = 0
|
||||
await callback(event.dataTransfer.files)
|
||||
event.dataTransfer.clearData()
|
||||
}
|
||||
},
|
||||
[callback],
|
||||
)
|
||||
|
||||
const onDragEnter = useCallback((event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
dragCounter.current++
|
||||
setIsDragging(true)
|
||||
}, [])
|
||||
|
||||
const onDragOver = useCallback((event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
}, [])
|
||||
|
||||
const onDragLeave = useCallback((event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
dragCounter.current--
|
||||
if (dragCounter.current > 0) return
|
||||
setIsDragging(false)
|
||||
}, [])
|
||||
|
||||
return {
|
||||
isDragging,
|
||||
|
||||
dragHandlers: {
|
||||
onDrop,
|
||||
onDragOver,
|
||||
onDragEnter,
|
||||
onDragLeave,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const DropZone = ({
|
||||
onDrop,
|
||||
children,
|
||||
}: {
|
||||
onDrop: (file: FileList) => void | Promise<void>
|
||||
children?: ReactNode
|
||||
}) => {
|
||||
const { isDragging, dragHandlers } = useDragAndDrop({ callback: onDrop })
|
||||
|
||||
return (
|
||||
<label
|
||||
className={`center flex h-[100px] w-full rounded-md border border-dashed ${
|
||||
isDragging ? "border-blue-500 bg-blue-100" : ""
|
||||
}`}
|
||||
htmlFor="upload-file"
|
||||
{...dragHandlers}
|
||||
>
|
||||
{children}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
@@ -22,6 +22,8 @@ type BaseProps = {
|
||||
inline?: boolean
|
||||
fitContent?: boolean
|
||||
}
|
||||
|
||||
const isImageLoadedSet = new Set<string>()
|
||||
export type MediaProps = BaseProps &
|
||||
(
|
||||
| (ImgHTMLAttributes<HTMLImageElement> & {
|
||||
@@ -103,7 +105,12 @@ const MediaImpl: FC<MediaProps> = ({
|
||||
[currentState, previewImageUrl, proxy?.width, proxy?.height],
|
||||
)
|
||||
|
||||
const [mediaLoadState, setMediaLoadState] = useState<"loading" | "loaded">("loading")
|
||||
const [mediaLoadState, setMediaLoadState] = useState<"loading" | "loaded">(() => {
|
||||
if (imgSrc) {
|
||||
return isImageLoadedSet.has(imgSrc) ? "loaded" : "loading"
|
||||
}
|
||||
return "loading"
|
||||
})
|
||||
|
||||
const errorHandle: React.ReactEventHandler<HTMLImageElement> = useEventCallback(() => {
|
||||
switch (currentState) {
|
||||
@@ -158,6 +165,10 @@ const MediaImpl: FC<MediaProps> = ({
|
||||
const handleOnLoad: React.ReactEventHandler<HTMLImageElement> = useEventCallback((e) => {
|
||||
setMediaLoadState("loaded")
|
||||
rest.onLoad?.(e as any)
|
||||
|
||||
if (imgSrc) {
|
||||
isImageLoadedSet.add(imgSrc)
|
||||
}
|
||||
if ("cacheDimensions" in props && props.cacheDimensions && src) {
|
||||
saveImageDimensionsToDb(src, {
|
||||
src,
|
||||
@@ -246,7 +257,11 @@ const MediaImpl: FC<MediaProps> = ({
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<div className={cn("relative rounded", className)} style={props.style}>
|
||||
<div
|
||||
className={cn("relative rounded", className)}
|
||||
data-state={mediaLoadState}
|
||||
style={props.style}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"relative inline-block max-w-full bg-theme-placeholder-image",
|
||||
|
||||
@@ -28,7 +28,7 @@ export function SwipeMedia({
|
||||
height: number
|
||||
}
|
||||
}) {
|
||||
const uniqMedia = uniqBy(media, "url")
|
||||
const uniqMedia = media ? uniqBy(media, "url") : []
|
||||
|
||||
const hoverRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
|
||||
@@ -23,50 +23,52 @@ export const useModalStack = (options?: ModalStackOptions) => {
|
||||
const currentCount = useRef(0)
|
||||
const { wrapper } = options || {}
|
||||
|
||||
const presentSync = (props: ModalProps & { id?: string }) => {
|
||||
const fallbackModelId = `${id}-${++currentCount.current}`
|
||||
const modalId = props.id ?? fallbackModelId
|
||||
|
||||
const currentStack = jotaiStore.get(modalStackAtom)
|
||||
|
||||
const existingModal = currentStack.find((item) => item.id === modalId)
|
||||
if (existingModal) {
|
||||
// Move to top
|
||||
jotaiStore.set(modalStackAtom, (p) => {
|
||||
const index = p.indexOf(existingModal)
|
||||
return [...p.slice(0, index), ...p.slice(index + 1), existingModal]
|
||||
})
|
||||
} else {
|
||||
// NOTE: The props of the Command Modal are immutable, so we'll just take the store value and inject it.
|
||||
// There is no need to inject `overlay` props, this is rendered responsively based on ui changes.
|
||||
const uiSettings = getUISettings()
|
||||
const modalConfig: Partial<ModalProps> = {
|
||||
draggable: uiSettings.modalDraggable,
|
||||
modal: true,
|
||||
}
|
||||
jotaiStore.set(modalStackAtom, (p) => {
|
||||
const modalProps: ModalProps = {
|
||||
...modalConfig,
|
||||
...props,
|
||||
|
||||
wrapper,
|
||||
}
|
||||
modalIdToPropsMap[modalId] = modalProps
|
||||
return p.concat({
|
||||
id: modalId,
|
||||
...modalProps,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return () => {
|
||||
jotaiStore.set(modalStackAtom, (p) => p.filter((item) => item.id !== modalId))
|
||||
}
|
||||
}
|
||||
return {
|
||||
present: useEventCallback((props: ModalProps & { id?: string }) =>
|
||||
nextFrame(() => presentSync(props)),
|
||||
),
|
||||
present: useEventCallback((props: ModalProps & { id?: string }) => {
|
||||
const presentSync = (props: ModalProps & { id?: string }) => {
|
||||
const fallbackModelId = `${id}-${++currentCount.current}`
|
||||
const modalId = props.id ?? fallbackModelId
|
||||
|
||||
const currentStack = jotaiStore.get(modalStackAtom)
|
||||
|
||||
const existingModal = currentStack.find((item) => item.id === modalId)
|
||||
|
||||
if (existingModal) {
|
||||
// Move to top
|
||||
jotaiStore.set(modalStackAtom, (p) => {
|
||||
const index = p.indexOf(existingModal)
|
||||
return [...p.slice(0, index), ...p.slice(index + 1), existingModal]
|
||||
})
|
||||
} else {
|
||||
// NOTE: The props of the Command Modal are immutable, so we'll just take the store value and inject it.
|
||||
// There is no need to inject `overlay` props, this is rendered responsively based on ui changes.
|
||||
const uiSettings = getUISettings()
|
||||
const modalConfig: Partial<ModalProps> = {
|
||||
draggable: uiSettings.modalDraggable,
|
||||
modal: true,
|
||||
}
|
||||
jotaiStore.set(modalStackAtom, (p) => {
|
||||
const modalProps: ModalProps = {
|
||||
...modalConfig,
|
||||
...props,
|
||||
|
||||
wrapper,
|
||||
}
|
||||
modalIdToPropsMap[modalId] = modalProps
|
||||
return p.concat({
|
||||
id: modalId,
|
||||
...modalProps,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return () => {
|
||||
jotaiStore.set(modalStackAtom, (p) => p.filter((item) => item.id !== modalId))
|
||||
}
|
||||
}
|
||||
|
||||
return nextFrame(() => presentSync(props))
|
||||
}),
|
||||
|
||||
...actions,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import { useAnimationControls } from "framer-motion"
|
||||
import { useCallback, useEffect } from "react"
|
||||
import { useCallback, useEffect, useLayoutEffect } from "react"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { modalMontionConfig } from "../constants"
|
||||
|
||||
@@ -30,7 +31,7 @@ export const useModalAnimate = (isTop: boolean) => {
|
||||
})
|
||||
}, [animateController])
|
||||
|
||||
useEffect(() => {
|
||||
useLayoutEffect(() => {
|
||||
if (isTop) return
|
||||
animateController.start({
|
||||
scale: 0.96,
|
||||
@@ -52,5 +53,8 @@ export const useModalAnimate = (isTop: boolean) => {
|
||||
return {
|
||||
noticeModal,
|
||||
animateController,
|
||||
dismissing: useEventCallback(async () => {
|
||||
await animateController.start(modalMontionConfig.exit)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,9 @@ const ModalToSheet = (props: ModalProps & { index: number; id: string }) => {
|
||||
const ModalProps: ModalActionsInternal = useMemo(
|
||||
() => ({
|
||||
dismiss: () => {
|
||||
sheetRef.current?.dismiss()
|
||||
close()
|
||||
sheetRef.current?.dismiss().then(() => {
|
||||
close()
|
||||
})
|
||||
},
|
||||
getIndex: () => props.index,
|
||||
setClickOutSideToDismiss: (v) => {
|
||||
@@ -74,7 +75,7 @@ const ModalToSheet = (props: ModalProps & { index: number; id: string }) => {
|
||||
)
|
||||
},
|
||||
}),
|
||||
[id, props.index, setStack],
|
||||
[close, id, props.index, setStack],
|
||||
)
|
||||
const modalContentRef = useRef<HTMLDivElement>(null)
|
||||
const ModalContextProps = useMemo<CurrentModalContentProps>(
|
||||
|
||||
@@ -86,13 +86,22 @@ export const ModalInternal = memo(
|
||||
const setStack = useSetAtom(modalStackAtom)
|
||||
|
||||
const [currentIsClosing, setCurrentIsClosing] = useState(false)
|
||||
const { noticeModal, animateController, dismissing } = useModalAnimate(!!isTop)
|
||||
|
||||
const close = useEventCallback((forceClose = false) => {
|
||||
if (!canClose && !forceClose) return
|
||||
setCurrentIsClosing(true)
|
||||
nextFrame(() => {
|
||||
setStack((p) => p.filter((modal) => modal.id !== item.id))
|
||||
})
|
||||
|
||||
if (!CustomModalComponent) {
|
||||
dismissing().then(() => {
|
||||
setStack((p) => p.filter((modal) => modal.id !== item.id))
|
||||
setCurrentIsClosing(false)
|
||||
})
|
||||
} else {
|
||||
nextFrame(() => {
|
||||
setStack((p) => p.filter((modal) => modal.id !== item.id))
|
||||
})
|
||||
}
|
||||
onPropsClose?.(false)
|
||||
})
|
||||
|
||||
@@ -133,8 +142,6 @@ export const ModalInternal = memo(
|
||||
draggable,
|
||||
})
|
||||
|
||||
const { noticeModal, animateController } = useModalAnimate(!!isTop)
|
||||
|
||||
const getIndex = useEventCallback(() => index)
|
||||
const [modalContentRef, setModalContentRef] = useState<HTMLDivElement | null>(null)
|
||||
const ModalProps: ModalActionsInternal = useMemo(
|
||||
@@ -298,6 +305,7 @@ export const ModalInternal = memo(
|
||||
>
|
||||
<div
|
||||
ref={setEdgeElementRef}
|
||||
onContextMenu={preventDefault}
|
||||
className={cn(
|
||||
"fixed flex",
|
||||
modal ? "inset-0 overflow-auto" : "left-0 top-0",
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ModalOverlay = forwardRef(
|
||||
},
|
||||
ref: ForwardedRef<HTMLDivElement>,
|
||||
) => (
|
||||
<Dialog.Overlay asChild>
|
||||
<Dialog.Overlay>
|
||||
<AnimatePresence>
|
||||
{!hidden && (
|
||||
<m.div
|
||||
|
||||
@@ -103,12 +103,12 @@ export function PullToRefresh({
|
||||
isRefreshing,
|
||||
])
|
||||
|
||||
// 计算实际的下拉距离
|
||||
// Calculate the actual pull-down distance
|
||||
const actualPullDistance = isRefreshing
|
||||
? THRESHOLD // 刷新时保持在阈值位置
|
||||
? THRESHOLD // Stay at threshold position when refreshing
|
||||
: pullDistance
|
||||
|
||||
// 计算下拉进度 (0-1)
|
||||
// Calculate the pull-down progress (0-1)
|
||||
const pullProgress = Math.max(Math.min(pullDistance / THRESHOLD - 0.2, 1), 0)
|
||||
const SIZE = 24
|
||||
const STROKE_WIDTH = 2
|
||||
|
||||
@@ -104,10 +104,6 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee
|
||||
id: COMMAND_ID.integration.saveToInstapaper,
|
||||
onClick: runCmdFn(COMMAND_ID.integration.saveToInstapaper, [{ entryId }]),
|
||||
},
|
||||
{
|
||||
id: COMMAND_ID.integration.saveToOmnivore,
|
||||
onClick: runCmdFn(COMMAND_ID.integration.saveToOmnivore, [{ entryId }]),
|
||||
},
|
||||
{
|
||||
id: COMMAND_ID.integration.saveToObsidian,
|
||||
onClick: runCmdFn(COMMAND_ID.integration.saveToObsidian, [{ entryId }]),
|
||||
@@ -116,6 +112,10 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee
|
||||
id: COMMAND_ID.integration.saveToOutline,
|
||||
onClick: runCmdFn(COMMAND_ID.integration.saveToOutline, [{ entryId }]),
|
||||
},
|
||||
{
|
||||
id: COMMAND_ID.integration.saveToReadeck,
|
||||
onClick: runCmdFn(COMMAND_ID.integration.saveToReadeck, [{ entryId }]),
|
||||
},
|
||||
{
|
||||
id: COMMAND_ID.entry.tip,
|
||||
onClick: runCmdFn(COMMAND_ID.entry.tip, [{ entryId, feedId: feed?.id }]),
|
||||
|
||||
@@ -1,438 +0,0 @@
|
||||
import {
|
||||
SimpleIconsEagle,
|
||||
SimpleIconsInstapaper,
|
||||
SimpleIconsObsidian,
|
||||
SimpleIconsOmnivore,
|
||||
SimpleIconsOutline,
|
||||
SimpleIconsReadwise,
|
||||
} from "@follow/components/ui/platform-icon/icons.js"
|
||||
import type { CombinedEntryModel } from "@follow/models/types"
|
||||
import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
import { useMutation, useQuery } from "@tanstack/react-query"
|
||||
import type { FetchError } from "ofetch"
|
||||
import { ofetch } from "ofetch"
|
||||
import type { ReactNode } from "react"
|
||||
import { useMemo } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { getReadabilityContent, getReadabilityStatus, ReadabilityStatus } from "~/atoms/readability"
|
||||
import { useIntegrationSettingValue } from "~/atoms/settings/integration"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
import { parseHtml } from "~/lib/parse-html"
|
||||
import type { FlatEntryModel } from "~/store/entry"
|
||||
import { getFeedById, useFeedById } from "~/store/feed"
|
||||
import { useInboxById } from "~/store/inbox"
|
||||
|
||||
export const useIntegrationActions = ({
|
||||
view,
|
||||
entry,
|
||||
}: {
|
||||
view?: number
|
||||
entry?: FlatEntryModel | null
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const feed = useFeedById(entry?.feedId, (feed) => {
|
||||
return {
|
||||
type: feed.type,
|
||||
ownerUserId: feed.ownerUserId,
|
||||
id: feed.id,
|
||||
}
|
||||
})
|
||||
|
||||
const inbox = useInboxById(entry?.inboxId)
|
||||
|
||||
const populatedEntry = useMemo(() => {
|
||||
if (!entry) return null
|
||||
if (!feed?.id && !inbox?.id) return null
|
||||
|
||||
return {
|
||||
...entry,
|
||||
feeds: feed ? getFeedById(feed.id) : undefined,
|
||||
inboxes: inbox,
|
||||
} as CombinedEntryModel
|
||||
}, [entry, feed, inbox])
|
||||
|
||||
const {
|
||||
enableEagle,
|
||||
enableReadwise,
|
||||
enableInstapaper,
|
||||
enableOmnivore,
|
||||
enableObsidian,
|
||||
enableOutline,
|
||||
readwiseToken,
|
||||
instapaperUsername,
|
||||
instapaperPassword,
|
||||
omnivoreToken,
|
||||
omnivoreEndpoint,
|
||||
obsidianVaultPath,
|
||||
outlineToken,
|
||||
outlineEndpoint,
|
||||
outlineCollection,
|
||||
} = useIntegrationSettingValue()
|
||||
const isObsidianEnabled = enableObsidian && !!obsidianVaultPath
|
||||
|
||||
const saveToObsidian = useMutation({
|
||||
mutationKey: ["save-to-obsidian"],
|
||||
mutationFn: async (data: {
|
||||
url: string
|
||||
title: string
|
||||
content: string
|
||||
author: string
|
||||
publishedAt: string
|
||||
vaultPath: string
|
||||
}) => {
|
||||
return await tipcClient?.saveToObsidian(data)
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
if (data?.success) {
|
||||
toast.success(t("entry_actions.saved_to_obsidian"), {
|
||||
duration: 3000,
|
||||
})
|
||||
} else {
|
||||
toast.error(`${t("entry_actions.failed_to_save_to_obsidian")}: ${data?.error}`, {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const checkEagle = useQuery({
|
||||
queryKey: ["check-eagle"],
|
||||
enabled: ELECTRON && enableEagle && !!entry?.entries.url && view !== undefined,
|
||||
queryFn: async () => {
|
||||
try {
|
||||
await ofetch("http://localhost:41595")
|
||||
return true
|
||||
} catch (error: unknown) {
|
||||
return (error as FetchError).data?.code === 401
|
||||
}
|
||||
},
|
||||
refetchOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
})
|
||||
|
||||
const items = useMemo(() => {
|
||||
if (!populatedEntry || view === undefined) return []
|
||||
|
||||
const getEntryContentAsMarkdown = async () => {
|
||||
const isReadabilityReady =
|
||||
getReadabilityStatus()[populatedEntry.entries.id] === ReadabilityStatus.SUCCESS
|
||||
const content =
|
||||
(isReadabilityReady
|
||||
? getReadabilityContent()[populatedEntry.entries.id].content
|
||||
: populatedEntry.entries.content) || ""
|
||||
|
||||
const [toMarkdown, toMdast, gfmTableToMarkdown] = await Promise.all([
|
||||
import("mdast-util-to-markdown").then((m) => m.toMarkdown),
|
||||
import("hast-util-to-mdast").then((m) => m.toMdast),
|
||||
import("mdast-util-gfm-table").then((m) => m.gfmTableToMarkdown),
|
||||
])
|
||||
|
||||
return toMarkdown(toMdast(parseHtml(content).hastTree), {
|
||||
extensions: [gfmTableToMarkdown()],
|
||||
})
|
||||
}
|
||||
|
||||
const items: {
|
||||
key: string
|
||||
className?: string
|
||||
shortcut?: string
|
||||
name: string
|
||||
icon?: ReactNode
|
||||
hide?: boolean
|
||||
active?: boolean
|
||||
disabled?: boolean
|
||||
onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void
|
||||
}[] = [
|
||||
{
|
||||
name: t("entry_actions.save_media_to_eagle"),
|
||||
icon: <SimpleIconsEagle />,
|
||||
key: "saveToEagle",
|
||||
hide:
|
||||
!enableEagle ||
|
||||
(checkEagle.isLoading ? true : !checkEagle.data) ||
|
||||
!populatedEntry.entries.media?.length,
|
||||
onClick: async () => {
|
||||
if (!populatedEntry.entries.url || !populatedEntry.entries.media?.length) {
|
||||
return
|
||||
}
|
||||
window.analytics?.capture("integration", {
|
||||
type: "eagle",
|
||||
event: "save",
|
||||
})
|
||||
const response = await tipcClient?.saveToEagle({
|
||||
url: populatedEntry.entries.url,
|
||||
mediaUrls: populatedEntry.entries.media.map((m) => m.url),
|
||||
})
|
||||
|
||||
if (response?.status === "success") {
|
||||
toast.success(t("entry_actions.saved_to_eagle"), {
|
||||
duration: 3000,
|
||||
})
|
||||
} else {
|
||||
toast.error(t("entry_actions.failed_to_save_to_eagle"), {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: t("entry_actions.save_to_readwise"),
|
||||
icon: <SimpleIconsReadwise />,
|
||||
key: "saveToReadwise",
|
||||
hide: !enableReadwise || !readwiseToken || !populatedEntry.entries.url,
|
||||
onClick: async () => {
|
||||
try {
|
||||
window.analytics?.capture("integration", {
|
||||
type: "readwise",
|
||||
event: "save",
|
||||
})
|
||||
const data = await ofetch("https://readwise.io/api/v3/save/", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Token ${readwiseToken}`,
|
||||
},
|
||||
body: {
|
||||
url: populatedEntry.entries.url,
|
||||
html: populatedEntry.entries.content || undefined,
|
||||
title: populatedEntry.entries.title || undefined,
|
||||
author: populatedEntry.entries.author || undefined,
|
||||
summary: populatedEntry.entries.description || undefined,
|
||||
published_date: populatedEntry.entries.publishedAt || undefined,
|
||||
image_url: populatedEntry.entries.media?.[0]?.url || undefined,
|
||||
saved_using: "Follow",
|
||||
},
|
||||
})
|
||||
|
||||
toast.success(
|
||||
<>
|
||||
{t("entry_actions.saved_to_readwise")},{" "}
|
||||
<a target="_blank" className="underline" href={data.url}>
|
||||
view
|
||||
</a>
|
||||
</>,
|
||||
{
|
||||
duration: 3000,
|
||||
},
|
||||
)
|
||||
} catch {
|
||||
toast.error(t("entry_actions.failed_to_save_to_readwise"), {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: t("entry_actions.save_to_instapaper"),
|
||||
icon: <SimpleIconsInstapaper />,
|
||||
key: "saveToInstapaper",
|
||||
hide:
|
||||
!enableInstapaper ||
|
||||
!instapaperPassword ||
|
||||
!instapaperUsername ||
|
||||
!populatedEntry.entries.url,
|
||||
onClick: async () => {
|
||||
try {
|
||||
window.analytics?.capture("integration", {
|
||||
type: "instapaper",
|
||||
event: "save",
|
||||
})
|
||||
const data = await ofetch("https://www.instapaper.com/api/add", {
|
||||
query: {
|
||||
url: populatedEntry.entries.url,
|
||||
title: populatedEntry.entries.title,
|
||||
},
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Basic ${btoa(`${instapaperUsername}:${instapaperPassword}`)}`,
|
||||
},
|
||||
parseResponse: JSON.parse,
|
||||
})
|
||||
|
||||
toast.success(
|
||||
<>
|
||||
{t("entry_actions.saved_to_instapaper")},{" "}
|
||||
<a
|
||||
target="_blank"
|
||||
className="underline"
|
||||
href={`https://www.instapaper.com/read/${data.bookmark_id}`}
|
||||
>
|
||||
view
|
||||
</a>
|
||||
</>,
|
||||
{
|
||||
duration: 3000,
|
||||
},
|
||||
)
|
||||
} catch {
|
||||
toast.error(t("entry_actions.failed_to_save_to_instapaper"), {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: t("entry_actions.save_to_omnivore"),
|
||||
icon: <SimpleIconsOmnivore />,
|
||||
key: "saveToomnivore",
|
||||
hide: !enableOmnivore || !omnivoreToken || !omnivoreEndpoint || !populatedEntry.entries.url,
|
||||
onClick: async () => {
|
||||
const saveUrlQuery = `
|
||||
mutation SaveUrl($input: SaveUrlInput!) {
|
||||
saveUrl(input: $input) {
|
||||
... on SaveSuccess {
|
||||
url
|
||||
clientRequestId
|
||||
}
|
||||
... on SaveError {
|
||||
errorCodes
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
window.analytics?.capture("integration", {
|
||||
type: "omnivore",
|
||||
event: "save",
|
||||
})
|
||||
try {
|
||||
const data = await ofetch(omnivoreEndpoint, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: omnivoreToken,
|
||||
},
|
||||
body: {
|
||||
query: saveUrlQuery,
|
||||
variables: {
|
||||
input: {
|
||||
url: populatedEntry.entries.url,
|
||||
source: "Follow",
|
||||
clientRequestId: globalThis.crypto.randomUUID(),
|
||||
publishedAt: new Date(populatedEntry.entries.publishedAt),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
toast.success(
|
||||
<>
|
||||
{t("entry_actions.saved_to_omnivore")},{" "}
|
||||
<a target="_blank" className="underline" href={data.data.saveUrl.url}>
|
||||
view
|
||||
</a>
|
||||
</>,
|
||||
{
|
||||
duration: 3000,
|
||||
},
|
||||
)
|
||||
} catch {
|
||||
toast.error(t("entry_actions.failed_to_save_to_omnivore"), {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: t("entry_actions.save_to_obsidian"),
|
||||
icon: <SimpleIconsObsidian />,
|
||||
key: "saveToObsidian",
|
||||
hide: !isObsidianEnabled || !populatedEntry?.entries?.url || !IN_ELECTRON,
|
||||
onClick: async () => {
|
||||
if (!isObsidianEnabled || !populatedEntry?.entries?.url || !IN_ELECTRON) return
|
||||
|
||||
const markdownContent = await getEntryContentAsMarkdown()
|
||||
window.analytics?.capture("integration", {
|
||||
type: "obsidian",
|
||||
event: "save",
|
||||
})
|
||||
saveToObsidian.mutate({
|
||||
url: populatedEntry.entries.url,
|
||||
title: populatedEntry.entries.title || "",
|
||||
content: markdownContent,
|
||||
author: populatedEntry.entries.author || "",
|
||||
publishedAt: populatedEntry.entries.publishedAt || "",
|
||||
vaultPath: obsidianVaultPath,
|
||||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: t("entry_actions.save_to_outline"),
|
||||
icon: <SimpleIconsOutline />,
|
||||
key: "saveToOutline",
|
||||
hide:
|
||||
!IN_ELECTRON ||
|
||||
!enableOutline ||
|
||||
!outlineToken ||
|
||||
!outlineEndpoint ||
|
||||
!outlineCollection ||
|
||||
!populatedEntry.entries.title,
|
||||
onClick: async () => {
|
||||
try {
|
||||
const request = async (method: string, params: Record<string, unknown>) => {
|
||||
return await ofetch(`${outlineEndpoint.replace(/\/$/, "")}/${method}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${outlineToken}`,
|
||||
},
|
||||
body: params,
|
||||
})
|
||||
}
|
||||
let collectionId = outlineCollection
|
||||
if (!/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i.test(collectionId)) {
|
||||
const collection = await request("collections.info", {
|
||||
id: collectionId,
|
||||
})
|
||||
collectionId = collection.data.id
|
||||
}
|
||||
const markdownContent = await getEntryContentAsMarkdown()
|
||||
await request("documents.create", {
|
||||
title: populatedEntry.entries.title,
|
||||
text: markdownContent,
|
||||
collectionId,
|
||||
publish: true,
|
||||
})
|
||||
toast.success(t("entry_actions.saved_to_outline"), {
|
||||
duration: 3000,
|
||||
})
|
||||
} catch {
|
||||
toast.error(t("entry_actions.failed_to_save_to_outline"), {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
return items
|
||||
}, [
|
||||
populatedEntry,
|
||||
view,
|
||||
t,
|
||||
enableEagle,
|
||||
checkEagle.isLoading,
|
||||
checkEagle.data,
|
||||
enableReadwise,
|
||||
readwiseToken,
|
||||
enableInstapaper,
|
||||
instapaperPassword,
|
||||
instapaperUsername,
|
||||
enableOmnivore,
|
||||
omnivoreToken,
|
||||
omnivoreEndpoint,
|
||||
isObsidianEnabled,
|
||||
enableOutline,
|
||||
outlineToken,
|
||||
outlineEndpoint,
|
||||
outlineCollection,
|
||||
saveToObsidian,
|
||||
obsidianVaultPath,
|
||||
])
|
||||
|
||||
return {
|
||||
items,
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import { env } from "@follow/shared/env"
|
||||
import { signOut } from "@follow/shared/auth"
|
||||
import { clearStorage } from "@follow/utils/ns"
|
||||
import { signOut } from "@hono/auth-js/react"
|
||||
import { useCallback } from "react"
|
||||
|
||||
import { setWhoami } from "~/atoms/user"
|
||||
import { isWebBuild, QUERY_PERSIST_KEY } from "~/constants"
|
||||
import { QUERY_PERSIST_KEY } from "~/constants"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
import { clearLocalPersistStoreData } from "~/store/utils/clear"
|
||||
|
||||
@@ -20,9 +19,12 @@ export const useSignOut = () =>
|
||||
clearStorage()
|
||||
window.analytics?.reset()
|
||||
// clear local store data
|
||||
await Promise.allSettled([clearLocalPersistStoreData(), tipcClient?.cleanAuthSessionToken()])
|
||||
await Promise.allSettled([
|
||||
clearLocalPersistStoreData(),
|
||||
tipcClient?.cleanBetterAuthSessionCookie(),
|
||||
])
|
||||
// Sign out
|
||||
await signOut({
|
||||
callbackUrl: isWebBuild ? env.VITE_WEB_URL : undefined,
|
||||
await signOut().then(() => {
|
||||
window.location.reload()
|
||||
})
|
||||
}, [])
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { User } from "@auth/core/types"
|
||||
import type { UserModel } from "@follow/models"
|
||||
|
||||
import { op } from "./op"
|
||||
|
||||
export const setIntegrationIdentify = async (user: User) => {
|
||||
export const setIntegrationIdentify = async (user: UserModel) => {
|
||||
op.identify({
|
||||
profileId: user.id,
|
||||
email: user.email,
|
||||
avatar: user.image,
|
||||
lastName: user.name,
|
||||
avatar: user.image ?? undefined,
|
||||
lastName: user.name ?? undefined,
|
||||
properties: {
|
||||
handle: user.handle,
|
||||
name: user.name,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { initializeDayjs } from "@follow/components/dayjs"
|
||||
import { registerGlobalContext } from "@follow/shared/bridge"
|
||||
import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
import { env } from "@follow/shared/env"
|
||||
import { authConfigManager } from "@hono/auth-js/react"
|
||||
import { repository } from "@pkg"
|
||||
import { enableMapSet } from "immer"
|
||||
|
||||
@@ -63,12 +61,6 @@ export const initializeApp = async () => {
|
||||
window.version = APP_VERSION
|
||||
|
||||
const now = Date.now()
|
||||
// Initialize the auth config first
|
||||
authConfigManager.setConfig({
|
||||
baseUrl: env.VITE_API_URL,
|
||||
basePath: "/auth",
|
||||
credentials: "include",
|
||||
})
|
||||
initializeDayjs()
|
||||
registerHistoryStack()
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { env } from "@follow/shared/env"
|
||||
import type { AppType } from "@follow/shared/hono"
|
||||
import { getCsrfToken } from "@hono/auth-js/react"
|
||||
import PKG from "@pkg"
|
||||
import { hc } from "hono/client"
|
||||
import { FetchError, ofetch } from "ofetch"
|
||||
@@ -13,27 +12,15 @@ import { isDev } from "~/constants"
|
||||
import { NeedActivationToast } from "~/modules/activation/NeedActivationToast"
|
||||
import { DebugRegistry } from "~/modules/debug/registry"
|
||||
|
||||
let csrfTokenPromise: Promise<string> | null = null
|
||||
|
||||
const getPromisedCsrfToken = async () => {
|
||||
if (!csrfTokenPromise) {
|
||||
csrfTokenPromise = getCsrfToken()
|
||||
}
|
||||
|
||||
return await csrfTokenPromise
|
||||
}
|
||||
export const apiFetch = ofetch.create({
|
||||
baseURL: env.VITE_API_URL,
|
||||
credentials: "include",
|
||||
retry: false,
|
||||
onRequest: async ({ options }) => {
|
||||
const csrfToken = await getPromisedCsrfToken()
|
||||
|
||||
onRequest: ({ options }) => {
|
||||
const header = new Headers(options.headers)
|
||||
|
||||
header.set("x-app-version", PKG.version)
|
||||
header.set("X-App-Dev", process.env.NODE_ENV === "development" ? "1" : "0")
|
||||
header.set("X-Csrf-Token", csrfToken)
|
||||
options.headers = header
|
||||
},
|
||||
onResponse() {
|
||||
@@ -92,11 +79,10 @@ export const apiClient = hc<AppType>(env.VITE_API_URL, {
|
||||
}
|
||||
throw err
|
||||
}),
|
||||
async headers() {
|
||||
headers() {
|
||||
return {
|
||||
"X-App-Version": PKG.version,
|
||||
"X-App-Dev": process.env.NODE_ENV === "development" ? "1" : "0",
|
||||
"X-Csrf-Token": await getPromisedCsrfToken(),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { IN_ELECTRON, WEB_URL } from "@follow/shared/constants"
|
||||
import { signIn } from "@hono/auth-js/react"
|
||||
|
||||
export const LOGIN_CALLBACK_URL = `${WEB_URL}/login`
|
||||
export type LoginRuntime = "browser" | "app"
|
||||
export const loginHandler = (provider: string, runtime: LoginRuntime = "app") => {
|
||||
if (IN_ELECTRON) {
|
||||
window.open(`${WEB_URL}/login?provider=${provider}`)
|
||||
} else {
|
||||
signIn(provider, {
|
||||
callbackUrl: runtime === "app" ? LOGIN_CALLBACK_URL : WEB_URL,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -241,6 +241,14 @@ export const parseHtml = (
|
||||
language: language.toLowerCase(),
|
||||
})
|
||||
},
|
||||
figure: ({ node, ...props }) =>
|
||||
createElement(
|
||||
"figure",
|
||||
{
|
||||
className: "max-w-full",
|
||||
},
|
||||
props.children,
|
||||
),
|
||||
table: ({ node, ...props }) =>
|
||||
createElement(
|
||||
"div",
|
||||
|
||||
@@ -30,7 +30,7 @@ export const LanguageMap: Record<
|
||||
},
|
||||
"zh-TW": {
|
||||
value: "zh-TW",
|
||||
label: "Traditional Chinese(Taiwan)",
|
||||
label: "Traditional Chinese (Taiwan)",
|
||||
code: "cmn",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export const ActivationModalContent = ({
|
||||
)}
|
||||
<FormControl>
|
||||
<Input
|
||||
className="font-mono placeholder:font-default"
|
||||
className="placeholder:text-theme-placeholder-text dark:text-zinc-200"
|
||||
placeholder={t("activation.title")}
|
||||
{...field}
|
||||
/>
|
||||
|
||||
@@ -21,7 +21,7 @@ export const FeedDailyModalContent = () => {
|
||||
))}
|
||||
</TabsList>
|
||||
|
||||
<div className="flex grow flex-col items-center overflow-auto">
|
||||
<div className="-mx-2 flex grow flex-col items-center overflow-auto lg:mx-0">
|
||||
{tabs.map((tab: any) => (
|
||||
<TabsContent
|
||||
key={tab}
|
||||
|
||||
@@ -189,30 +189,31 @@ export const DailyReportModalContent: Component<DailyReportContentProps> = ({
|
||||
view,
|
||||
}) => {
|
||||
const content = useQueryData({ endDate, startDate, view })
|
||||
|
||||
const RelatedEntryLink = useState(() => createRelatedEntryLink("toast"))[0]
|
||||
const { t } = useTranslation()
|
||||
const RelatedEntryLink = useState(() => createRelatedEntryLink("toast"))[0]
|
||||
|
||||
if (!content.data && !content.isLoading)
|
||||
return (
|
||||
<div className="center pointer-events-none absolute inset-0 translate-y-6 flex-col gap-4 opacity-80">
|
||||
<div className="center pointer-events-none inset-0 my-8 flex-col gap-4 opacity-80 lg:absolute lg:my-0 lg:translate-y-6">
|
||||
<EmptyIcon />
|
||||
<p>{t("ai_daily.no_found")}</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="center grow flex-col">
|
||||
<div className="flex grow flex-col">
|
||||
{content.isLoading ? (
|
||||
<LoadingCircle
|
||||
size="large"
|
||||
className="center pointer-events-none absolute inset-0 mt-8 text-center"
|
||||
className="center pointer-events-none h-24 text-center lg:absolute lg:inset-0 lg:mt-8 lg:h-auto"
|
||||
/>
|
||||
) : content.data ? (
|
||||
<Markdown
|
||||
components={{
|
||||
a: RelatedEntryLink as Components["a"],
|
||||
}}
|
||||
className="prose-sm mt-4 h-0 grow overflow-auto px-6 prose-p:my-1 prose-ul:my-1 prose-ul:list-outside prose-ul:list-disc prose-li:marker:text-accent"
|
||||
className="prose-sm mt-4 grow overflow-auto px-2 prose-p:my-1 prose-ul:my-1 prose-ul:list-outside prose-ul:list-disc prose-li:marker:text-accent lg:h-0 lg:px-6"
|
||||
>
|
||||
{content.data}
|
||||
</Markdown>
|
||||
|
||||
@@ -15,6 +15,8 @@ export const EntryColumnMobile = () => {
|
||||
|
||||
const [scrollContainer, setScrollContainer] = useState<null | HTMLDivElement>(null)
|
||||
const view = useRouteParamsSelector((s) => s.view)
|
||||
const folderName = useRouteParamsSelector((s) => s.folderName)
|
||||
const listId = useRouteParamsSelector((s) => s.listId)
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setScrollContainer(
|
||||
@@ -22,10 +24,11 @@ export const EntryColumnMobile = () => {
|
||||
)
|
||||
}, 1000)
|
||||
return () => clearTimeout(timer)
|
||||
}, [view])
|
||||
}, [view, folderName, listId])
|
||||
usePreventOverscrollBounce()
|
||||
|
||||
return (
|
||||
<div className="flex h-screen min-w-0 grow">
|
||||
<div className="flex h-screen min-w-0 grow overflow-hidden">
|
||||
<EntryColumn />
|
||||
|
||||
{isStartupTimeline && (
|
||||
|
||||
@@ -8,7 +8,7 @@ import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
import { preventDefault } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { throttle } from "es-toolkit/compat"
|
||||
import { debounce } from "es-toolkit/compat"
|
||||
import type { PropsWithChildren } from "react"
|
||||
import * as React from "react"
|
||||
import { forwardRef, Suspense, useEffect, useRef, useState } from "react"
|
||||
@@ -208,22 +208,29 @@ const FeedResponsiveResizerContainer = ({
|
||||
setFeedColumnTempShow(false)
|
||||
return
|
||||
}
|
||||
const handler = throttle((e: MouseEvent) => {
|
||||
const mouseX = e.clientX
|
||||
const mouseY = e.clientY
|
||||
const handler = debounce(
|
||||
(e: MouseEvent) => {
|
||||
const mouseX = e.clientX
|
||||
const mouseY = e.clientY
|
||||
|
||||
const uiSettings = getUISettings()
|
||||
const feedColumnTempShow = getFeedColumnTempShow()
|
||||
const isInEntryContentWideMode = uiSettings.wideMode || getIsZenMode()
|
||||
if (mouseY < 200 && isInEntryContentWideMode) return
|
||||
const threshold = feedColumnTempShow ? uiSettings.feedColWidth : 100
|
||||
const uiSettings = getUISettings()
|
||||
const feedColumnTempShow = getFeedColumnTempShow()
|
||||
const isInEntryContentWideMode = uiSettings.wideMode || getIsZenMode()
|
||||
const feedWidth = uiSettings.feedColWidth
|
||||
if (mouseY < 200 && isInEntryContentWideMode && mouseX < feedWidth) return
|
||||
const threshold = feedColumnTempShow ? uiSettings.feedColWidth : 100
|
||||
|
||||
if (mouseX < threshold) {
|
||||
setFeedColumnTempShow(true)
|
||||
} else {
|
||||
setFeedColumnTempShow(false)
|
||||
}
|
||||
}, 300)
|
||||
if (mouseX < threshold) {
|
||||
setFeedColumnTempShow(true)
|
||||
} else {
|
||||
setFeedColumnTempShow(false)
|
||||
}
|
||||
},
|
||||
36,
|
||||
{
|
||||
leading: true,
|
||||
},
|
||||
)
|
||||
|
||||
document.addEventListener("mousemove", handler)
|
||||
return () => {
|
||||
@@ -269,7 +276,7 @@ const FeedResponsiveResizerContainer = ({
|
||||
"shrink-0 overflow-hidden",
|
||||
"absolute inset-y-0 z-[2]",
|
||||
feedColumnTempShow && !feedColumnShow && "shadow-drawer-to-right z-[12]",
|
||||
!feedColumnShow && !feedColumnTempShow ? "-translate-x-full delay-200" : "",
|
||||
!feedColumnShow && !feedColumnTempShow ? "-translate-x-full" : "",
|
||||
!isDragging ? "duration-200" : "",
|
||||
)}
|
||||
style={{
|
||||
|
||||
@@ -18,7 +18,6 @@ import { feedIconSelector } from "~/store/feed/selector"
|
||||
import { useUnreadByView } from "~/store/unread/hooks"
|
||||
|
||||
import { ProfileButton } from "../../user/ProfileButton"
|
||||
import styles from "./mobile.module.css"
|
||||
|
||||
export const MobileFloatBar = ({
|
||||
scrollContainer,
|
||||
@@ -74,22 +73,28 @@ export const MobileFloatBar = ({
|
||||
}, [isScrollDown, animateController])
|
||||
|
||||
return (
|
||||
<m.div
|
||||
<div
|
||||
className={clsx(
|
||||
"absolute inset-x-0 flex h-10 justify-center will-change-transform bottom-safe-offset-8",
|
||||
"pointer-events-none absolute inset-x-0 bottom-0 flex h-36 items-end overflow-hidden pb-safe-offset-6",
|
||||
className,
|
||||
)}
|
||||
transition={{ type: "spring" }}
|
||||
animate={animateController}
|
||||
>
|
||||
<div className={styles["float-bar"]}>
|
||||
<m.div
|
||||
className={clsx(
|
||||
"mx-auto inline-flex h-10 min-w-0 items-center rounded-full border border-neutral-200 bg-background pl-4 pr-2 shadow-sm shadow-zinc-100 dark:border-neutral-800",
|
||||
"[box-shadow:0px_8px_30px_rgba(122,122,122,0.2)] dark:[box-shadow:0px_8px_30px_rgba(122,122,122,0.2)]",
|
||||
"pointer-events-auto",
|
||||
)}
|
||||
transition={{ type: "spring" }}
|
||||
animate={animateController}
|
||||
>
|
||||
<PlayerIcon isScrollDown={isScrollDown} onLogoClick={onLogoClick} />
|
||||
<DividerVertical className="h-3/4 shrink-0" />
|
||||
<ViewTabs onViewChange={onViewChange} />
|
||||
<DividerVertical className="h-3/4 shrink-0" />
|
||||
<ProfileButton />
|
||||
</div>
|
||||
</m.div>
|
||||
</m.div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,38 @@
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.js"
|
||||
import { Outlet } from "react-router"
|
||||
|
||||
import { useLoginModalShow, useWhoami } from "~/atoms/user"
|
||||
import { PlainModal } from "~/components/ui/modal/stacked/custom-modal"
|
||||
import { DeclarativeModal } from "~/components/ui/modal/stacked/declarative-modal"
|
||||
import { useDailyTask } from "~/hooks/biz/useDailyTask"
|
||||
import { LoginModalContent } from "~/modules/auth/LoginModalContent"
|
||||
|
||||
import { NewUserGuide } from "./index.shared"
|
||||
|
||||
export const MobileRootLayout = () => {
|
||||
useDailyTask()
|
||||
|
||||
const isAuthFail = useLoginModalShow()
|
||||
const user = useWhoami()
|
||||
return (
|
||||
<>
|
||||
<Outlet />
|
||||
<NewUserGuide />
|
||||
|
||||
{isAuthFail && !user && (
|
||||
<RootPortal>
|
||||
<DeclarativeModal
|
||||
id="login"
|
||||
CustomModalComponent={PlainModal}
|
||||
open
|
||||
overlay
|
||||
title="Login"
|
||||
canClose={false}
|
||||
clickOutsideToDismiss={false}
|
||||
>
|
||||
<LoginModalContent canClose={false} runtime={"browser"} />
|
||||
</DeclarativeModal>
|
||||
</RootPortal>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
.float-bar {
|
||||
@apply min-w-0 mx-4 rounded-full border bg-background dark:border-neutral-800 shadow-sm shadow-zinc-100 border-neutral-200 h-10 inline-flex items-center pl-4 pr-2;
|
||||
|
||||
box-shadow: 0px 8px 30px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .float-bar {
|
||||
box-shadow: 0px 8px 30px rgba(122, 122, 122, 0.2);
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Logo } from "@follow/components/icons/logo.js"
|
||||
import { ActionButton } from "@follow/components/ui/button/index.js"
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.js"
|
||||
import { views } from "@follow/constants"
|
||||
import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import useEmblaCarousel from "embla-carousel-react"
|
||||
import type { FC } from "react"
|
||||
@@ -11,11 +9,7 @@ import { useTranslation } from "react-i18next"
|
||||
import { Link } from "react-router"
|
||||
|
||||
import { useSetSidebarActiveView, useSidebarActiveView } from "~/atoms/sidebar"
|
||||
import { useLoginModalShow, useWhoami } from "~/atoms/user"
|
||||
import { PlainModal } from "~/components/ui/modal/stacked/custom-modal"
|
||||
import { DeclarativeModal } from "~/components/ui/modal/stacked/declarative-modal"
|
||||
import { getRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { LoginModalContent } from "~/modules/auth/LoginModalContent"
|
||||
|
||||
import { FeedList } from "../../feed-column/list"
|
||||
import { FooterInfo } from "./components/FooterInfo"
|
||||
@@ -34,9 +28,6 @@ export function FeedColumnMobile({ asWidget }: { asWidget?: boolean }) {
|
||||
|
||||
const [feedListScrollRef, setFeedListScrollRef] = useState<HTMLDivElement | null>()
|
||||
|
||||
const isAuthFail = useLoginModalShow()
|
||||
const user = useWhoami()
|
||||
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
@@ -73,22 +64,6 @@ export function FeedColumnMobile({ asWidget }: { asWidget?: boolean }) {
|
||||
</SwipeWrapper>
|
||||
</div>
|
||||
|
||||
{isAuthFail && !user && (
|
||||
<RootPortal>
|
||||
<DeclarativeModal
|
||||
id="login"
|
||||
CustomModalComponent={PlainModal}
|
||||
open
|
||||
overlay
|
||||
title="Login"
|
||||
canClose={false}
|
||||
clickOutsideToDismiss={false}
|
||||
>
|
||||
<LoginModalContent canClose={false} runtime={IN_ELECTRON ? "app" : "browser"} />
|
||||
</DeclarativeModal>
|
||||
</RootPortal>
|
||||
)}
|
||||
|
||||
<FooterInfo />
|
||||
<MobileFloatBar
|
||||
className={asWidget ? "!bottom-0" : undefined}
|
||||
|
||||
@@ -12,7 +12,9 @@ export const SubviewLayout = () => {
|
||||
const scrollYProgress = useScroll()
|
||||
|
||||
const opacity = useTransform(scrollYProgress.scrollY, [0, 120], [0, 1], { ease: easeOut })
|
||||
const borderOpacity = useTransform(scrollYProgress.scrollY, [50, 120], [0, 1], { ease: easeOut })
|
||||
const borderOpacity = useTransform(scrollYProgress.scrollY, [50, 120], [0, 0.5], {
|
||||
ease: easeOut,
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -22,7 +24,7 @@ export const SubviewLayout = () => {
|
||||
className={cn(
|
||||
"sticky inset-x-0 top-0 z-10 p-4",
|
||||
"grid grid-cols-[1fr_auto_1fr] items-center gap-4",
|
||||
"bg-zinc-50/80 backdrop-blur-xl dark:bg-neutral-900/90",
|
||||
"bg-theme-background",
|
||||
"border-b",
|
||||
)}
|
||||
style={{
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { WindowState } from "@follow/shared/bridge"
|
||||
import { preventDefault } from "@follow/utils/dom"
|
||||
|
||||
import { useWindowState } from "~/atoms/app"
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT } from "~/constants"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
|
||||
export const Titlebar = () => {
|
||||
const { data: isMaximized, refetch } = useQuery({
|
||||
queryFn: () => tipcClient?.getWindowIsMaximized(),
|
||||
queryKey: ["windowIsMaximized"],
|
||||
})
|
||||
const isMaximized = useWindowState() === WindowState.MAXIMIZED
|
||||
|
||||
const feedColWidth = useUISettingKey("feedColWidth")
|
||||
|
||||
return (
|
||||
<div
|
||||
onContextMenu={preventDefault}
|
||||
className="drag-region absolute right-0 flex items-center justify-end overflow-hidden"
|
||||
style={{
|
||||
height: `${ElECTRON_CUSTOM_TITLEBAR_HEIGHT}px`,
|
||||
@@ -35,7 +35,6 @@ export const Titlebar = () => {
|
||||
className="no-drag-region pointer-events-auto flex h-full w-[50px] items-center justify-center duration-200 hover:bg-theme-item-active"
|
||||
onClick={async () => {
|
||||
await tipcClient?.windowAction({ action: "maximum" })
|
||||
refetch()
|
||||
}}
|
||||
>
|
||||
{isMaximized ? (
|
||||
|
||||
@@ -2,6 +2,8 @@ import { FollowIcon } from "@follow/components/icons/follow.jsx"
|
||||
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
|
||||
import { authProvidersConfig } from "@follow/constants"
|
||||
import type { LoginRuntime } from "@follow/shared/auth"
|
||||
import { loginHandler } from "@follow/shared/auth"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import clsx from "clsx"
|
||||
import { AnimatePresence, m } from "framer-motion"
|
||||
@@ -10,8 +12,6 @@ import { useTranslation } from "react-i18next"
|
||||
|
||||
import { modalMontionConfig } from "~/components/ui/modal/stacked/constants"
|
||||
import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
|
||||
import type { LoginRuntime } from "~/lib/auth"
|
||||
import { loginHandler } from "~/lib/auth"
|
||||
import { useAuthProviders } from "~/queries/users"
|
||||
|
||||
interface LoginModalContentProps {
|
||||
|
||||
@@ -41,14 +41,14 @@ export const RadioCards = ({
|
||||
{radios.map((item) => (
|
||||
<RadioCard
|
||||
key={item.value}
|
||||
wrapperClassName="justify-center"
|
||||
wrapperClassName="justify-center py-2.5"
|
||||
value={(item.value * monthlyBoostCost).toString()}
|
||||
label={
|
||||
<div className="text-center">
|
||||
<h3 className="text-sm font-medium leading-none">
|
||||
{dayjs.duration(item.value, "months").humanize()}
|
||||
</h3>
|
||||
<p className="mt-0.5 flex items-center justify-center gap-1 text-sm text-theme-vibrancyFg">
|
||||
<p className="mt-1 flex items-center justify-center gap-1 text-xs leading-none text-theme-vibrancyFg">
|
||||
{item.value * monthlyBoostCost}
|
||||
<i className="i-mgc-power text-accent" />
|
||||
</p>
|
||||
|
||||
@@ -42,7 +42,7 @@ export const FeedClaimModalContent: FC<{
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="center h-32 w-[650px]">
|
||||
<div className="center h-32 lg:w-[650px]">
|
||||
<LoadingCircle size="large" />
|
||||
</div>
|
||||
)
|
||||
@@ -53,7 +53,7 @@ export const FeedClaimModalContent: FC<{
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-[650px]">
|
||||
<div className="mx-auto w-full max-w-[650px]">
|
||||
<Card className="mb-2">
|
||||
<CardHeader>
|
||||
<FollowSummary feed={feed} />
|
||||
@@ -78,10 +78,8 @@ export const FeedClaimModalContent: FC<{
|
||||
<BaseCodeBlock>{claimMessage?.data.content || ""}</BaseCodeBlock>
|
||||
</TabsContent>
|
||||
<TabsContent className="mt-0 pt-3" value="description">
|
||||
<p className="mb-2 leading-none">
|
||||
{t("feed_claim_modal.description_current")}
|
||||
<span className="ml-2 text-xs text-zinc-500">{feed.description}</span>
|
||||
</p>
|
||||
<p className="mb-2 leading-none">{t("feed_claim_modal.description_current")}</p>
|
||||
<p className="my-2 text-xs text-zinc-500">{feed.description}</p>
|
||||
<Trans
|
||||
i18nKey="feed_claim_modal.description_instructions"
|
||||
components={{ code: <code className="text-sm">{"<description />"}</code> }}
|
||||
|
||||
@@ -19,9 +19,9 @@ export const COMMAND_ID = {
|
||||
saveToEagle: "integration:save-to-eagle",
|
||||
saveToReadwise: "integration:save-to-readwise",
|
||||
saveToInstapaper: "integration:save-to-instapaper",
|
||||
saveToOmnivore: "integration:save-to-omnivore",
|
||||
saveToObsidian: "integration:save-to-obsidian",
|
||||
saveToOutline: "integration:save-to-outline",
|
||||
saveToReadeck: "integration:save-to-readeck",
|
||||
},
|
||||
list: {
|
||||
edit: "list:edit",
|
||||
|
||||
@@ -2,8 +2,8 @@ import {
|
||||
SimpleIconsEagle,
|
||||
SimpleIconsInstapaper,
|
||||
SimpleIconsObsidian,
|
||||
SimpleIconsOmnivore,
|
||||
SimpleIconsOutline,
|
||||
SimpleIconsReadeck,
|
||||
SimpleIconsReadwise,
|
||||
} from "@follow/components/ui/platform-icon/icons.js"
|
||||
import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
@@ -29,9 +29,9 @@ export const useRegisterIntegrationCommands = () => {
|
||||
useRegisterEagleCommands()
|
||||
useRegisterReadwiseCommands()
|
||||
useRegisterInstapaperCommands()
|
||||
useRegisterOmnivoreCommands()
|
||||
useRegisterObsidianCommands()
|
||||
useRegisterOutlineCommands()
|
||||
useRegisterReadeckCommands()
|
||||
}
|
||||
|
||||
const useRegisterEagleCommands = () => {
|
||||
@@ -236,90 +236,6 @@ const useRegisterInstapaperCommands = () => {
|
||||
)
|
||||
}
|
||||
|
||||
const useRegisterOmnivoreCommands = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const enableOmnivore = useIntegrationSettingKey("enableOmnivore")
|
||||
const omnivoreToken = useIntegrationSettingKey("omnivoreToken")
|
||||
const omnivoreEndpoint = useIntegrationSettingKey("omnivoreEndpoint")
|
||||
|
||||
const isOmnivoreAvailable = enableOmnivore && !!omnivoreToken && !!omnivoreEndpoint
|
||||
|
||||
useRegisterCommandEffect(
|
||||
!isOmnivoreAvailable
|
||||
? []
|
||||
: defineFollowCommand({
|
||||
id: COMMAND_ID.integration.saveToOmnivore,
|
||||
label: t("entry_actions.save_to_omnivore"),
|
||||
icon: <SimpleIconsOmnivore />,
|
||||
run: async ({ entryId }) => {
|
||||
const entry = useEntryStore.getState().flatMapEntries[entryId]
|
||||
if (!entry) {
|
||||
toast.error("Failed to save to Omnivore: entry is not available", { duration: 3000 })
|
||||
return
|
||||
}
|
||||
const saveUrlQuery = `
|
||||
mutation SaveUrl($input: SaveUrlInput!) {
|
||||
saveUrl(input: $input) {
|
||||
... on SaveSuccess {
|
||||
url
|
||||
clientRequestId
|
||||
}
|
||||
... on SaveError {
|
||||
errorCodes
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
window.analytics?.capture("integration", {
|
||||
type: "omnivore",
|
||||
event: "save",
|
||||
})
|
||||
try {
|
||||
const data = await ofetch(omnivoreEndpoint, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: omnivoreToken,
|
||||
},
|
||||
body: {
|
||||
query: saveUrlQuery,
|
||||
variables: {
|
||||
input: {
|
||||
url: entry.entries.url,
|
||||
source: "Follow",
|
||||
clientRequestId: globalThis.crypto.randomUUID(),
|
||||
publishedAt: new Date(entry.entries.publishedAt),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
toast.success(
|
||||
<>
|
||||
{t("entry_actions.saved_to_omnivore")},{" "}
|
||||
<a target="_blank" className="underline" href={data.data.saveUrl.url}>
|
||||
view
|
||||
</a>
|
||||
</>,
|
||||
{
|
||||
duration: 3000,
|
||||
},
|
||||
)
|
||||
} catch {
|
||||
toast.error(t("entry_actions.failed_to_save_to_omnivore"), {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
}),
|
||||
{
|
||||
deps: [isOmnivoreAvailable],
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
const getEntryContentAsMarkdown = async (entry: FlatEntryModel) => {
|
||||
const isReadabilityReady = getReadabilityStatus()[entry.entries.id] === ReadabilityStatus.SUCCESS
|
||||
const content =
|
||||
@@ -466,3 +382,71 @@ const useRegisterOutlineCommands = () => {
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
const useRegisterReadeckCommands = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const enableReadeck = useIntegrationSettingKey("enableReadeck")
|
||||
const readeckEndpoint = useIntegrationSettingKey("readeckEndpoint")
|
||||
const readeckToken = useIntegrationSettingKey("readeckToken")
|
||||
const readeckAvailable = enableReadeck && !!readeckEndpoint && !!readeckToken
|
||||
|
||||
useRegisterCommandEffect(
|
||||
!readeckAvailable
|
||||
? []
|
||||
: defineFollowCommand({
|
||||
id: COMMAND_ID.integration.saveToReadeck,
|
||||
label: t("entry_actions.save_to_readeck"),
|
||||
icon: <SimpleIconsReadeck />,
|
||||
run: async ({ entryId }) => {
|
||||
const entry = useEntryStore.getState().flatMapEntries[entryId]
|
||||
if (!entry) {
|
||||
toast.error("Failed to save to Readeck: entry is not available", { duration: 3000 })
|
||||
return
|
||||
}
|
||||
try {
|
||||
window.analytics?.capture("integration", {
|
||||
type: "readeck",
|
||||
event: "save",
|
||||
})
|
||||
const data = new FormData()
|
||||
if (entry.entries.url) {
|
||||
data.set("url", entry.entries.url)
|
||||
}
|
||||
if (entry.entries.title) {
|
||||
data.set("title", entry.entries.title)
|
||||
}
|
||||
const response = await ofetch.raw(
|
||||
`${readeckEndpoint.replace(/\/$/, "")}/api/bookmarks`,
|
||||
{
|
||||
method: "POST",
|
||||
body: data,
|
||||
headers: {
|
||||
Authorization: `Bearer ${readeckToken}`,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
toast.success(
|
||||
<>
|
||||
{t("entry_actions.saved_to_readeck")},{" "}
|
||||
<a target="_blank" className="underline" href={response.headers.get("Location")!}>
|
||||
view
|
||||
</a>
|
||||
</>,
|
||||
{
|
||||
duration: 3000,
|
||||
},
|
||||
)
|
||||
} catch {
|
||||
toast.error(t("entry_actions.failed_to_save_to_readeck"), {
|
||||
duration: 3000,
|
||||
})
|
||||
}
|
||||
},
|
||||
}),
|
||||
{
|
||||
deps: [readeckAvailable],
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -106,11 +106,6 @@ export type SaveToInstapaperCommand = Command<{
|
||||
fn: (payload: { entryId: string }) => void
|
||||
}>
|
||||
|
||||
export type SaveToOmnivoreCommand = Command<{
|
||||
id: typeof COMMAND_ID.integration.saveToOmnivore
|
||||
fn: (payload: { entryId: string }) => void
|
||||
}>
|
||||
|
||||
export type SaveToObsidianCommand = Command<{
|
||||
id: typeof COMMAND_ID.integration.saveToObsidian
|
||||
fn: (payload: { entryId: string }) => void
|
||||
@@ -121,12 +116,17 @@ export type SaveToOutlineCommand = Command<{
|
||||
fn: (payload: { entryId: string }) => void
|
||||
}>
|
||||
|
||||
export type SaveToReadeckCommand = Command<{
|
||||
id: typeof COMMAND_ID.integration.saveToReadeck
|
||||
fn: (payload: { entryId: string }) => void
|
||||
}>
|
||||
|
||||
export type IntegrationCommand =
|
||||
| SaveToEagleCommand
|
||||
| SaveToReadwiseCommand
|
||||
| SaveToInstapaperCommand
|
||||
| SaveToOmnivoreCommand
|
||||
| SaveToObsidianCommand
|
||||
| SaveToOutlineCommand
|
||||
| SaveToReadeckCommand
|
||||
|
||||
export type BasicCommand = EntryCommand | IntegrationCommand
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { EntryModelSimple, FeedModel } from "@follow/models/types"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useEffect, useMemo, useRef } from "react"
|
||||
import { useCallback, useEffect, useMemo, useRef } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
@@ -76,7 +76,9 @@ export const FeedForm: Component<{
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-full flex-col",
|
||||
asWidget ? "mx-auto min-h-[420px] w-full max-w-[550px]" : "px-[18px] pb-[18px] pt-12",
|
||||
asWidget
|
||||
? "mx-auto min-h-[420px] w-full max-w-[550px] lg:min-w-[550px]"
|
||||
: "px-[18px] pb-[18px] pt-12",
|
||||
)}
|
||||
>
|
||||
{!asWidget && (
|
||||
@@ -273,6 +275,10 @@ const FeedInnerForm = ({
|
||||
[categories.data],
|
||||
)
|
||||
|
||||
const fillDefaultTitle = useCallback(() => {
|
||||
form.setValue("title", feed.title || "")
|
||||
}, [feed.title, form])
|
||||
|
||||
return (
|
||||
<div className="flex flex-1 flex-col gap-y-4">
|
||||
<Card>
|
||||
@@ -292,7 +298,18 @@ const FeedInnerForm = ({
|
||||
<FormDescription>{t("feed_form.title_description")}</FormDescription>
|
||||
</div>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
<div className="flex gap-2">
|
||||
<Input {...field} />
|
||||
<Button
|
||||
buttonClassName="shrink-0"
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={fillDefaultTitle}
|
||||
disabled={field.value === feed.title}
|
||||
>
|
||||
{t("feed_form.fill_default")}
|
||||
</Button>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
@@ -19,8 +19,8 @@ import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { produce } from "immer"
|
||||
import { atom, useAtomValue, useStore } from "jotai"
|
||||
import type { FC } from "react"
|
||||
import { memo, useCallback, useEffect, useState } from "react"
|
||||
import type { ChangeEvent, FC } from "react"
|
||||
import { memo, useCallback, useState } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { z } from "zod"
|
||||
@@ -119,26 +119,26 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
const keyword = form.watch("keyword")
|
||||
useEffect(() => {
|
||||
const trimmedKeyword = keyword.trimStart()
|
||||
if (!prefix) {
|
||||
const handleKeywordChange = useCallback(
|
||||
(event: ChangeEvent<HTMLInputElement>) => {
|
||||
const trimmedKeyword = event.target.value.trimStart()
|
||||
if (!prefix) {
|
||||
form.setValue("keyword", trimmedKeyword)
|
||||
return
|
||||
}
|
||||
const isValidPrefix = prefix.find((p) => trimmedKeyword.startsWith(p))
|
||||
if (!isValidPrefix) {
|
||||
form.setValue("keyword", prefix[0])
|
||||
return
|
||||
}
|
||||
if (trimmedKeyword.startsWith(`${isValidPrefix}${isValidPrefix}`)) {
|
||||
form.setValue("keyword", trimmedKeyword.slice(isValidPrefix.length))
|
||||
return
|
||||
}
|
||||
form.setValue("keyword", trimmedKeyword)
|
||||
return
|
||||
}
|
||||
const isValidPrefix = prefix.find((p) => trimmedKeyword.startsWith(p))
|
||||
if (!isValidPrefix) {
|
||||
form.setValue("keyword", prefix[0])
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (trimmedKeyword.startsWith(`${isValidPrefix}${isValidPrefix}`)) {
|
||||
form.setValue("keyword", trimmedKeyword.slice(isValidPrefix.length))
|
||||
}
|
||||
|
||||
form.setValue("keyword", trimmedKeyword)
|
||||
}, [form, keyword, prefix])
|
||||
},
|
||||
[form, prefix],
|
||||
)
|
||||
|
||||
const handleSuccess = useCallback(
|
||||
(item: DiscoverSearchData[number]) => {
|
||||
@@ -210,7 +210,7 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
|
||||
<FormItem>
|
||||
<FormLabel>{t(info[type]?.label)}</FormLabel>
|
||||
<FormControl>
|
||||
<Input autoFocus {...field} />
|
||||
<Input autoFocus {...field} onChange={handleKeywordChange} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useForm } from "react-hook-form"
|
||||
import { Trans, useTranslation } from "react-i18next"
|
||||
import { z } from "zod"
|
||||
|
||||
import { DropZone } from "~/components/ui/drop-zone"
|
||||
import { apiFetch } from "~/lib/api-fetch"
|
||||
import { toastFetchError } from "~/lib/error-parser"
|
||||
import { Queries } from "~/queries"
|
||||
@@ -30,9 +31,14 @@ type FeedResponseList = {
|
||||
}[]
|
||||
|
||||
const formSchema = z.object({
|
||||
file: z.instanceof(File).refine((file) => file.size < 500_000, {
|
||||
message: "Your OPML file must be less than 500KB.",
|
||||
}),
|
||||
file: z
|
||||
.instanceof(File)
|
||||
.refine((file) => file.size < 500_000, {
|
||||
message: "Your OPML file must be less than 500KB.",
|
||||
})
|
||||
.refine((file) => file.name.endsWith(".opml") || file.name.endsWith(".xml"), {
|
||||
message: "Your OPML file must be in OPML or XML format.",
|
||||
}),
|
||||
})
|
||||
|
||||
const NumberDisplay = ({ value }) => <span className="font-bold text-zinc-800">{value ?? 0}</span>
|
||||
@@ -110,26 +116,21 @@ export function DiscoverImport({ isInit = false }: { isInit?: boolean }) {
|
||||
{isInit ? t("discover.import.new_import_opml") : t("discover.import.opml")}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<label
|
||||
className="center flex h-[100px] w-full rounded-md border border-dashed"
|
||||
htmlFor="upload-file"
|
||||
>
|
||||
<DropZone onDrop={(fileList) => onChange(fileList[0])}>
|
||||
{form.formState.dirtyFields.file ? (
|
||||
<Fragment>
|
||||
<i className="i-mgc-file-upload-cute-re size-5" />
|
||||
|
||||
<span className="ml-2 text-sm font-semibold opacity-80">{value.name}</span>
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
<i className="i-mgc-file-upload-cute-re size-5" />
|
||||
|
||||
<span className="ml-2 text-sm opacity-80">
|
||||
{t("discover.import.click_to_upload")}
|
||||
</span>
|
||||
</Fragment>
|
||||
)}
|
||||
</label>
|
||||
</DropZone>
|
||||
</FormControl>
|
||||
<Input
|
||||
{...fieldProps}
|
||||
|
||||
@@ -8,7 +8,7 @@ export const RecommendationContent = ({
|
||||
route: RSSHubRoute
|
||||
routePrefix: string
|
||||
}) => (
|
||||
<div className="w-full max-w-[700px] sm:min-w-[550px]">
|
||||
<div className="mx-auto w-full max-w-[700px] sm:min-w-[550px]">
|
||||
<DiscoverFeedForm route={route} routePrefix={routePrefix} />
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { Queries } from "~/queries"
|
||||
|
||||
import { TrendingButton } from "../trending"
|
||||
import { RSSHubCategories } from "./constants"
|
||||
import styles from "./recommendations.module.css"
|
||||
import { RecommendationCard } from "./recommendations-card"
|
||||
@@ -42,6 +43,7 @@ const fetchRsshubPopular = (category: DiscoverCategories, lang: Language) => {
|
||||
lang,
|
||||
})
|
||||
}
|
||||
let firstLoad = true
|
||||
export function Recommendations({
|
||||
hideTitle,
|
||||
className,
|
||||
@@ -62,9 +64,13 @@ export function Recommendations({
|
||||
meta: {
|
||||
persist: true,
|
||||
},
|
||||
staleTime: 1000 * 60 * 60 * 24, // 1 day
|
||||
refetchOnMount: firstLoad ? "always" : true,
|
||||
placeholderData: keepPreviousData,
|
||||
})
|
||||
|
||||
firstLoad = false
|
||||
|
||||
const { data, isLoading, isFetching } = rsshubPopular
|
||||
|
||||
const keys = useMemo(() => {
|
||||
@@ -136,14 +142,18 @@ export function Recommendations({
|
||||
return (
|
||||
<div className={cn(!hideTitle && "mt-8 w-full max-w-[1200px]")}>
|
||||
{!hideTitle && (
|
||||
<div className="relative text-center text-lg font-bold">
|
||||
<div className="center relative flex text-lg font-bold">
|
||||
<span>{t("discover.popular")}</span>
|
||||
|
||||
<div className="absolute bottom-0 right-0">
|
||||
<TrendingButton language={selectedLang} />
|
||||
</div>
|
||||
{isFetching && (
|
||||
<div className="pointer-events-none absolute inset-x-0 top-0 flex items-center justify-center gap-8">
|
||||
<span className="opacity-0" aria-hidden>
|
||||
{t("discover.popular")}
|
||||
</span>
|
||||
|
||||
<LoadingCircle size="small" className="center flex" />
|
||||
</div>
|
||||
)}
|
||||
@@ -152,7 +162,7 @@ export function Recommendations({
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"z-[9] my-3 flex w-full flex-col items-end gap-4 bg-theme-background sm:flex-row sm:items-center",
|
||||
"z-[9] my-3 flex w-full flex-col items-end gap-4 sm:flex-row sm:items-center",
|
||||
headerClassName,
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useRefValue } from "@follow/hooks"
|
||||
import type { FC } from "react"
|
||||
import { memo, useLayoutEffect, useState } from "react"
|
||||
import { useHotkeys } from "react-hotkeys-hook"
|
||||
import type { VirtuosoHandle } from "react-virtuoso"
|
||||
|
||||
import { useMainContainerElement } from "~/atoms/dom"
|
||||
import { HotKeyScopeMap } from "~/constants"
|
||||
@@ -13,8 +12,8 @@ import { useRouteEntryId } from "~/hooks/biz/useRouteParams"
|
||||
export const EntryColumnShortcutHandler: FC<{
|
||||
refetch: () => void
|
||||
data: readonly string[]
|
||||
virtuosoRef: React.RefObject<VirtuosoHandle>
|
||||
}> = memo(({ data, refetch, virtuosoRef }) => {
|
||||
handleScrollTo: (index: number) => void
|
||||
}> = memo(({ data, refetch, handleScrollTo }) => {
|
||||
const dataRef = useRefValue(data!)
|
||||
|
||||
useHotkeys(
|
||||
@@ -58,9 +57,7 @@ export const EntryColumnShortcutHandler: FC<{
|
||||
|
||||
const nextIndex = Math.min(currentActiveEntryIndex + 1, data.length - 1)
|
||||
|
||||
virtuosoRef.current?.scrollIntoView?.({
|
||||
index: nextIndex,
|
||||
})
|
||||
handleScrollTo(nextIndex)
|
||||
const nextId = data![nextIndex]
|
||||
|
||||
navigate({
|
||||
@@ -78,9 +75,7 @@ export const EntryColumnShortcutHandler: FC<{
|
||||
const nextIndex =
|
||||
currentActiveEntryIndex === -1 ? data.length - 1 : Math.max(0, currentActiveEntryIndex - 1)
|
||||
|
||||
virtuosoRef.current?.scrollIntoView?.({
|
||||
index: nextIndex,
|
||||
})
|
||||
handleScrollTo(nextIndex)
|
||||
const nextId = data![nextIndex]
|
||||
|
||||
navigate({
|
||||
|
||||
@@ -16,7 +16,7 @@ export function ArticleItem({ entryId, entryPreview, translation }: UniversalIte
|
||||
|
||||
export function ArticleItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
return (
|
||||
<div className="relative rounded-md text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative select-none rounded-md text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
<div className="group relative flex py-4 pl-3 pr-2">
|
||||
<FeedIcon className="mr-2 size-5 rounded-sm" feed={feed} fallback />
|
||||
@@ -58,7 +58,7 @@ export function ArticleItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
}
|
||||
|
||||
export const ArticleItemSkeleton = (
|
||||
<div className="relative h-[120px] rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative h-[120px] rounded-md text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
<div className="group relative flex py-4 pl-3 pr-2">
|
||||
<Skeleton className="mr-2 size-5 rounded-sm" />
|
||||
|
||||
@@ -15,7 +15,7 @@ export function AudioItem({ entryId, entryPreview, translation }: UniversalItemP
|
||||
|
||||
export function AudioItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
return (
|
||||
<div className="relative mx-auto w-full max-w-lg rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative mx-auto w-full max-w-lg select-none rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
<div className="group relative flex py-4 pl-3 pr-2">
|
||||
<div className="-mt-0.5 line-clamp-4 flex-1 text-sm leading-tight">
|
||||
@@ -57,7 +57,7 @@ export function AudioItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
}
|
||||
|
||||
export const AudioItemSkeleton = (
|
||||
<div className="relative mx-auto w-full max-w-lg rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative mx-auto w-full max-w-lg select-none rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
<div className="group relative flex py-4 pl-3 pr-2">
|
||||
<div className="-mt-0.5 line-clamp-4 flex-1 text-sm leading-tight">
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
|
||||
import { ArticleItem, ArticleItemSkeleton, ArticleItemStateLess } from "./article-item"
|
||||
import { AudioItem, AudioItemSkeleton, AudioItemStateLess } from "./audio-item"
|
||||
import {
|
||||
NotificationItem,
|
||||
NotificationItemSkeleton,
|
||||
NotificationItemStateLess,
|
||||
} from "./notification-item"
|
||||
import { PictureItem, PictureItemSkeleton, PictureItemStateLess } from "./picture-item"
|
||||
import {
|
||||
SocialMediaItem,
|
||||
SocialMediaItemSkeleton,
|
||||
SocialMediaItemStateLess,
|
||||
} from "./social-media-item"
|
||||
import { VideoItem, VideoItemSkeleton, VideoItemStateLess } from "./video-item"
|
||||
import { ArticleItem, ArticleItemSkeleton } from "./article-item"
|
||||
import { AudioItem, AudioItemSkeleton } from "./audio-item"
|
||||
import { NotificationItem, NotificationItemSkeleton } from "./notification-item"
|
||||
import { PictureItem, PictureItemSkeleton } from "./picture-item"
|
||||
import { SocialMediaItem, SocialMediaItemSkeleton } from "./social-media-item"
|
||||
import { VideoItem, VideoItemSkeleton } from "./video-item"
|
||||
|
||||
const ItemMap = {
|
||||
[FeedViewType.Articles]: ArticleItem,
|
||||
@@ -27,19 +19,6 @@ export const getItemComponentByView = (view: FeedViewType) => {
|
||||
return ItemMap[view] || ArticleItem
|
||||
}
|
||||
|
||||
const StatelessItemMap = {
|
||||
[FeedViewType.Articles]: ArticleItemStateLess,
|
||||
[FeedViewType.SocialMedia]: SocialMediaItemStateLess,
|
||||
[FeedViewType.Pictures]: PictureItemStateLess,
|
||||
[FeedViewType.Videos]: VideoItemStateLess,
|
||||
[FeedViewType.Audios]: AudioItemStateLess,
|
||||
[FeedViewType.Notifications]: NotificationItemStateLess,
|
||||
}
|
||||
|
||||
export const getStatelessItemComponentByView = (view: FeedViewType) => {
|
||||
return StatelessItemMap[view] || ArticleItemStateLess
|
||||
}
|
||||
|
||||
const SkeletonItemMap = {
|
||||
[FeedViewType.Articles]: ArticleItemSkeleton,
|
||||
[FeedViewType.SocialMedia]: SocialMediaItemSkeleton,
|
||||
|
||||
@@ -13,7 +13,7 @@ export function NotificationItem({ entryId, entryPreview, translation }: Univers
|
||||
|
||||
export function NotificationItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
return (
|
||||
<div className="relative w-full max-w-lg">
|
||||
<div className="relative w-full max-w-lg select-none">
|
||||
<div className="group relative flex py-4 pl-3 pr-2">
|
||||
<FeedIcon feed={feed} fallback />
|
||||
|
||||
@@ -31,9 +31,9 @@ export function NotificationItemStateLess({ entry, feed }: EntryItemStatelessPro
|
||||
}
|
||||
|
||||
export const NotificationItemSkeleton = (
|
||||
<div className="relative w-full max-w-lg">
|
||||
<div className="relative w-full max-w-lg select-none">
|
||||
<div className="group relative flex py-4 pl-3 pr-2">
|
||||
<Skeleton className="mr-2 size-5 shrink-0 overflow-hidden rounded-sm " />
|
||||
<Skeleton className="mr-2 size-5 shrink-0 overflow-hidden rounded-sm" />
|
||||
<div className="-mt-0.5 line-clamp-4 flex-1 text-sm leading-tight">
|
||||
<div className="flex gap-1 text-[10px] font-bold text-zinc-400 dark:text-neutral-500">
|
||||
<Skeleton className="h-3 w-32 truncate " />
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Skeleton } from "@follow/components/ui/skeleton/index.jsx"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
|
||||
import { RelativeTime } from "~/components/ui/datetime"
|
||||
import { Media } from "~/components/ui/media"
|
||||
import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
import { FeedTitle } from "~/modules/feed/feed-title"
|
||||
|
||||
import type { EntryItemStatelessProps } from "../types"
|
||||
|
||||
export function PictureItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
return (
|
||||
<div className="relative mx-auto max-w-md select-none rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
<div className="p-1.5">
|
||||
<div className="relative flex gap-2 overflow-x-auto">
|
||||
<div
|
||||
className={cn(
|
||||
"relative flex w-full shrink-0 items-center overflow-hidden rounded-md",
|
||||
!entry.media?.[0].url && "aspect-square",
|
||||
)}
|
||||
>
|
||||
{entry.media?.[0] ? (
|
||||
<Media
|
||||
thumbnail
|
||||
src={entry.media[0].url}
|
||||
type={entry.media[0].type}
|
||||
previewImageUrl={entry.media[0].preview_image_url}
|
||||
className="size-full overflow-hidden"
|
||||
mediaContainerClassName={"w-auto h-auto rounded"}
|
||||
loading="lazy"
|
||||
proxy={{
|
||||
width: 0,
|
||||
height: 0,
|
||||
}}
|
||||
height={entry.media[0].height}
|
||||
width={entry.media[0].width}
|
||||
blurhash={entry.media[0].blurhash}
|
||||
/>
|
||||
) : (
|
||||
<Skeleton className="size-full overflow-hidden" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="relative flex-1 px-2 pb-3 pt-1 text-sm">
|
||||
<div className="relative mb-1 mt-1.5 truncate font-medium leading-none">
|
||||
{entry.title}
|
||||
</div>
|
||||
<div className="mt-1 flex items-center gap-1 truncate text-[13px]">
|
||||
<FeedIcon feed={feed} fallback className="size-4" />
|
||||
<FeedTitle feed={feed} />
|
||||
<span className="text-zinc-500">·</span>
|
||||
{!!entry.publishedAt && <RelativeTime date={entry.publishedAt} />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -12,22 +12,18 @@ import type { PropsWithChildren } from "react"
|
||||
import { memo, useContext, useEffect, useMemo, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { RelativeTime } from "~/components/ui/datetime"
|
||||
import { Media } from "~/components/ui/media"
|
||||
import { SwipeMedia } from "~/components/ui/media/SwipeMedia"
|
||||
import { ReactVirtuosoItemPlaceholder } from "~/components/ui/placeholder"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { filterSmallMedia } from "~/lib/utils"
|
||||
import { EntryContent } from "~/modules/entry-content"
|
||||
import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
import { FeedTitle } from "~/modules/feed/feed-title"
|
||||
import { useEntry } from "~/store/entry/hooks"
|
||||
import { useImageDimensions } from "~/store/image"
|
||||
|
||||
import { usePreviewMedia } from "../../../components/ui/media/hooks"
|
||||
import { EntryItemWrapper } from "../layouts/EntryItemWrapper"
|
||||
import { GridItem, GridItemFooter } from "../templates/grid-item-template"
|
||||
import type { EntryItemStatelessProps, UniversalItemProps } from "../types"
|
||||
import type { UniversalItemProps } from "../types"
|
||||
|
||||
export function PictureItem({ entryId, entryPreview, translation }: UniversalItemProps) {
|
||||
const entry = useEntry(entryId) || entryPreview
|
||||
@@ -46,7 +42,7 @@ export function PictureItem({ entryId, entryPreview, translation }: UniversalIte
|
||||
media={entry.entries.media}
|
||||
className={cn(
|
||||
"aspect-square",
|
||||
"w-full shrink-0 rounded-md",
|
||||
"w-full shrink-0 rounded-md [&_img]:rounded-md",
|
||||
isActive && "rounded-b-none",
|
||||
)}
|
||||
imgClassName="object-cover"
|
||||
@@ -205,57 +201,6 @@ const MasonryItemFixedDimensionWrapper = (
|
||||
)
|
||||
}
|
||||
|
||||
export function PictureItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
return (
|
||||
<div className="relative mx-auto max-w-md rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
<div className="p-1.5">
|
||||
<div className="relative flex gap-2 overflow-x-auto">
|
||||
<div
|
||||
className={cn(
|
||||
"relative flex w-full shrink-0 items-center overflow-hidden rounded-md",
|
||||
!entry.media?.[0].url && "aspect-square",
|
||||
)}
|
||||
>
|
||||
{entry.media?.[0] ? (
|
||||
<Media
|
||||
thumbnail
|
||||
src={entry.media[0].url}
|
||||
type={entry.media[0].type}
|
||||
previewImageUrl={entry.media[0].preview_image_url}
|
||||
className="size-full overflow-hidden"
|
||||
mediaContainerClassName={"w-auto h-auto rounded"}
|
||||
loading="lazy"
|
||||
proxy={{
|
||||
width: 0,
|
||||
height: 0,
|
||||
}}
|
||||
height={entry.media[0].height}
|
||||
width={entry.media[0].width}
|
||||
blurhash={entry.media[0].blurhash}
|
||||
/>
|
||||
) : (
|
||||
<Skeleton className="size-full overflow-hidden" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="relative flex-1 px-2 pb-3 pt-1 text-sm">
|
||||
<div className="relative mb-1 mt-1.5 truncate font-medium leading-none">
|
||||
{entry.title}
|
||||
</div>
|
||||
<div className="mt-1 flex items-center gap-1 truncate text-[13px]">
|
||||
<FeedIcon feed={feed} fallback className="size-4" />
|
||||
<FeedTitle feed={feed} />
|
||||
<span className="text-zinc-500">·</span>
|
||||
{!!entry.publishedAt && <RelativeTime date={entry.publishedAt} />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const PictureItemSkeleton = (
|
||||
<div className="relative max-w-md rounded-md bg-theme-background text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
|
||||
@@ -33,7 +33,7 @@ import { getEntry } from "~/store/entry"
|
||||
import { imageActions } from "~/store/image"
|
||||
|
||||
import { getMasonryColumnValue, setMasonryColumnValue, useMasonryColumnValue } from "../atoms"
|
||||
import { batchMarkRead } from "../hooks"
|
||||
import { batchMarkRead } from "../hooks/useEntryMarkReadHandler"
|
||||
import { PictureWaterFallItem } from "./picture-item"
|
||||
|
||||
// grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 @6xl:grid-cols-4 @7xl:grid-cols-5 px-4 gap-1.5
|
||||
@@ -262,7 +262,7 @@ const MasonryRender: React.ComponentType<
|
||||
}
|
||||
interface MasonryProps {
|
||||
data: string[]
|
||||
endReached: () => Promise<any>
|
||||
endReached: () => any
|
||||
hasNextPage: boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { AutoResizeHeight } from "@follow/components/ui/auto-resize-height/index.js"
|
||||
import { ActionButton } from "@follow/components/ui/button/index.js"
|
||||
import { Skeleton } from "@follow/components/ui/skeleton/index.jsx"
|
||||
import type { MediaModel } from "@follow/shared/hono"
|
||||
import { LRUCache } from "@follow/utils/lru-cache"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { atom } from "jotai"
|
||||
import { useLayoutEffect, useRef, useState } from "react"
|
||||
import { useLayoutEffect, useMemo, useRef, useState } from "react"
|
||||
|
||||
import { RelativeTime } from "~/components/ui/datetime"
|
||||
import { Media } from "~/components/ui/media"
|
||||
@@ -28,17 +32,25 @@ const socialMediaContentWidthAtom = atom(0)
|
||||
export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, translation }) => {
|
||||
const entry = useEntry(entryId) || entryPreview
|
||||
|
||||
const previewMedia = usePreviewMedia()
|
||||
const asRead = useAsRead(entry)
|
||||
const feed = useFeedById(entry?.feedId)
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const [showAction, setShowAction] = useState(false)
|
||||
|
||||
const isMobile = useMobile()
|
||||
const handleMouseEnter = useMemo(() => {
|
||||
return () => setShowAction(true)
|
||||
}, [])
|
||||
const handleMouseLeave = useMemo(() => {
|
||||
return () => setShowAction(false)
|
||||
}, [])
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (ref.current) {
|
||||
jotaiStore.set(socialMediaContentWidthAtom, ref.current.offsetWidth)
|
||||
}
|
||||
}, [ref.current])
|
||||
}, [])
|
||||
// NOTE: prevent 0 height element, react virtuoso will not stop render any more
|
||||
if (!entry || !feed) return <ReactVirtuosoItemPlaceholder />
|
||||
|
||||
@@ -50,19 +62,19 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
|
||||
|
||||
return (
|
||||
<div
|
||||
onMouseEnter={() => setShowAction(true)}
|
||||
onMouseLeave={() => setShowAction(false)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
className={cn(
|
||||
"relative flex px-2 py-6 lg:px-8",
|
||||
"relative flex px-5 py-4 lg:px-8",
|
||||
"group",
|
||||
!asRead &&
|
||||
"before:absolute before:left-2 before:top-10 before:block before:size-2 before:rounded-full before:bg-accent",
|
||||
"before:absolute before:left-1 before:top-8 before:block before:size-2 before:rounded-full before:bg-accent md:before:-left-2 lg:before:left-2",
|
||||
)}
|
||||
>
|
||||
<FeedIcon fallback feed={feed} entry={entry.entries} size={32} className="mt-1" />
|
||||
<div ref={ref} className="ml-2 min-w-0 flex-1">
|
||||
<div className="-mt-0.5 flex-1 text-sm">
|
||||
<div className="space-x-1 leading-6">
|
||||
<div className="select-none space-x-1 leading-6">
|
||||
<span className="inline-flex items-center gap-1 text-base font-semibold">
|
||||
<FeedTitle
|
||||
feed={feed}
|
||||
@@ -89,81 +101,21 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
|
||||
</span>
|
||||
</div>
|
||||
<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}
|
||||
target={translation?.content}
|
||||
isHTML
|
||||
/>
|
||||
<CollapsedSocialMediaItem entryId={entryId}>
|
||||
<EntryTranslation
|
||||
className="cursor-auto select-text text-sm leading-relaxed prose-blockquote:mt-0 [&_br:last-child]:hidden"
|
||||
source={content}
|
||||
target={translation?.content}
|
||||
isHTML
|
||||
/>
|
||||
</CollapsedSocialMediaItem>
|
||||
{!!entry.collections && <StarIcon className="absolute right-0 top-0" />}
|
||||
</div>
|
||||
</div>
|
||||
{!!media?.length && (
|
||||
<div className="mt-4 flex gap-[8px] overflow-x-auto pb-2">
|
||||
{media.map((media, i, mediaList) => {
|
||||
const style: Partial<{
|
||||
width: string
|
||||
height: string
|
||||
}> = {}
|
||||
const boundsWidth = jotaiStore.get(socialMediaContentWidthAtom)
|
||||
if (media.height && media.width) {
|
||||
// has 1 picture, max width is container width, but max height is less than window height: 2/3
|
||||
if (mediaList.length === 1) {
|
||||
style.width = `${boundsWidth}px`
|
||||
style.height = `${(boundsWidth * media.height) / media.width}px`
|
||||
if (Number.parseInt(style.height) > (window.innerHeight * 2) / 3) {
|
||||
style.height = `${(window.innerHeight * 2) / 3}px`
|
||||
style.width = `${(Number.parseInt(style.height) * media.width) / media.height}px`
|
||||
}
|
||||
}
|
||||
// has 2 pictures, max width is container half width, and - gap 8px
|
||||
else if (mediaList.length === 2) {
|
||||
style.width = `${(boundsWidth - 8) / 2}px`
|
||||
style.height = `${(((boundsWidth - 8) / 2) * media.height) / media.width}px`
|
||||
}
|
||||
// has over 2 pictures, max width is container 1/3 width
|
||||
else if (mediaList.length > 2) {
|
||||
style.width = `${boundsWidth / 3}px`
|
||||
style.height = `${((boundsWidth / 3) * media.height) / media.width}px`
|
||||
}
|
||||
}
|
||||
|
||||
const proxySize = {
|
||||
width: Number.parseInt(style.width || "0") * 2 || 0,
|
||||
height: Number.parseInt(style.height || "0") * 2 || 0,
|
||||
}
|
||||
return (
|
||||
<Media
|
||||
style={style}
|
||||
key={media.url}
|
||||
src={media.url}
|
||||
type={media.type}
|
||||
previewImageUrl={media.preview_image_url}
|
||||
blurhash={media.blurhash}
|
||||
className="size-28 shrink-0 data-[state=loading]:!bg-theme-placeholder-image"
|
||||
loading="lazy"
|
||||
proxy={proxySize}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
previewMedia(
|
||||
mediaList.map((m) => ({
|
||||
url: m.url,
|
||||
type: m.type,
|
||||
blurhash: m.blurhash,
|
||||
fallbackUrl:
|
||||
m.preview_image_url ?? getImageProxyUrl({ url: m.url, ...proxySize }),
|
||||
})),
|
||||
i,
|
||||
)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{!!media?.length && <SocialMediaGallery media={media} />}
|
||||
</div>
|
||||
|
||||
{showAction && (
|
||||
{showAction && !isMobile && (
|
||||
<div className={"absolute right-1 top-1.5"}>
|
||||
<ActionBar entryId={entryId} />
|
||||
</div>
|
||||
@@ -199,7 +151,7 @@ const ActionBar = ({ entryId }: { entryId: string }) => {
|
||||
|
||||
export function SocialMediaItemStateLess({ entry, feed }: EntryItemStatelessProps) {
|
||||
return (
|
||||
<div className="relative m-auto rounded-md text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative m-auto select-none rounded-md text-zinc-700 transition-colors dark:text-neutral-400">
|
||||
<div className="relative">
|
||||
<div className="group relative flex px-8 py-6">
|
||||
<FeedIcon className="mr-2 size-9" feed={feed} fallback />
|
||||
@@ -266,3 +218,190 @@ export const SocialMediaItemSkeleton = (
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
const SocialMediaGallery = ({ media }: { media: MediaModel[] }) => {
|
||||
const previewMedia = usePreviewMedia()
|
||||
|
||||
const isAllMediaSameRatio = useMemo(() => {
|
||||
let ratio = 0
|
||||
for (const m of media) {
|
||||
if (m.height && m.width) {
|
||||
const currentRatio = m.height / m.width
|
||||
if (ratio === 0) {
|
||||
ratio = currentRatio
|
||||
} else if (ratio !== currentRatio) {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}, [media])
|
||||
|
||||
// all media has same ratio, use horizontal layout
|
||||
if (isAllMediaSameRatio) {
|
||||
return (
|
||||
<div className="mt-4 flex gap-[8px] overflow-x-auto pb-2">
|
||||
{media.map((media, i, mediaList) => {
|
||||
const style: Partial<{
|
||||
width: string
|
||||
height: string
|
||||
}> = {}
|
||||
const boundsWidth = jotaiStore.get(socialMediaContentWidthAtom)
|
||||
if (media.height && media.width) {
|
||||
// has 1 picture, max width is container width, but max height is less than window height: 2/3
|
||||
if (mediaList.length === 1) {
|
||||
style.width = `${boundsWidth}px`
|
||||
style.height = `${(boundsWidth * media.height) / media.width}px`
|
||||
if (Number.parseInt(style.height) > (window.innerHeight * 2) / 3) {
|
||||
style.height = `${(window.innerHeight * 2) / 3}px`
|
||||
style.width = `${(Number.parseInt(style.height) * media.width) / media.height}px`
|
||||
}
|
||||
}
|
||||
// has 2 pictures, max width is container half width, and - gap 8px
|
||||
else if (mediaList.length === 2) {
|
||||
style.width = `${(boundsWidth - 8) / 2}px`
|
||||
style.height = `${(((boundsWidth - 8) / 2) * media.height) / media.width}px`
|
||||
}
|
||||
// has over 2 pictures, max width is container 1/3 width
|
||||
else if (mediaList.length > 2) {
|
||||
style.width = `${boundsWidth / 3}px`
|
||||
style.height = `${((boundsWidth / 3) * media.height) / media.width}px`
|
||||
}
|
||||
}
|
||||
|
||||
const proxySize = {
|
||||
width: Number.parseInt(style.width || "0") * 2 || 0,
|
||||
height: Number.parseInt(style.height || "0") * 2 || 0,
|
||||
}
|
||||
return (
|
||||
<Media
|
||||
style={style}
|
||||
key={media.url}
|
||||
src={media.url}
|
||||
type={media.type}
|
||||
previewImageUrl={media.preview_image_url}
|
||||
blurhash={media.blurhash}
|
||||
className="size-28 shrink-0 data-[state=loading]:!bg-theme-placeholder-image"
|
||||
loading="lazy"
|
||||
proxy={proxySize}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
previewMedia(
|
||||
mediaList.map((m) => ({
|
||||
url: m.url,
|
||||
type: m.type,
|
||||
blurhash: m.blurhash,
|
||||
fallbackUrl:
|
||||
m.preview_image_url ?? getImageProxyUrl({ url: m.url, ...proxySize }),
|
||||
})),
|
||||
i,
|
||||
)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// all media has different ratio, use grid layout
|
||||
return (
|
||||
<div className="mt-4">
|
||||
<div
|
||||
className={cn(
|
||||
"grid gap-2",
|
||||
media.length === 2 && "grid-cols-2",
|
||||
media.length === 3 && "grid-cols-2",
|
||||
media.length === 4 && "grid-cols-2",
|
||||
media.length >= 5 && "grid-cols-3",
|
||||
)}
|
||||
>
|
||||
{media.map((m, i) => {
|
||||
const proxySize = {
|
||||
width: 400,
|
||||
height: 400,
|
||||
}
|
||||
|
||||
const style = media.length === 3 && i === 2 ? { gridRow: "span 2" } : {}
|
||||
|
||||
return (
|
||||
<Media
|
||||
style={style}
|
||||
key={m.url}
|
||||
src={m.url}
|
||||
type={m.type}
|
||||
previewImageUrl={m.preview_image_url}
|
||||
blurhash={m.blurhash}
|
||||
className="aspect-square w-full rounded object-cover"
|
||||
loading="lazy"
|
||||
proxy={proxySize}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
previewMedia(
|
||||
media.map((m) => ({
|
||||
url: m.url,
|
||||
type: m.type,
|
||||
blurhash: m.blurhash,
|
||||
fallbackUrl:
|
||||
m.preview_image_url ?? getImageProxyUrl({ url: m.url, ...proxySize }),
|
||||
})),
|
||||
i,
|
||||
)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const collapsedHeight = 300
|
||||
const collapsedItemCache = new LRUCache<string, boolean>(100)
|
||||
const CollapsedSocialMediaItem: Component<{
|
||||
entryId: string
|
||||
}> = ({ children, entryId }) => {
|
||||
const [isOverflow, setIsOverflow] = useState(false)
|
||||
const [isShowMore, setIsShowMore] = useState(() => collapsedItemCache.get(entryId) ?? false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
useLayoutEffect(() => {
|
||||
if (ref.current) {
|
||||
setIsOverflow(ref.current.scrollHeight > collapsedHeight)
|
||||
}
|
||||
}, [children])
|
||||
|
||||
return (
|
||||
<AutoResizeHeight spring className="relative">
|
||||
<div
|
||||
className={cn(
|
||||
"relative",
|
||||
!isShowMore && "max-h-[300px] overflow-hidden",
|
||||
isShowMore && "h-auto",
|
||||
!isShowMore && isOverflow && "mask-b-2xl",
|
||||
)}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
{isOverflow && !isShowMore && (
|
||||
<div className="absolute inset-x-0 -bottom-2 flex select-none justify-center py-2 duration-200">
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setIsShowMore(true)
|
||||
collapsedItemCache.put(entryId, true)
|
||||
}}
|
||||
aria-hidden
|
||||
className="flex items-center justify-center text-xs duration-200 hover:text-foreground"
|
||||
>
|
||||
<i className="i-mingcute-arrow-to-down-line" />
|
||||
<span className="ml-2">Show more</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</AutoResizeHeight>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,21 +1,10 @@
|
||||
import { ActionButton } from "@follow/components/ui/button/index.js"
|
||||
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { throttle } from "es-toolkit/compat"
|
||||
import { m } from "framer-motion"
|
||||
import type { FC, PropsWithChildren } from "react"
|
||||
import {
|
||||
cloneElement,
|
||||
memo,
|
||||
useCallback,
|
||||
useId,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react"
|
||||
import { cloneElement, memo, useCallback, useId, useMemo, useRef, useState } from "react"
|
||||
import { Trans } from "react-i18next"
|
||||
import { useDebounceCallback } from "usehooks-ts"
|
||||
|
||||
@@ -27,6 +16,20 @@ import { isListSubscription } from "~/store/subscription"
|
||||
|
||||
import { useMarkAllByRoute } from "../hooks/useMarkAll"
|
||||
|
||||
interface DateItemInnerProps {
|
||||
date: Date
|
||||
startTime: number
|
||||
endTime: number
|
||||
className?: string
|
||||
Wrapper?: FC<PropsWithChildren>
|
||||
isSticky?: boolean
|
||||
}
|
||||
|
||||
type DateItemProps = Pick<DateItemInnerProps, "isSticky"> & {
|
||||
view: FeedViewType
|
||||
date: string
|
||||
className?: string
|
||||
}
|
||||
const useParseDate = (date: string) =>
|
||||
useMemo(() => {
|
||||
const dateObj = new Date(date)
|
||||
@@ -37,61 +40,40 @@ const useParseDate = (date: string) =>
|
||||
}
|
||||
}, [date])
|
||||
|
||||
const useSticky = () => {
|
||||
const $scroller = useScrollViewElement()
|
||||
const itemRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
const [isSticky, setIsSticky] = useState(false)
|
||||
useLayoutEffect(() => {
|
||||
const $ = itemRef.current?.parentElement
|
||||
if (!$) return
|
||||
const handler = throttle((e: HTMLElementEventMap["scroll"]) => {
|
||||
if ((e.target as HTMLElement).scrollTop < 10) {
|
||||
setIsSticky(false)
|
||||
return
|
||||
}
|
||||
const isSticky = $.offsetTop <= 0
|
||||
|
||||
setIsSticky(isSticky)
|
||||
}, 16)
|
||||
$scroller?.addEventListener("scroll", handler)
|
||||
return () => {
|
||||
$scroller?.removeEventListener("scroll", handler)
|
||||
}
|
||||
}, [$scroller])
|
||||
|
||||
return { isSticky, itemRef }
|
||||
}
|
||||
export const DateItem = memo(({ date, view }: { date: string; view: FeedViewType }) => {
|
||||
const className = cn(
|
||||
"lg:pt-2",
|
||||
`relative -mx-2 flex items-center gap-1 bg-background px-4 text-base font-bold text-zinc-800 dark:text-neutral-400`,
|
||||
)
|
||||
export const DateItem = memo(({ date, view, isSticky }: DateItemProps) => {
|
||||
const className = tw`relative flex items-center text-sm lg:text-base gap-1 bg-background px-4 font-bold text-zinc-800 dark:text-neutral-400 h-7`
|
||||
|
||||
if (view === FeedViewType.SocialMedia) {
|
||||
return <SocialMediaDateItem date={date} className={className} />
|
||||
return <SocialMediaDateItem date={date} className={className} isSticky={isSticky} />
|
||||
}
|
||||
return <UniversalDateItem date={date} className={className} />
|
||||
return <UniversalDateItem date={date} className={className} isSticky={isSticky} />
|
||||
})
|
||||
const UniversalDateItem = ({ date, className }: { date: string; className?: string }) => {
|
||||
const UniversalDateItem = ({ date, className, isSticky }: Omit<DateItemProps, "view">) => {
|
||||
const { startOfDay, endOfDay, dateObj } = useParseDate(date)
|
||||
|
||||
return (
|
||||
<DateItemInner className={className} date={dateObj} startTime={startOfDay} endTime={endOfDay} />
|
||||
<DateItemInner
|
||||
className={className}
|
||||
date={dateObj}
|
||||
startTime={startOfDay}
|
||||
endTime={endOfDay}
|
||||
isSticky={isSticky}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const DateItemInner: FC<{
|
||||
date: Date
|
||||
startTime: number
|
||||
endTime: number
|
||||
className?: string
|
||||
Wrapper?: FC<PropsWithChildren>
|
||||
}> = ({ date, endTime, startTime, className, Wrapper }) => {
|
||||
const DateItemInner: FC<DateItemInnerProps> = ({
|
||||
date,
|
||||
endTime,
|
||||
startTime,
|
||||
className,
|
||||
Wrapper,
|
||||
isSticky,
|
||||
}) => {
|
||||
const rid = useId()
|
||||
const RelativeElement = useMemo(
|
||||
() => (
|
||||
<m.span key="b" layout layoutId={rid}>
|
||||
<m.span key="b" className="inline-flex items-center" layout layoutId={rid}>
|
||||
<RelativeDay date={date} />
|
||||
</m.span>
|
||||
),
|
||||
@@ -102,7 +84,6 @@ const DateItemInner: FC<{
|
||||
startTime,
|
||||
endTime,
|
||||
})
|
||||
const { isSticky, itemRef } = useSticky()
|
||||
|
||||
const [confirmMark, setConfirmMark] = useState(false)
|
||||
const removeConfirm = useDebounceCallback(
|
||||
@@ -125,7 +106,6 @@ const DateItemInner: FC<{
|
||||
return (
|
||||
<div
|
||||
className={cn(className, isSticky && "border-b")}
|
||||
ref={itemRef}
|
||||
onClick={stopPropagation}
|
||||
onMouseEnter={removeConfirm.cancel}
|
||||
onMouseLeave={removeConfirm}
|
||||
@@ -179,7 +159,15 @@ const DateItemInner: FC<{
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const SocialMediaDateItem = ({ date, className }: { date: string; className?: string }) => {
|
||||
const SocialMediaDateItem = ({
|
||||
date,
|
||||
className,
|
||||
isSticky,
|
||||
}: {
|
||||
date: string
|
||||
className?: string
|
||||
isSticky?: boolean
|
||||
}) => {
|
||||
const { startOfDay, endOfDay, dateObj } = useParseDate(date)
|
||||
|
||||
return (
|
||||
@@ -187,7 +175,9 @@ const SocialMediaDateItem = ({ date, className }: { date: string; className?: st
|
||||
// @ts-expect-error
|
||||
Wrapper={useCallback(
|
||||
({ children }) => (
|
||||
<div className="m-auto flex w-[645px] gap-3 pl-5 text-lg">{children}</div>
|
||||
<div className="m-auto flex w-[645px] max-w-full select-none gap-3 pl-5 text-base lg:text-lg">
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
[],
|
||||
)}
|
||||
@@ -195,6 +185,7 @@ const SocialMediaDateItem = ({ date, className }: { date: string; className?: st
|
||||
date={dateObj}
|
||||
startTime={startOfDay}
|
||||
endTime={endOfDay}
|
||||
isSticky={isSticky}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { LRUCache } from "@follow/utils/lru-cache"
|
||||
import type { Range, VirtualItem, Virtualizer } from "@tanstack/react-virtual"
|
||||
import { useVirtualizer } from "@tanstack/react-virtual"
|
||||
import type { FC } from "react"
|
||||
import { Fragment, startTransition, useEffect, useMemo, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { setUISetting, useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { getEntry } from "~/store/entry"
|
||||
|
||||
import { EntryItem, EntryItemSkeleton } from "./item"
|
||||
import { PictureMasonry } from "./Items/picture-masonry"
|
||||
import type { EntryListProps } from "./list"
|
||||
|
||||
export const EntryColumnGrid: FC<EntryListProps> = (props) => {
|
||||
const { entriesIds, feedId, hasNextPage, view, fetchNextPage } = props
|
||||
|
||||
const isMobile = useMobile()
|
||||
const masonry = useUISettingKey("pictureViewMasonry") || isMobile
|
||||
|
||||
const filterNoImage = useUISettingKey("pictureViewFilterNoImage")
|
||||
const nextData = useMemo(() => {
|
||||
if (filterNoImage) {
|
||||
return entriesIds.filter((entryId) => {
|
||||
const entry = getEntry(entryId)
|
||||
return entry?.entries.media?.length && entry.entries.media.length > 0
|
||||
})
|
||||
}
|
||||
return entriesIds
|
||||
}, [entriesIds, filterNoImage])
|
||||
const { t } = useTranslation()
|
||||
if (nextData.length === 0 && entriesIds.length > 0) {
|
||||
return (
|
||||
<div className="center absolute inset-x-0 inset-y-12 -translate-y-12 flex-col gap-5">
|
||||
<i className="i-mgc-photo-album-cute-fi size-12" />
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{t("entry_column.filtered_content_tip")}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
onClick={() => {
|
||||
setUISetting("pictureViewFilterNoImage", false)
|
||||
}}
|
||||
>
|
||||
Show All
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const hasFilteredContent = nextData.length < entriesIds.length
|
||||
|
||||
const FilteredContentTip = hasFilteredContent && !hasNextPage && (
|
||||
<div className="center mb-6 flex flex-col gap-5">
|
||||
<i className="i-mgc-photo-album-cute-fi size-12" />
|
||||
<div>{t("entry_column.filtered_content_tip_2")}</div>
|
||||
|
||||
<Button
|
||||
onClick={() => {
|
||||
setUISetting("pictureViewFilterNoImage", false)
|
||||
}}
|
||||
>
|
||||
Show All
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
|
||||
if (masonry && view === FeedViewType.Pictures) {
|
||||
return (
|
||||
<>
|
||||
<PictureMasonry
|
||||
key={feedId}
|
||||
hasNextPage={hasNextPage}
|
||||
endReached={fetchNextPage}
|
||||
data={entriesIds}
|
||||
/>
|
||||
|
||||
{FilteredContentTip}
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<VirtualGrid {...props} />
|
||||
{FilteredContentTip}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const capacity = 3 * 2
|
||||
const offsetCache = new LRUCache<string, number>(capacity)
|
||||
const measurementsCache = new LRUCache<string, VirtualItem[]>(capacity)
|
||||
|
||||
const ratioMap = {
|
||||
[FeedViewType.Pictures]: 1,
|
||||
// 16:9
|
||||
[FeedViewType.Videos]: 16 / 9,
|
||||
}
|
||||
const VirtualGrid: FC<EntryListProps> = (props) => {
|
||||
const { entriesIds, feedId, onRangeChange, fetchNextPage, view, Footer, hasNextPage, listRef } =
|
||||
props
|
||||
const scrollRef = useScrollViewElement()
|
||||
|
||||
const [containerWidth, setContainerWidth] = useState(0)
|
||||
|
||||
const columns = useMemo(() => {
|
||||
if (!scrollRef) return [0]
|
||||
|
||||
const width = containerWidth
|
||||
const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize)
|
||||
let columnCount = 1 // default (grid-cols-1)
|
||||
if (width >= 32 * rem) columnCount = 2 // @lg (32rem)
|
||||
if (width >= 48 * rem) columnCount = 3 // @3xl (48rem)
|
||||
if (width >= 72 * rem) columnCount = 4 // @6xl (72rem)
|
||||
if (width >= 80 * rem) columnCount = 5 // @8xl (80rem)
|
||||
|
||||
return Array.from({ length: columnCount }).fill(width / columnCount) as number[]
|
||||
}, [containerWidth, scrollRef])
|
||||
|
||||
// Calculate rows based on entries
|
||||
const rows = useMemo(() => {
|
||||
const itemsPerRow = columns.length
|
||||
const rowCount = Math.ceil(entriesIds.length / itemsPerRow)
|
||||
return Array.from({ length: rowCount }, (_, index) =>
|
||||
entriesIds.slice(index * itemsPerRow, (index + 1) * itemsPerRow),
|
||||
)
|
||||
}, [entriesIds, columns.length])
|
||||
|
||||
const rowCacheKey = `${feedId}-row`
|
||||
const columnCacheKey = `${feedId}-column`
|
||||
|
||||
const columnVirtualizer = useVirtualizer({
|
||||
horizontal: true,
|
||||
count: columns.length,
|
||||
getScrollElement: () => scrollRef,
|
||||
estimateSize: (i) => columns[i],
|
||||
overscan: 5,
|
||||
initialOffset: offsetCache.get(columnCacheKey) ?? 0,
|
||||
initialMeasurementsCache: measurementsCache.get(columnCacheKey) ?? [],
|
||||
onChange: useTypeScriptHappyCallback(
|
||||
(virtualizer: Virtualizer<HTMLElement, Element>) => {
|
||||
if (!virtualizer.isScrolling) {
|
||||
measurementsCache.put(columnCacheKey, virtualizer.measurementsCache)
|
||||
offsetCache.put(columnCacheKey, virtualizer.scrollOffset ?? 0)
|
||||
}
|
||||
},
|
||||
[columnCacheKey],
|
||||
),
|
||||
})
|
||||
|
||||
const rowVirtualizer = useVirtualizer({
|
||||
count: rows.length + 1,
|
||||
estimateSize: () => {
|
||||
return columns[0] / ratioMap[view] + 58
|
||||
},
|
||||
overscan: 5,
|
||||
gap: 8,
|
||||
getScrollElement: () => scrollRef,
|
||||
initialOffset: offsetCache.get(rowCacheKey) ?? 0,
|
||||
initialMeasurementsCache: measurementsCache.get(rowCacheKey) ?? [],
|
||||
paddingEnd: 32,
|
||||
onChange: useTypeScriptHappyCallback(
|
||||
(virtualizer: Virtualizer<HTMLElement, Element>) => {
|
||||
if (!virtualizer.isScrolling) {
|
||||
measurementsCache.put(rowCacheKey, virtualizer.measurementsCache)
|
||||
offsetCache.put(rowCacheKey, virtualizer.scrollOffset ?? 0)
|
||||
}
|
||||
|
||||
if (!virtualizer.range) return
|
||||
|
||||
const columnCount = columns.length
|
||||
const realRange = {
|
||||
startIndex: virtualizer.range.startIndex * columnCount,
|
||||
endIndex: virtualizer.range.endIndex * columnCount,
|
||||
}
|
||||
|
||||
onRangeChange?.(realRange as Range)
|
||||
},
|
||||
[rowCacheKey, columns.length],
|
||||
),
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!listRef) return
|
||||
listRef.current = rowVirtualizer
|
||||
}, [rowVirtualizer, listRef])
|
||||
|
||||
useEffect(() => {
|
||||
if (!scrollRef) return
|
||||
const handler = () => {
|
||||
const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize)
|
||||
const width = scrollRef.clientWidth - 2 * rem
|
||||
setContainerWidth(width)
|
||||
|
||||
rowVirtualizer.measure()
|
||||
columnVirtualizer.measure()
|
||||
}
|
||||
|
||||
const observer = new ResizeObserver(handler)
|
||||
observer.observe(scrollRef)
|
||||
return () => {
|
||||
observer.disconnect()
|
||||
}
|
||||
}, [columnVirtualizer, rowVirtualizer, scrollRef])
|
||||
|
||||
const virtualItems = rowVirtualizer.getVirtualItems()
|
||||
useEffect(() => {
|
||||
const lastItem = virtualItems.at(-1)
|
||||
|
||||
if (!lastItem) {
|
||||
return
|
||||
}
|
||||
|
||||
const isPlaceholderRow = lastItem.index === rows.length
|
||||
|
||||
if (isPlaceholderRow && hasNextPage) {
|
||||
fetchNextPage()
|
||||
}
|
||||
}, [fetchNextPage, hasNextPage, rows.length, virtualItems])
|
||||
|
||||
const [ready, setReady] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
startTransition(() => {
|
||||
setReady(true)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div
|
||||
className="relative mx-4"
|
||||
style={{
|
||||
height: `${rowVirtualizer.getTotalSize()}px`,
|
||||
width: `${columnVirtualizer.getTotalSize()}px`,
|
||||
}}
|
||||
>
|
||||
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
||||
const isLoaderRow = virtualRow.key === rows.length
|
||||
if (isLoaderRow && ready) {
|
||||
return (
|
||||
<div
|
||||
key={virtualRow.key}
|
||||
className="absolute left-0 top-0 w-full"
|
||||
style={{
|
||||
height: `${virtualRow.size}px`,
|
||||
transform: `translateY(${virtualRow.start}px)`,
|
||||
}}
|
||||
>
|
||||
{Footer ? typeof Footer === "function" ? <Footer /> : Footer : null}
|
||||
{hasNextPage && <EntryItemSkeleton view={view} count={6} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Fragment key={virtualRow.key}>
|
||||
{columnVirtualizer.getVirtualItems().map((virtualColumn) => (
|
||||
<div
|
||||
ref={columnVirtualizer.measureElement}
|
||||
key={virtualColumn.index}
|
||||
className="absolute left-0 top-0"
|
||||
style={{
|
||||
height: `${virtualRow.size}px`,
|
||||
width: `${virtualColumn.size}px`,
|
||||
|
||||
transform: `translateX(${virtualColumn.start}px) translateY(${virtualRow.start}px)`,
|
||||
}}
|
||||
>
|
||||
{ready && (
|
||||
<EntryItem
|
||||
entryId={entriesIds[virtualRow.index * columns.length + virtualColumn.index]}
|
||||
view={view}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</Fragment>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+7
-78
@@ -1,11 +1,9 @@
|
||||
import { views } from "@follow/constants"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import type { ListRange } from "react-virtuoso"
|
||||
import { useDebounceCallback } from "usehooks-ts"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { useRouteParams, useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { useRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { apiClient, apiFetch } from "~/lib/api-fetch"
|
||||
import { entries, useEntries } from "~/queries/entries"
|
||||
@@ -13,46 +11,7 @@ import { entryActions, getEntry, useEntryIdsByFeedIdOrView } from "~/store/entry
|
||||
import { useFolderFeedsByFeedId } from "~/store/subscription"
|
||||
import { feedUnreadActions } from "~/store/unread"
|
||||
|
||||
export const useEntryMarkReadHandler = (entriesIds: string[]) => {
|
||||
const renderAsRead = useGeneralSettingKey("renderMarkUnread")
|
||||
const scrollMarkUnread = useGeneralSettingKey("scrollMarkUnread")
|
||||
const feedView = useRouteParamsSelector((params) => params.view)
|
||||
|
||||
const handleMarkReadInRange = useDebounceCallback(
|
||||
async ({ startIndex }: ListRange) => {
|
||||
const idSlice = entriesIds?.slice(0, startIndex)
|
||||
|
||||
if (!idSlice) return
|
||||
batchMarkRead(idSlice)
|
||||
},
|
||||
500,
|
||||
{ leading: false },
|
||||
)
|
||||
|
||||
const handleRenderAsRead = useCallback(
|
||||
async ({ startIndex, endIndex }: ListRange, enabled?: boolean) => {
|
||||
if (!enabled) return
|
||||
const idSlice = entriesIds?.slice(startIndex, endIndex)
|
||||
|
||||
if (!idSlice) return
|
||||
batchMarkRead(idSlice)
|
||||
},
|
||||
[entriesIds],
|
||||
)
|
||||
|
||||
return useMemo(() => {
|
||||
if (views[feedView].wideMode && renderAsRead) {
|
||||
return handleRenderAsRead
|
||||
}
|
||||
|
||||
if (scrollMarkUnread) {
|
||||
return handleMarkReadInRange
|
||||
}
|
||||
return
|
||||
}, [feedView, handleMarkReadInRange, handleRenderAsRead, renderAsRead, scrollMarkUnread])
|
||||
}
|
||||
const anyString = [] as string[]
|
||||
|
||||
export const useEntriesByView = ({
|
||||
onReset,
|
||||
isArchived,
|
||||
@@ -144,20 +103,11 @@ export const useEntriesByView = ({
|
||||
}
|
||||
if (!isFetchingFirstPage) {
|
||||
prevEntryIdsRef.current = entryIds
|
||||
setMergedEntries({ ...mergedEntries, [view]: entryIds })
|
||||
|
||||
onReset?.()
|
||||
}
|
||||
}, [isFetchingFirstPage, isArchived])
|
||||
|
||||
const [mergedEntries, setMergedEntries] = useState<Record<number, string[]>>({
|
||||
0: [],
|
||||
1: [],
|
||||
2: [],
|
||||
3: [],
|
||||
4: [],
|
||||
5: [],
|
||||
})
|
||||
|
||||
const entryIdsAsDeps = entryIds.toString()
|
||||
|
||||
useEffect(() => {
|
||||
@@ -166,23 +116,22 @@ export const useEntriesByView = ({
|
||||
useEffect(() => {
|
||||
if (!prevEntryIdsRef.current) {
|
||||
prevEntryIdsRef.current = entryIds
|
||||
setMergedEntries({ ...mergedEntries, [view]: entryIds })
|
||||
|
||||
return
|
||||
}
|
||||
// merge the new entries with the old entries, and unique them
|
||||
const nextIds = [...new Set([...prevEntryIdsRef.current, ...entryIds])]
|
||||
prevEntryIdsRef.current = nextIds
|
||||
setMergedEntries({ ...mergedEntries, [view]: entryIds })
|
||||
}, [entryIdsAsDeps])
|
||||
|
||||
const sortEntries = useMemo(
|
||||
() =>
|
||||
isCollection
|
||||
? sortEntriesIdByStarAt(mergedEntries[view])
|
||||
? sortEntriesIdByStarAt(entryIds)
|
||||
: listId
|
||||
? sortEntriesIdByEntryInsertedAt(mergedEntries[view])
|
||||
: sortEntriesIdByEntryPublishedAt(mergedEntries[view]),
|
||||
[isCollection, listId, mergedEntries, view],
|
||||
? sortEntriesIdByEntryInsertedAt(entryIds)
|
||||
: sortEntriesIdByEntryPublishedAt(entryIds),
|
||||
[entryIds, isCollection, listId],
|
||||
)
|
||||
|
||||
const groupByDate = useGeneralSettingKey("groupByDate")
|
||||
@@ -230,26 +179,6 @@ export const useEntriesByView = ({
|
||||
}
|
||||
}
|
||||
|
||||
export function batchMarkRead(ids: string[]) {
|
||||
const batchLikeIds = [] as [string, string][]
|
||||
const entriesId2Map = entryActions.getFlattenMapEntries()
|
||||
for (const id of ids) {
|
||||
const entry = entriesId2Map[id]
|
||||
|
||||
if (!entry) continue
|
||||
const isRead = entry.read
|
||||
if (!isRead) {
|
||||
batchLikeIds.push([entry.feedId, id])
|
||||
}
|
||||
}
|
||||
|
||||
if (batchLikeIds.length > 0) {
|
||||
for (const [feedId, id] of batchLikeIds) {
|
||||
entryActions.markRead({ feedId, entryId: id, read: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sortEntriesIdByEntryPublishedAt(entries: string[]) {
|
||||
const entriesId2Map = entryActions.getFlattenMapEntries()
|
||||
return entries
|
||||
@@ -0,0 +1,61 @@
|
||||
import { views } from "@follow/constants"
|
||||
import type { Range } from "@tanstack/react-virtual"
|
||||
import { useMemo } from "react"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { entryActions } from "~/store/entry"
|
||||
|
||||
export const useEntryMarkReadHandler = (entriesIds: string[]) => {
|
||||
const renderAsRead = useGeneralSettingKey("renderMarkUnread")
|
||||
const scrollMarkUnread = useGeneralSettingKey("scrollMarkUnread")
|
||||
const feedView = useRouteParamsSelector((params) => params.view)
|
||||
|
||||
const indexKeyIsCalled = useMemo(() => new Set<string>(), [entriesIds])
|
||||
|
||||
const handleRenderAsRead = useEventCallback(
|
||||
({ startIndex, endIndex }: Range, enabled?: boolean) => {
|
||||
if (!enabled) return
|
||||
if (indexKeyIsCalled.has(`${startIndex}-${endIndex}`)) return
|
||||
const idSlice = entriesIds?.slice(startIndex, endIndex)
|
||||
|
||||
indexKeyIsCalled.add(`${startIndex}-${endIndex}`)
|
||||
|
||||
if (!idSlice) return
|
||||
|
||||
batchMarkRead(idSlice)
|
||||
},
|
||||
)
|
||||
|
||||
return useMemo(() => {
|
||||
if (views[feedView].wideMode && renderAsRead) {
|
||||
return handleRenderAsRead
|
||||
}
|
||||
|
||||
if (scrollMarkUnread) {
|
||||
return handleRenderAsRead
|
||||
}
|
||||
return
|
||||
}, [feedView, handleRenderAsRead, renderAsRead, scrollMarkUnread])
|
||||
}
|
||||
|
||||
export function batchMarkRead(ids: string[]) {
|
||||
const batchLikeIds = [] as [string, string][]
|
||||
const entriesId2Map = entryActions.getFlattenMapEntries()
|
||||
for (const id of ids) {
|
||||
const entry = entriesId2Map[id]
|
||||
|
||||
if (!entry) continue
|
||||
const isRead = entry.read
|
||||
if (!isRead) {
|
||||
batchLikeIds.push([entry.feedId, id])
|
||||
}
|
||||
}
|
||||
|
||||
if (batchLikeIds.length > 0) {
|
||||
for (const [feedId, id] of batchLikeIds) {
|
||||
entryActions.markRead({ feedId, entryId: id, read: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +1,40 @@
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { FeedViewType, views } from "@follow/constants"
|
||||
import { useTitle, useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { useTitle } from "@follow/hooks"
|
||||
import type { FeedModel } from "@follow/models/types"
|
||||
import { isBizId } from "@follow/utils/utils"
|
||||
import type { FunctionComponent } from "react"
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import type { Range, Virtualizer } from "@tanstack/react-virtual"
|
||||
import { memo, useCallback, useEffect, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import type {
|
||||
ScrollSeekConfiguration,
|
||||
VirtuosoGridProps,
|
||||
VirtuosoHandle,
|
||||
VirtuosoProps,
|
||||
} from "react-virtuoso"
|
||||
import { VirtuosoGrid } from "react-virtuoso"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { setUISetting, useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { FeedFoundCanBeFollowError } from "~/components/errors/FeedFoundCanBeFollowErrorFallback"
|
||||
import { FeedNotFound } from "~/components/errors/FeedNotFound"
|
||||
import { ReactVirtuosoItemPlaceholder } from "~/components/ui/placeholder"
|
||||
import { FEED_COLLECTION_LIST, ROUTE_FEED_PENDING } from "~/constants"
|
||||
import { ENTRY_COLUMN_LIST_SCROLLER_ID } from "~/constants/dom"
|
||||
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
|
||||
import { useRouteParams, useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { useFeed } from "~/queries/feed"
|
||||
import { entryActions, getEntry, useEntry } from "~/store/entry"
|
||||
import { entryActions, useEntry } from "~/store/entry"
|
||||
import { useFeedById, useFeedHeaderTitle } from "~/store/feed"
|
||||
import { useSubscriptionByFeedId } from "~/store/subscription"
|
||||
|
||||
import { useEntriesByView, useEntryMarkReadHandler } from "./hooks"
|
||||
import { EntryColumnGrid } from "./grid"
|
||||
import { useEntriesByView } from "./hooks/useEntriesByView"
|
||||
import { useSnapEntryIdList } from "./hooks/useEntryIdListSnap"
|
||||
import { EntryItem, EntryItemSkeleton } from "./item"
|
||||
import { PictureMasonry } from "./Items/picture-masonry"
|
||||
import { useEntryMarkReadHandler } from "./hooks/useEntryMarkReadHandler"
|
||||
import { EntryListHeader } from "./layouts/EntryListHeader"
|
||||
import { EntryEmptyList, EntryList, EntryListContent } from "./lists"
|
||||
import { girdClassNames } from "./styles"
|
||||
import { EntryEmptyList, EntryList } from "./list"
|
||||
import { EntryColumnWrapper } from "./wrapper"
|
||||
|
||||
const scrollSeekConfiguration: ScrollSeekConfiguration = {
|
||||
enter: (velocity) => Math.abs(velocity) > 1000,
|
||||
exit: (velocity) => Math.abs(velocity) < 1000,
|
||||
}
|
||||
|
||||
const prevScrollTopMap = {}
|
||||
|
||||
export type VirtuosoComponentProps = { onlyShowArchivedButton: boolean }
|
||||
type VirtuosoComponentPropsContext = { context?: VirtuosoComponentProps }
|
||||
|
||||
function EntryColumnImpl() {
|
||||
const { t } = useTranslation()
|
||||
const virtuosoRef = useRef<VirtuosoHandle>(null)
|
||||
const [isArchived, setIsArchived] = useState(false)
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
const listRef = useRef<Virtualizer<HTMLElement, Element>>()
|
||||
const entries = useEntriesByView({
|
||||
onReset: useCallback(() => {
|
||||
virtuosoRef.current?.scrollTo({
|
||||
top: 0,
|
||||
})
|
||||
listRef.current?.scrollToIndex(0)
|
||||
}, []),
|
||||
isArchived,
|
||||
})
|
||||
@@ -128,79 +105,54 @@ function EntryColumnImpl() {
|
||||
}
|
||||
}, [shouldLoadArchivedEntries])
|
||||
|
||||
const scrollRef = useRef<HTMLDivElement>(null)
|
||||
const handleScroll = useCallback(() => {
|
||||
if (!isInteracted.current) {
|
||||
isInteracted.current = true
|
||||
}
|
||||
|
||||
const handleScroll = useCallback(
|
||||
(e: React.UIEvent<HTMLDivElement>) => {
|
||||
if (!isInteracted.current) {
|
||||
isInteracted.current = true
|
||||
}
|
||||
const { scrollTop } = e.currentTarget
|
||||
if (!routeFeedId) return
|
||||
|
||||
if (!routeFeedId) return
|
||||
prevScrollTopMap[routeFeedId] = scrollTop
|
||||
},
|
||||
[routeFeedId],
|
||||
)
|
||||
|
||||
const virtuosoOptions = {
|
||||
components: {
|
||||
List: EntryListContent,
|
||||
Footer: useCallback(
|
||||
({ context }: VirtuosoComponentPropsContext) => {
|
||||
if (!isFetchingNextPage) {
|
||||
if (showArchivedButton) {
|
||||
return (
|
||||
<div className="flex justify-center py-4">
|
||||
<Button variant="outline" onClick={() => setIsArchived(true)}>
|
||||
{t("words.load_archived_entries")}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
if (context?.onlyShowArchivedButton) return null
|
||||
return (
|
||||
<EntryItemSkeleton view={view} count={entries.data?.pages?.[0].data?.length || 20} />
|
||||
)
|
||||
}
|
||||
},
|
||||
[isFetchingNextPage, showArchivedButton, t, view, entries.data?.pages],
|
||||
),
|
||||
ScrollSeekPlaceholder: useCallback(() => <EntryItemSkeleton view={view} count={1} />, [view]),
|
||||
},
|
||||
scrollSeekConfiguration,
|
||||
rangeChanged: (...args: any[]) => {
|
||||
handleMarkReadInRange &&
|
||||
// @ts-expect-error
|
||||
handleMarkReadInRange(...args, isInteracted.current)
|
||||
},
|
||||
customScrollParent: scrollRef.current!,
|
||||
initialScrollTop: prevScrollTopMap[routeFeedId || ""] || 0,
|
||||
|
||||
endReached: useCallback(async () => {
|
||||
if (!entries.isFetchingNextPage && entries.hasNextPage) {
|
||||
await entries.fetchNextPage()
|
||||
}
|
||||
}, [entries]),
|
||||
data: entriesIds,
|
||||
onScroll: handleScroll,
|
||||
itemContent: useTypeScriptHappyCallback(
|
||||
(_, entryId) => {
|
||||
if (!entryId) return <ReactVirtuosoItemPlaceholder />
|
||||
|
||||
return <EntryItem key={entryId} entryId={entryId} view={view} />
|
||||
},
|
||||
[view],
|
||||
),
|
||||
} satisfies VirtuosoProps<string, VirtuosoComponentProps>
|
||||
const [first, second] = rangeQueueRef.current
|
||||
if (first && second && second.startIndex - first.startIndex > 0) {
|
||||
handleMarkReadInRange?.(
|
||||
{
|
||||
startIndex: first.startIndex,
|
||||
endIndex: second.startIndex,
|
||||
} as Range,
|
||||
isInteracted.current,
|
||||
)
|
||||
}
|
||||
}, [handleMarkReadInRange, routeFeedId])
|
||||
|
||||
const navigate = useNavigateEntry()
|
||||
const rangeQueueRef = useRef<Range[]>([])
|
||||
const isRefreshing = entries.isFetching && !entries.isFetchingNextPage
|
||||
const renderAsRead = useGeneralSettingKey("renderMarkUnread")
|
||||
const handleRangeChange = useCallback(
|
||||
(e: Range) => {
|
||||
rangeQueueRef.current.push(e)
|
||||
if (rangeQueueRef.current.length > 2) {
|
||||
rangeQueueRef.current.shift()
|
||||
}
|
||||
|
||||
if (!renderAsRead) return
|
||||
if (!views[view].wideMode) {
|
||||
return
|
||||
}
|
||||
// For gird, render as mark read logic
|
||||
handleMarkReadInRange?.(e, isInteracted.current)
|
||||
},
|
||||
[handleMarkReadInRange, renderAsRead, view],
|
||||
)
|
||||
|
||||
const fetchNextPage = useCallback(() => {
|
||||
if (entries.hasNextPage && !entries.isFetchingNextPage) {
|
||||
entries.fetchNextPage()
|
||||
}
|
||||
}, [entries])
|
||||
const isMobile = useMobile()
|
||||
|
||||
const ListComponent = views[view].gridMode ? EntryColumnGrid : EntryList
|
||||
return (
|
||||
<div
|
||||
data-hide-in-print
|
||||
@@ -214,10 +166,9 @@ function EntryColumnImpl() {
|
||||
})
|
||||
}
|
||||
>
|
||||
{virtuosoOptions.data.length === 0 &&
|
||||
!entries.isLoading &&
|
||||
!entries.error &&
|
||||
feed?.type === "feed" && <AddFeedHelper />}
|
||||
{entriesIds.length === 0 && !entries.isLoading && !entries.error && feed?.type === "feed" && (
|
||||
<AddFeedHelper />
|
||||
)}
|
||||
|
||||
<EntryListHeader
|
||||
refetch={entries.refetch}
|
||||
@@ -230,22 +181,31 @@ function EntryColumnImpl() {
|
||||
onPullToRefresh={entries.refetch}
|
||||
key={`${routeFeedId}-${view}`}
|
||||
>
|
||||
{virtuosoOptions.data.length === 0 && !showArchivedButton ? (
|
||||
{entriesIds.length === 0 && !showArchivedButton ? (
|
||||
entries.isLoading ? null : (
|
||||
<EntryEmptyList />
|
||||
)
|
||||
) : view && views[view].gridMode ? (
|
||||
<ListGird
|
||||
virtuosoOptions={virtuosoOptions}
|
||||
virtuosoRef={virtuosoRef}
|
||||
hasNextPage={entries.hasNextPage}
|
||||
/>
|
||||
) : (
|
||||
<EntryList
|
||||
{...virtuosoOptions}
|
||||
virtuosoRef={virtuosoRef}
|
||||
<ListComponent
|
||||
gap={view === FeedViewType.SocialMedia ? 10 : undefined}
|
||||
listRef={listRef}
|
||||
onRangeChange={handleRangeChange}
|
||||
hasNextPage={entries.hasNextPage}
|
||||
view={view}
|
||||
feedId={routeFeedId || ""}
|
||||
entriesIds={entriesIds}
|
||||
fetchNextPage={fetchNextPage}
|
||||
refetch={entries.refetch}
|
||||
groupCounts={groupedCounts}
|
||||
Footer={
|
||||
!isFetchingNextPage && showArchivedButton ? (
|
||||
<div className="flex justify-center py-4">
|
||||
<Button variant="outline" onClick={() => setIsArchived(true)}>
|
||||
{t("words.load_archived_entries")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</EntryColumnWrapper>
|
||||
@@ -253,105 +213,6 @@ function EntryColumnImpl() {
|
||||
)
|
||||
}
|
||||
|
||||
const ListGird = ({
|
||||
virtuosoOptions,
|
||||
virtuosoRef,
|
||||
hasNextPage,
|
||||
}: {
|
||||
virtuosoOptions: Omit<
|
||||
VirtuosoGridProps<string, VirtuosoComponentProps>,
|
||||
"data" | "endReached"
|
||||
> & {
|
||||
data: string[]
|
||||
endReached: () => Promise<any>
|
||||
}
|
||||
virtuosoRef: React.RefObject<VirtuosoHandle>
|
||||
hasNextPage: boolean
|
||||
}) => {
|
||||
const isMobile = useMobile()
|
||||
const masonry = useUISettingKey("pictureViewMasonry") || isMobile
|
||||
const view = useRouteParamsSelector((s) => s.view)
|
||||
const feedId = useRouteParamsSelector((s) => s.feedId)
|
||||
const filterNoImage = useUISettingKey("pictureViewFilterNoImage")
|
||||
const nextData = useMemo(() => {
|
||||
if (filterNoImage) {
|
||||
return virtuosoOptions.data.filter((entryId) => {
|
||||
const entry = getEntry(entryId)
|
||||
return entry?.entries.media?.length && entry.entries.media.length > 0
|
||||
})
|
||||
}
|
||||
return virtuosoOptions.data
|
||||
}, [virtuosoOptions.data, filterNoImage])
|
||||
const { t } = useTranslation()
|
||||
if (nextData.length === 0 && virtuosoOptions.data.length > 0) {
|
||||
return (
|
||||
<div className="center absolute inset-x-0 inset-y-12 -translate-y-12 flex-col gap-5">
|
||||
<i className="i-mgc-photo-album-cute-fi size-12" />
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{t("entry_column.filtered_content_tip")}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
onClick={() => {
|
||||
setUISetting("pictureViewFilterNoImage", false)
|
||||
}}
|
||||
>
|
||||
Show All
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const hasFilteredContent = nextData.length < virtuosoOptions.data.length
|
||||
|
||||
const FilteredContentTip = hasFilteredContent && !hasNextPage && (
|
||||
<div className="center mb-6 flex flex-col gap-5">
|
||||
<i className="i-mgc-photo-album-cute-fi size-12" />
|
||||
<div>{t("entry_column.filtered_content_tip_2")}</div>
|
||||
|
||||
<Button
|
||||
onClick={() => {
|
||||
setUISetting("pictureViewFilterNoImage", false)
|
||||
}}
|
||||
>
|
||||
Show All
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
|
||||
if (masonry && view === FeedViewType.Pictures) {
|
||||
return (
|
||||
<>
|
||||
<PictureMasonry
|
||||
key={feedId}
|
||||
hasNextPage={virtuosoOptions.totalCount! > virtuosoOptions.data.length}
|
||||
endReached={virtuosoOptions.endReached}
|
||||
data={nextData}
|
||||
/>
|
||||
|
||||
{virtuosoOptions.components?.Footer &&
|
||||
(virtuosoOptions.components.Footer as FunctionComponent<VirtuosoComponentPropsContext>)({
|
||||
context: { onlyShowArchivedButton: true },
|
||||
})}
|
||||
|
||||
{FilteredContentTip}
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<VirtuosoGrid
|
||||
id={ENTRY_COLUMN_LIST_SCROLLER_ID}
|
||||
listClassName={girdClassNames}
|
||||
{...virtuosoOptions}
|
||||
data={nextData}
|
||||
ref={virtuosoRef}
|
||||
/>
|
||||
{FilteredContentTip}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const AddFeedHelper = () => {
|
||||
const feedId = useRouteParamsSelector((s) => s.feedId)
|
||||
const feedQuery = useFeed({ id: feedId })
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import type { FC } from "react"
|
||||
import { memo } from "react"
|
||||
|
||||
import { ArticleItemStateLess } from "./Items/article-item"
|
||||
import { AudioItemStateLess } from "./Items/audio-item"
|
||||
import { NotificationItemStateLess } from "./Items/notification-item"
|
||||
import { PictureItemStateLess } from "./Items/picture-item-stateless"
|
||||
import { SocialMediaItemStateLess } from "./Items/social-media-item"
|
||||
import { VideoItemStateLess } from "./Items/video-item"
|
||||
import type { EntryItemStatelessProps } from "./types"
|
||||
|
||||
const StatelessItemMap = {
|
||||
[FeedViewType.Articles]: ArticleItemStateLess,
|
||||
[FeedViewType.SocialMedia]: SocialMediaItemStateLess,
|
||||
[FeedViewType.Pictures]: PictureItemStateLess,
|
||||
[FeedViewType.Videos]: VideoItemStateLess,
|
||||
[FeedViewType.Audios]: AudioItemStateLess,
|
||||
[FeedViewType.Notifications]: NotificationItemStateLess,
|
||||
}
|
||||
|
||||
const getStatelessItemComponentByView = (view: FeedViewType) => {
|
||||
return StatelessItemMap[view] || ArticleItemStateLess
|
||||
}
|
||||
|
||||
export const EntryItemStateless: FC<EntryItemStatelessProps> = memo((props) => {
|
||||
const Item = getStatelessItemComponentByView(props.view as FeedViewType)
|
||||
|
||||
return <Item {...props} />
|
||||
})
|
||||
@@ -11,14 +11,10 @@ import type { FlatEntryModel } from "~/store/entry"
|
||||
import { useEntry } from "~/store/entry/hooks"
|
||||
|
||||
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
|
||||
import {
|
||||
getItemComponentByView,
|
||||
getSkeletonItemComponentByView,
|
||||
getStatelessItemComponentByView,
|
||||
} from "./Items"
|
||||
import { getItemComponentByView, getSkeletonItemComponentByView } from "./Items"
|
||||
import { EntryItemWrapper } from "./layouts/EntryItemWrapper"
|
||||
import { girdClassNames } from "./styles"
|
||||
import type { EntryItemStatelessProps, EntryListItemFC } from "./types"
|
||||
import type { EntryListItemFC } from "./types"
|
||||
|
||||
interface EntryItemProps {
|
||||
entryId: string
|
||||
@@ -57,12 +53,6 @@ export const EntryItem: FC<EntryItemProps> = memo(({ entryId, view }) => {
|
||||
return <EntryItemImpl entry={entry} view={view} />
|
||||
})
|
||||
|
||||
export const EntryItemStateless: FC<EntryItemStatelessProps> = memo((props) => {
|
||||
const Item = getStatelessItemComponentByView(props.view as FeedViewType)
|
||||
|
||||
return <Item {...props} />
|
||||
})
|
||||
|
||||
const LoadingCircleFallback = (
|
||||
<div className="center mt-2">
|
||||
<LoadingCircle size="medium" />
|
||||
|
||||
@@ -59,11 +59,14 @@ export const EntryItemWrapper: FC<
|
||||
(e) => {
|
||||
e.stopPropagation()
|
||||
|
||||
if (!asRead) {
|
||||
entryActions.markRead({ feedId: entry.feedId, entryId: entry.entries.id, read: true })
|
||||
}
|
||||
navigate({
|
||||
entryId: entry.entries.id,
|
||||
})
|
||||
},
|
||||
[entry.entries.id, navigate],
|
||||
[asRead, entry.entries.id, entry.feedId, navigate],
|
||||
)
|
||||
const handleDoubleClick: React.MouseEventHandler<HTMLDivElement> = useCallback(
|
||||
() => entry.entries.url && window.open(entry.entries.url, "_blank"),
|
||||
@@ -74,6 +77,17 @@ export const EntryItemWrapper: FC<
|
||||
|
||||
const contextMenuProps = useContextMenu({
|
||||
onContextMenu: async (e) => {
|
||||
const $target = e.target as HTMLElement
|
||||
const selection = window.getSelection()
|
||||
if (selection) {
|
||||
const targetHasSelection =
|
||||
selection?.toString().length > 0 && $target.contains(selection?.anchorNode)
|
||||
if (targetHasSelection) {
|
||||
e.stopPropagation()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
e.preventDefault()
|
||||
setIsContextMenuOpen(true)
|
||||
await showContextMenu(
|
||||
@@ -123,7 +137,7 @@ export const EntryItemWrapper: FC<
|
||||
className={cn(
|
||||
"relative",
|
||||
asRead ? "text-zinc-700 dark:text-neutral-400" : "text-zinc-900 dark:text-neutral-300",
|
||||
views[view as FeedViewType]?.wideMode ? "rounded-md" : "-mx-2 px-2",
|
||||
views[view as FeedViewType]?.wideMode ? "rounded-md" : "px-2",
|
||||
"duration-200 hover:bg-theme-item-hover",
|
||||
(isActive || isContextMenuOpen) && "!bg-theme-item-active",
|
||||
itemClassName,
|
||||
|
||||
@@ -64,13 +64,14 @@ export const EntryListHeader: FC<EntryListHeaderProps> = ({ refetch, isRefreshin
|
||||
const feed = useFeedById(feedId)
|
||||
const isList = !!listId
|
||||
|
||||
const showQuickTimeline = useGeneralSettingKey("showQuickTimeline")
|
||||
const containerRef = React.useRef<HTMLDivElement>(null)
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={cn(
|
||||
"mb-2 flex w-full flex-col pr-4 transition-[padding] duration-300 ease-in-out",
|
||||
"flex w-full flex-col pb-2 pr-4 transition-[padding] duration-300 ease-in-out",
|
||||
"pl-6 pt-safe-offset-2.5",
|
||||
"bg-background",
|
||||
)}
|
||||
@@ -152,7 +153,7 @@ export const EntryListHeader: FC<EntryListHeaderProps> = ({ refetch, isRefreshin
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TimelineTabs />
|
||||
{showQuickTimeline && <TimelineTabs />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -160,7 +161,7 @@ export const EntryListHeader: FC<EntryListHeaderProps> = ({ refetch, isRefreshin
|
||||
const FollowSubscriptionButton = () => {
|
||||
return (
|
||||
<PresentSheet
|
||||
zIndex={90}
|
||||
zIndex={50}
|
||||
dismissableClassName="mb-0"
|
||||
triggerAsChild
|
||||
content={<FeedColumnMobile asWidget />}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useSubscriptionStore } from "~/store/subscription"
|
||||
|
||||
export const TimelineTabs = () => {
|
||||
const routerParams = useRouteParams()
|
||||
const { view, listId, inboxId } = routerParams
|
||||
const { view, listId, inboxId, folderName } = routerParams
|
||||
|
||||
const listsData = useSubscriptionStore(
|
||||
useCallback(
|
||||
@@ -22,16 +22,32 @@ export const TimelineTabs = () => {
|
||||
[view],
|
||||
),
|
||||
)
|
||||
const categoriesData = useSubscriptionStore(
|
||||
useCallback(
|
||||
(state) => {
|
||||
const categoryNames = new Set<string>()
|
||||
for (const subId of state.feedIdByView[view]) {
|
||||
const sub = state.data[subId]
|
||||
if (sub.category) {
|
||||
categoryNames.add(sub.category)
|
||||
}
|
||||
}
|
||||
return Array.from(categoryNames)
|
||||
},
|
||||
[view],
|
||||
),
|
||||
)
|
||||
const hasData = listsData.length > 0 || inboxData.length > 0
|
||||
|
||||
const timeline = listId || inboxId || ""
|
||||
const timeline = listId || inboxId || folderName || ""
|
||||
|
||||
const navigate = useNavigateEntry()
|
||||
if (!hasData) return null
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
className="-ml-3 -mr-4 mt-2 flex overflow-x-auto overflow-y-hidden scrollbar-none"
|
||||
variant={"rounded"}
|
||||
className="-ml-6 -mr-4 mt-2 flex overflow-x-auto overflow-y-hidden pl-3 scrollbar-none"
|
||||
value={timeline}
|
||||
onValueChange={(val) => {
|
||||
if (!val) {
|
||||
@@ -43,12 +59,12 @@ export const TimelineTabs = () => {
|
||||
}
|
||||
}}
|
||||
>
|
||||
<TabsList className="justify-start border-b-0">
|
||||
<TabsTrigger variant={"rounded"} className="p-0" value="">
|
||||
Yours
|
||||
<TabsList className="justify-start border-b-0 [&_span]:text-xs">
|
||||
<TabsTrigger className="p-0" value="">
|
||||
<span>Yours</span>
|
||||
</TabsTrigger>
|
||||
{listsData.map((s) => (
|
||||
<TabsTrigger variant={"rounded"} className="p-0" key={s.listId} value={s.listId!}>
|
||||
<TabsTrigger className="p-0" key={s.listId} value={s.listId!}>
|
||||
<ListItem
|
||||
listId={s.listId!}
|
||||
view={view}
|
||||
@@ -57,8 +73,24 @@ export const TimelineTabs = () => {
|
||||
/>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
{categoriesData.map((s) => (
|
||||
<TabsTrigger
|
||||
key={s}
|
||||
value={s}
|
||||
onClick={() => {
|
||||
navigate({
|
||||
folderName: s,
|
||||
})
|
||||
}}
|
||||
>
|
||||
<span className="flex h-5 items-center gap-1">
|
||||
<i className="i-mgc-folder-open-cute-re" />
|
||||
{s}
|
||||
</span>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
{inboxData.map((s) => (
|
||||
<TabsTrigger variant={"rounded"} key={s.inboxId} value={s.inboxId!}>
|
||||
<TabsTrigger key={s.inboxId} value={s.inboxId!}>
|
||||
<InboxItem
|
||||
inboxId={s.inboxId!}
|
||||
view={view}
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
import { EmptyIcon } from "@follow/components/icons/empty.jsx"
|
||||
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { LRUCache } from "@follow/utils/lru-cache"
|
||||
import type { Range, VirtualItem, Virtualizer } from "@tanstack/react-virtual"
|
||||
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual"
|
||||
import clsx from "clsx"
|
||||
import type { HTMLMotionProps } from "framer-motion"
|
||||
import type { FC, MutableRefObject, ReactNode } from "react"
|
||||
import {
|
||||
forwardRef,
|
||||
Fragment,
|
||||
memo,
|
||||
startTransition,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { useRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { useEntry } from "~/store/entry"
|
||||
import { isListSubscription } from "~/store/subscription"
|
||||
|
||||
import { DateItem } from "./components/DateItem"
|
||||
import { EntryColumnShortcutHandler } from "./EntryColumnShortcutHandler"
|
||||
import { EntryItem, EntryItemSkeleton } from "./item"
|
||||
|
||||
export const EntryListContent = forwardRef<HTMLDivElement>((props, ref) => (
|
||||
<div className="px-2" {...props} ref={ref} />
|
||||
))
|
||||
|
||||
export const EntryEmptyList = forwardRef<HTMLDivElement, HTMLMotionProps<"div">>((props, ref) => {
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<m.div
|
||||
className="absolute -mt-6 flex size-full grow flex-col items-center justify-center gap-2 text-zinc-400"
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
{unreadOnly ? (
|
||||
<>
|
||||
<i className="i-mgc-celebrate-cute-re -mt-11 text-3xl" />
|
||||
<span className="text-base">{t("entry_list.zero_unread")}</span>
|
||||
</>
|
||||
) : (
|
||||
<div className="flex -translate-y-6 flex-col items-center justify-center gap-2">
|
||||
<EmptyIcon className="size-[30px]" />
|
||||
<span className="text-base">{t("words.zero_items")}</span>
|
||||
</div>
|
||||
)}
|
||||
</m.div>
|
||||
)
|
||||
})
|
||||
|
||||
export type EntryListProps = {
|
||||
feedId: string
|
||||
entriesIds: string[]
|
||||
view: FeedViewType
|
||||
|
||||
hasNextPage: boolean
|
||||
fetchNextPage: () => void
|
||||
refetch: () => void
|
||||
|
||||
groupCounts?: number[]
|
||||
gap?: number
|
||||
|
||||
Footer?: FC | ReactNode
|
||||
|
||||
onRangeChange?: (range: Range) => void
|
||||
|
||||
listRef?: MutableRefObject<Virtualizer<HTMLElement, Element> | undefined>
|
||||
}
|
||||
|
||||
const capacity = 3
|
||||
const offsetCache = new LRUCache<string, number>(capacity)
|
||||
const measurementsCache = new LRUCache<string, VirtualItem[]>(capacity)
|
||||
export const EntryList: FC<EntryListProps> = memo(
|
||||
({
|
||||
feedId,
|
||||
view,
|
||||
entriesIds,
|
||||
fetchNextPage,
|
||||
refetch,
|
||||
hasNextPage,
|
||||
groupCounts,
|
||||
Footer,
|
||||
listRef,
|
||||
onRangeChange,
|
||||
gap,
|
||||
}) => {
|
||||
// Prevent scroll list move when press up/down key, the up/down key should be taken over by the shortcut key we defined.
|
||||
const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = useCallback((e) => {
|
||||
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
||||
e.preventDefault()
|
||||
}
|
||||
}, [])
|
||||
|
||||
const scrollRef = useScrollViewElement()
|
||||
|
||||
const stickyIndexes = useMemo(
|
||||
() =>
|
||||
groupCounts
|
||||
? groupCounts.reduce(
|
||||
(acc, count, index) => {
|
||||
acc[index + 1] = acc[index] + count
|
||||
return acc
|
||||
},
|
||||
[0],
|
||||
)
|
||||
: [],
|
||||
[groupCounts],
|
||||
)
|
||||
|
||||
const rowVirtualizer = useVirtualizer({
|
||||
count: entriesIds.length + 1,
|
||||
estimateSize: () => 112,
|
||||
overscan: 5,
|
||||
gap,
|
||||
getScrollElement: () => scrollRef,
|
||||
initialOffset: offsetCache.get(feedId) ?? 0,
|
||||
initialMeasurementsCache: measurementsCache.get(feedId) ?? [],
|
||||
onChange: useTypeScriptHappyCallback(
|
||||
(virtualizer: Virtualizer<HTMLElement, Element>) => {
|
||||
if (!virtualizer.isScrolling) {
|
||||
measurementsCache.put(feedId, virtualizer.measurementsCache)
|
||||
offsetCache.put(feedId, virtualizer.scrollOffset ?? 0)
|
||||
}
|
||||
|
||||
onRangeChange?.(virtualizer.range as Range)
|
||||
},
|
||||
[feedId],
|
||||
),
|
||||
rangeExtractor: useTypeScriptHappyCallback(
|
||||
(range: Range) => {
|
||||
activeStickyIndexRef.current =
|
||||
[...stickyIndexes].reverse().find((index) => range.startIndex >= index) ?? 0
|
||||
|
||||
const next = new Set([activeStickyIndexRef.current, ...defaultRangeExtractor(range)])
|
||||
|
||||
return [...next].sort((a, b) => a - b)
|
||||
},
|
||||
[stickyIndexes],
|
||||
),
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!listRef) return
|
||||
listRef.current = rowVirtualizer
|
||||
}, [rowVirtualizer, listRef])
|
||||
|
||||
const handleScrollTo = useEventCallback((index: number) => {
|
||||
rowVirtualizer.scrollToIndex(index)
|
||||
})
|
||||
|
||||
const activeStickyIndexRef = useRef(0)
|
||||
const isActiveSticky = (index: number) => activeStickyIndexRef.current === index
|
||||
const isSticky = (index: number) => stickyIndexes.includes(index)
|
||||
|
||||
const virtualItems = rowVirtualizer.getVirtualItems()
|
||||
useEffect(() => {
|
||||
const lastItem = virtualItems.at(-1)
|
||||
|
||||
if (!lastItem) {
|
||||
return
|
||||
}
|
||||
|
||||
const isPlaceholderRow = lastItem.index === entriesIds.length
|
||||
|
||||
if (isPlaceholderRow && hasNextPage) {
|
||||
fetchNextPage()
|
||||
}
|
||||
}, [entriesIds.length, fetchNextPage, hasNextPage, virtualItems])
|
||||
|
||||
const [isScrollTop, setIsScrollTop] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const $scrollRef = scrollRef
|
||||
if (!$scrollRef) return
|
||||
const handleScroll = () => {
|
||||
setIsScrollTop($scrollRef.scrollTop <= 0)
|
||||
}
|
||||
$scrollRef.addEventListener("scroll", handleScroll)
|
||||
|
||||
return () => {
|
||||
$scrollRef.removeEventListener("scroll", handleScroll)
|
||||
}
|
||||
}, [scrollRef])
|
||||
|
||||
const [ready, setReady] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
startTransition(() => {
|
||||
setReady(true)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
onKeyDown={handleKeyDown}
|
||||
className={"relative w-full select-text"}
|
||||
style={{
|
||||
height: `${rowVirtualizer.getTotalSize()}px`,
|
||||
}}
|
||||
>
|
||||
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
||||
if (!ready) return null
|
||||
// Last placeholder row
|
||||
const isLoaderRow = virtualRow.index === entriesIds.length
|
||||
|
||||
const transform = `translateY(${virtualRow.start}px)`
|
||||
if (isLoaderRow) {
|
||||
const Content = hasNextPage ? (
|
||||
<EntryItemSkeleton view={view} count={6} />
|
||||
) : Footer ? (
|
||||
typeof Footer === "function" ? (
|
||||
<Footer />
|
||||
) : (
|
||||
Footer
|
||||
)
|
||||
) : null
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={rowVirtualizer.measureElement}
|
||||
className="absolute left-0 top-0 w-full will-change-transform"
|
||||
key={virtualRow.key}
|
||||
style={{
|
||||
transform,
|
||||
}}
|
||||
>
|
||||
{Content}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const activeSticky = isActiveSticky(virtualRow.index)
|
||||
const sticky = isSticky(virtualRow.index)
|
||||
return (
|
||||
<Fragment key={virtualRow.key}>
|
||||
{sticky && (
|
||||
<div
|
||||
className={clsx(
|
||||
"bg-background",
|
||||
activeSticky
|
||||
? "sticky top-0 z-[1]"
|
||||
: "absolute left-0 top-0 z-[2] w-full will-change-transform",
|
||||
)}
|
||||
style={
|
||||
!activeSticky
|
||||
? {
|
||||
transform,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<EntryHeadDateItem
|
||||
entryId={entriesIds[virtualRow.index]}
|
||||
isSticky={!isScrollTop && activeSticky}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="absolute left-0 top-0 w-full will-change-transform"
|
||||
style={{
|
||||
transform,
|
||||
paddingTop: sticky ? "1.75rem" : undefined,
|
||||
}}
|
||||
ref={rowVirtualizer.measureElement}
|
||||
data-index={virtualRow.index}
|
||||
>
|
||||
<EntryItem entryId={entriesIds[virtualRow.index]} view={view} />
|
||||
</div>
|
||||
</Fragment>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<EntryColumnShortcutHandler
|
||||
refetch={refetch}
|
||||
data={entriesIds}
|
||||
handleScrollTo={handleScrollTo}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
const EntryHeadDateItem: FC<{
|
||||
entryId: string
|
||||
isSticky?: boolean
|
||||
}> = memo(({ entryId, isSticky }) => {
|
||||
const entry = useEntry(entryId)
|
||||
|
||||
const routeParams = useRouteParams()
|
||||
const { feedId, view } = routeParams
|
||||
const isList = isListSubscription(feedId)
|
||||
|
||||
if (!entry) return null
|
||||
const date = new Date(
|
||||
isList ? entry.entries.insertedAt : entry.entries.publishedAt,
|
||||
).toDateString()
|
||||
return <DateItem isSticky={isSticky} date={date} view={view} />
|
||||
})
|
||||
|
||||
EntryHeadDateItem.displayName = "EntryHeadDateItem"
|
||||
@@ -1,156 +0,0 @@
|
||||
import { EmptyIcon } from "@follow/components/icons/empty.jsx"
|
||||
import type { HTMLMotionProps } from "framer-motion"
|
||||
import type { DOMAttributes, FC } from "react"
|
||||
import { forwardRef, memo, useCallback } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import type { VirtuosoHandle, VirtuosoProps } from "react-virtuoso"
|
||||
import { GroupedVirtuoso, Virtuoso } from "react-virtuoso"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { ReactVirtuosoItemPlaceholder } from "~/components/ui/placeholder"
|
||||
import { ENTRY_COLUMN_LIST_SCROLLER_ID } from "~/constants/dom"
|
||||
import { useRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { useEntry } from "~/store/entry"
|
||||
import { isListSubscription } from "~/store/subscription"
|
||||
|
||||
import { DateItem } from "./components/DateItem"
|
||||
import { EntryColumnShortcutHandler } from "./EntryColumnShortcutHandler"
|
||||
import type { VirtuosoComponentProps } from "./index"
|
||||
|
||||
export const EntryListContent = forwardRef<HTMLDivElement>((props, ref) => (
|
||||
<div className="px-2" {...props} ref={ref} />
|
||||
))
|
||||
|
||||
export const EntryEmptyList = forwardRef<HTMLDivElement, HTMLMotionProps<"div">>((props, ref) => {
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<m.div
|
||||
className="absolute -mt-6 flex size-full grow flex-col items-center justify-center gap-2 text-zinc-400"
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
{unreadOnly ? (
|
||||
<>
|
||||
<i className="i-mgc-celebrate-cute-re -mt-11 text-3xl" />
|
||||
<span className="text-base">{t("entry_list.zero_unread")}</span>
|
||||
</>
|
||||
) : (
|
||||
<div className="flex -translate-y-6 flex-col items-center justify-center gap-2">
|
||||
<EmptyIcon className="size-[30px]" />
|
||||
<span className="text-base">{t("words.zero_items")}</span>
|
||||
</div>
|
||||
)}
|
||||
</m.div>
|
||||
)
|
||||
})
|
||||
|
||||
type BaseEntryProps = {
|
||||
virtuosoRef: React.RefObject<VirtuosoHandle>
|
||||
refetch: () => void
|
||||
}
|
||||
type EntryListProps = VirtuosoProps<string, VirtuosoComponentProps> & {
|
||||
groupCounts?: number[]
|
||||
} & BaseEntryProps
|
||||
export const EntryList: FC<EntryListProps> = memo(
|
||||
({
|
||||
virtuosoRef,
|
||||
refetch,
|
||||
groupCounts,
|
||||
|
||||
...virtuosoOptions
|
||||
}) => {
|
||||
// Prevent scroll list move when press up/down key, the up/down key should be taken over by the shortcut key we defined.
|
||||
const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = useCallback((e) => {
|
||||
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
||||
e.preventDefault()
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
{groupCounts ? (
|
||||
<EntryGroupedList
|
||||
groupCounts={groupCounts}
|
||||
onKeyDown={handleKeyDown}
|
||||
{...virtuosoOptions}
|
||||
ref={virtuosoRef}
|
||||
/>
|
||||
) : (
|
||||
<Virtuoso
|
||||
id={ENTRY_COLUMN_LIST_SCROLLER_ID}
|
||||
onKeyDown={handleKeyDown}
|
||||
{...virtuosoOptions}
|
||||
ref={virtuosoRef}
|
||||
/>
|
||||
)}
|
||||
<EntryColumnShortcutHandler
|
||||
refetch={refetch}
|
||||
data={virtuosoOptions.data!}
|
||||
virtuosoRef={virtuosoRef}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
const EntryGroupedList = forwardRef<
|
||||
VirtuosoHandle,
|
||||
VirtuosoProps<string, VirtuosoComponentProps> &
|
||||
DOMAttributes<HTMLDivElement> & {
|
||||
groupCounts: number[]
|
||||
}
|
||||
>(({ groupCounts, itemContent, onKeyDown, data, totalCount, ...virtuosoOptions }, ref) => (
|
||||
<GroupedVirtuoso
|
||||
id={ENTRY_COLUMN_LIST_SCROLLER_ID}
|
||||
className="z-0"
|
||||
ref={ref}
|
||||
groupContent={useCallback(
|
||||
(index: number) => {
|
||||
const entryId = getGetGroupDataIndex(groupCounts!, index, data!)
|
||||
|
||||
return <EntryHeadDateItem entryId={entryId} />
|
||||
},
|
||||
[groupCounts, data],
|
||||
)}
|
||||
groupCounts={groupCounts}
|
||||
onKeyDown={onKeyDown}
|
||||
{...virtuosoOptions}
|
||||
itemContent={useCallback(
|
||||
(index: number, _: number, __: string, c: any) => {
|
||||
const entryId = data![index]
|
||||
return itemContent?.(index, entryId, c)
|
||||
},
|
||||
[itemContent, JSON.stringify(data)],
|
||||
)}
|
||||
/>
|
||||
))
|
||||
|
||||
function getGetGroupDataIndex<T>(groupCounts: number[], groupIndex: number, data: readonly T[]) {
|
||||
// Get first grouped of data index
|
||||
//
|
||||
let sum = 0
|
||||
for (let i = 0; i < groupIndex; i++) {
|
||||
sum += groupCounts[i]
|
||||
}
|
||||
return data[sum]
|
||||
}
|
||||
|
||||
const EntryHeadDateItem: FC<{
|
||||
entryId: string
|
||||
}> = memo(({ entryId }) => {
|
||||
const entry = useEntry(entryId)
|
||||
|
||||
const routeParams = useRouteParams()
|
||||
const { feedId, view } = routeParams
|
||||
const isList = isListSubscription(feedId)
|
||||
|
||||
if (!entry) return <ReactVirtuosoItemPlaceholder />
|
||||
const date = new Date(
|
||||
isList ? entry.entries.insertedAt : entry.entries.publishedAt,
|
||||
).toDateString()
|
||||
return <DateItem date={date} view={view} />
|
||||
})
|
||||
|
||||
EntryHeadDateItem.displayName = "EntryHeadDateItem"
|
||||
@@ -1 +1 @@
|
||||
export const girdClassNames = tw`grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 @6xl:grid-cols-4 @7xl:grid-cols-5 px-4 gap-1.5`
|
||||
export const girdClassNames = tw`grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 @6xl:grid-cols-4 @7xl:grid-cols-5 gap-1.5`
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
|
||||
import { cn, isSafari } from "@follow/utils/utils"
|
||||
import { clsx, cn, isSafari } from "@follow/utils/utils"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { AudioPlayer, useAudioPlayerAtomSelector } from "~/atoms/player"
|
||||
import { useRealInWideMode, useUISettingKey } from "~/atoms/settings/ui"
|
||||
@@ -55,14 +56,37 @@ export function ListItem({
|
||||
const thumbnailRatio = useUISettingKey("thumbnailRatio")
|
||||
const rid = `list-item-${entryId}`
|
||||
|
||||
const lineClamp = useMemo(() => {
|
||||
const envIsSafari = isSafari()
|
||||
let lineClampTitle = settingWideMode ? 1 : 2
|
||||
let lineClampDescription = settingWideMode ? 1 : 2
|
||||
if (translation?.title) {
|
||||
lineClampTitle += settingWideMode ? 1 : 2
|
||||
}
|
||||
if (translation?.description) {
|
||||
lineClampDescription += settingWideMode ? 1 : 2
|
||||
}
|
||||
|
||||
// for tailwind
|
||||
// line-clamp-[1] line-clamp-[2] line-clamp-[3] line-clamp-[4] line-clamp-[5] line-clamp-[6] line-clamp-[7] line-clamp-[8]
|
||||
|
||||
// FIXME: Safari bug, not support line-clamp cross elements
|
||||
return {
|
||||
global: !envIsSafari ? `line-clamp-[${lineClampTitle + lineClampDescription}]` : "",
|
||||
title: envIsSafari ? `line-clamp-[${lineClampTitle}]` : "",
|
||||
description: envIsSafari ? `line-clamp-[${lineClampDescription}]` : "",
|
||||
}
|
||||
}, [translation?.title, translation?.description, settingWideMode])
|
||||
|
||||
// NOTE: prevent 0 height element, react virtuoso will not stop render any more
|
||||
if (!entry || !(feed || inbox)) return <ReactVirtuosoItemPlaceholder />
|
||||
|
||||
const displayTime = inInCollection ? entry.collections?.createdAt : entry.entries.publishedAt
|
||||
const envIsSafari = isSafari()
|
||||
|
||||
const related = feed || inbox
|
||||
|
||||
const hasAudio = entry.entries?.attachments?.[0].url
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
@@ -76,10 +100,8 @@ export function ListItem({
|
||||
<div
|
||||
className={cn(
|
||||
"-mt-0.5 flex-1 text-sm leading-tight",
|
||||
|
||||
// FIXME: Safari bug, not support line-clamp cross elements
|
||||
!envIsSafari && (settingWideMode ? "line-clamp-2" : "line-clamp-4"),
|
||||
withAudio && "max-w-[calc(100%-88px)]",
|
||||
lineClamp.global,
|
||||
withAudio && !!hasAudio && "max-w-[calc(100%-88px)]",
|
||||
)}
|
||||
>
|
||||
<div
|
||||
@@ -108,16 +130,13 @@ export function ListItem({
|
||||
>
|
||||
{entry.entries.title ? (
|
||||
<EntryTranslation
|
||||
useOverlay
|
||||
side="top"
|
||||
className={envIsSafari ? "line-clamp-2 break-all" : undefined}
|
||||
className={cn("break-all", lineClamp.title)}
|
||||
source={entry.entries.title}
|
||||
target={translation?.title}
|
||||
/>
|
||||
) : (
|
||||
<EntryTranslation
|
||||
useOverlay
|
||||
side="top"
|
||||
className={cn("break-all", lineClamp.description)}
|
||||
source={entry.entries.description}
|
||||
target={translation?.description}
|
||||
/>
|
||||
@@ -134,9 +153,7 @@ export function ListItem({
|
||||
)}
|
||||
>
|
||||
<EntryTranslation
|
||||
useOverlay
|
||||
side="top"
|
||||
className={envIsSafari ? "line-clamp-2 break-all" : undefined}
|
||||
className={cn("break-all", lineClamp.description)}
|
||||
source={entry.entries.description}
|
||||
target={translation?.description}
|
||||
/>
|
||||
@@ -144,17 +161,26 @@ export function ListItem({
|
||||
)}
|
||||
</div>
|
||||
|
||||
{withAudio && entry.entries?.attachments?.[0].url && (
|
||||
{withAudio && !!hasAudio && (
|
||||
<AudioCover
|
||||
entryId={entryId}
|
||||
src={entry.entries?.attachments?.[0].url}
|
||||
src={entry.entries!.attachments![0].url}
|
||||
durationInSeconds={Number.parseInt(
|
||||
String(entry.entries?.attachments?.[0].duration_in_seconds ?? 0),
|
||||
String(entry.entries!.attachments![0].duration_in_seconds ?? 0),
|
||||
10,
|
||||
)}
|
||||
feedIcon={
|
||||
<FeedIcon
|
||||
fallback={false}
|
||||
fallback={true}
|
||||
fallbackElement={
|
||||
<div
|
||||
className={clsx(
|
||||
"bg-theme-placeholder-image",
|
||||
settingWideMode ? "size-[65px]" : "size-[80px]",
|
||||
"rounded",
|
||||
)}
|
||||
/>
|
||||
}
|
||||
feed={feed || inbox}
|
||||
entry={entry.entries}
|
||||
size={settingWideMode ? 65 : 80}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
|
||||
import { tooltipStyle } from "@follow/components/ui/tooltip/styles.js"
|
||||
import { useMeasure } from "@follow/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as HoverCard from "@radix-ui/react-hover-card"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { HTML } from "~/components/ui/markdown/HTML"
|
||||
|
||||
@@ -10,83 +7,35 @@ export const EntryTranslation: Component<{
|
||||
source?: string | null
|
||||
target?: string
|
||||
showTranslation?: boolean
|
||||
|
||||
side?: "top" | "bottom"
|
||||
|
||||
useOverlay?: boolean
|
||||
isHTML?: boolean
|
||||
}> = ({ source, target, showTranslation, className, side, useOverlay, isHTML }) => {
|
||||
let nextTarget = target
|
||||
if (source === target) {
|
||||
nextTarget = undefined
|
||||
}
|
||||
}> = ({ source, target, showTranslation = true, className, isHTML }) => {
|
||||
const nextTarget = useMemo(() => {
|
||||
if (!target || !showTranslation || source === target) {
|
||||
return ""
|
||||
}
|
||||
return target
|
||||
}, [source, target, showTranslation])
|
||||
|
||||
const [ref, bounds] = useMeasure({ debounce: 60 })
|
||||
const content = useMemo(() => source + (nextTarget ? ` ${nextTarget}` : ""), [source, nextTarget])
|
||||
|
||||
if (!source) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (nextTarget && showTranslation) {
|
||||
return (
|
||||
<HoverCard.Root>
|
||||
<HoverCard.Trigger className={className} ref={ref}>
|
||||
<i className="i-mgc-translate-2-cute-re mr-1 align-middle" />
|
||||
{isHTML ? (
|
||||
<HTML as="div" className="align-middle" noMedia>
|
||||
{nextTarget}
|
||||
</HTML>
|
||||
) : (
|
||||
<span className="align-middle">{nextTarget}</span>
|
||||
)}
|
||||
</HoverCard.Trigger>
|
||||
<HoverCard.Portal>
|
||||
<HoverCard.Content
|
||||
className={cn(
|
||||
"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}
|
||||
side={side}
|
||||
sideOffset={useOverlay ? 0 : 12}
|
||||
>
|
||||
{useOverlay ? (
|
||||
<div className="absolute inset-x-0">
|
||||
<ScrollArea.ScrollArea
|
||||
mask
|
||||
rootClassName={cn(
|
||||
"shadow-modal rounded-xl border bg-background p-2",
|
||||
"group-data-[side=top]:top-0",
|
||||
"group-data-[side=bottom]:top-full",
|
||||
)}
|
||||
viewportClassName="max-h-[12ch]"
|
||||
>
|
||||
{isHTML ? (
|
||||
<HTML as="div" className="align-middle" noMedia>
|
||||
{source}
|
||||
</HTML>
|
||||
) : (
|
||||
<span className="align-middle">{source}</span>
|
||||
)}
|
||||
</ScrollArea.ScrollArea>
|
||||
</div>
|
||||
) : isHTML ? (
|
||||
<HTML as="div" className={cn(tooltipStyle.content)} noMedia>
|
||||
{source}
|
||||
</HTML>
|
||||
) : (
|
||||
<span className={cn(tooltipStyle.content)}>{source}</span>
|
||||
)}
|
||||
</HoverCard.Content>
|
||||
</HoverCard.Portal>
|
||||
</HoverCard.Root>
|
||||
)
|
||||
}
|
||||
return isHTML ? (
|
||||
<HTML as="div" className={cn("prose dark:prose-invert", className)} noMedia>
|
||||
{source}
|
||||
</HTML>
|
||||
) : (
|
||||
<div className={className}>{source}</div>
|
||||
return (
|
||||
<div>
|
||||
{nextTarget && <i className="i-mgc-translate-2-cute-re mr-1 align-middle" />}
|
||||
{isHTML ? (
|
||||
<HTML
|
||||
as="div"
|
||||
className={cn("prose inline align-middle dark:prose-invert", className)}
|
||||
noMedia
|
||||
>
|
||||
{content}
|
||||
</HTML>
|
||||
) : (
|
||||
<div className={cn("inline align-middle", className)}>{content}</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@ import { forwardRef } from "react"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
|
||||
import type { EntryColumnWrapperProps } from "./wrapper.shared"
|
||||
import { styles } from "./wrapper.shared"
|
||||
import { animationStyles, styles } from "./wrapper.shared"
|
||||
|
||||
export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperProps>(
|
||||
({ children, onScroll }, ref) => {
|
||||
const view = useRouteParamsSelector((state) => state.view)
|
||||
|
||||
return (
|
||||
<div className={clsx(styles, "mt-2")}>
|
||||
<div className={clsx(styles, animationStyles, "mt-2")}>
|
||||
<ScrollArea
|
||||
scrollbarClassName={!views[view].wideMode ? "w-[5px] p-0" : ""}
|
||||
mask={false}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ScrollElementContext } from "@follow/components/ui/scroll-area/ctx.js"
|
||||
import { FeedViewType, views } from "@follow/constants"
|
||||
import { views } from "@follow/constants"
|
||||
import { clsx } from "clsx"
|
||||
import { forwardRef, useState } from "react"
|
||||
|
||||
@@ -13,7 +13,7 @@ import { styles } from "./wrapper.shared"
|
||||
const noop = async () => {}
|
||||
|
||||
export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperProps>(
|
||||
({ children, onPullToRefresh }, ref) => {
|
||||
({ children, onPullToRefresh, onScroll }, ref) => {
|
||||
const view = useRouteParamsSelector((state) => state.view)
|
||||
|
||||
const [scrollElement, setScrollElement] = useState<HTMLElement | null>(null)
|
||||
@@ -25,8 +25,8 @@ export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperP
|
||||
<div
|
||||
className="h-full overflow-y-auto"
|
||||
ref={setScrollElement}
|
||||
// PictureMasonry do not have this id from VirtuosoGrid
|
||||
id={view === FeedViewType.Pictures ? ENTRY_COLUMN_LIST_SCROLLER_ID : undefined}
|
||||
id={ENTRY_COLUMN_LIST_SCROLLER_ID}
|
||||
onScroll={onScroll}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export const styles = tw`relative h-0 grow duration-200 ease-in-out animate-in fade-in slide-in-from-bottom-24 f-motion-reduce:fade-in-0 f-motion-reduce:slide-in-from-bottom-0`
|
||||
export const styles = tw`relative h-0 grow`
|
||||
export const animationStyles = tw`delay-100 duration-200 ease-in-out animate-in fade-in slide-in-from-bottom-24 f-motion-reduce:fade-in-0 f-motion-reduce:slide-in-from-bottom-0`
|
||||
|
||||
export interface EntryColumnWrapperProps extends ComponentType {
|
||||
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
import { ActionButton } from "@follow/components/ui/button/index.js"
|
||||
import { DividerVertical } from "@follow/components/ui/divider/index.js"
|
||||
import { FeedViewType, views } from "@follow/constants"
|
||||
import type { CombinedEntryModel } from "@follow/models/types"
|
||||
import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { noop } from "foxact/noop"
|
||||
import { useMemo, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { AudioPlayer, getAudioPlayerAtomValue } from "~/atoms/player"
|
||||
import {
|
||||
isInReadability,
|
||||
ReadabilityStatus,
|
||||
useEntryInReadabilityStatus,
|
||||
} from "~/atoms/readability"
|
||||
import { shortcuts } from "~/constants/shortcuts"
|
||||
import { useEntryReadabilityToggle } from "~/hooks/biz/useEntryActions"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
import { parseHtml } from "~/lib/parse-html"
|
||||
import type { FlatEntryModel } from "~/store/entry"
|
||||
import { useFeedById } from "~/store/feed"
|
||||
|
||||
export const ElectronAdditionActions = IN_ELECTRON
|
||||
? ({
|
||||
view = FeedViewType.Articles,
|
||||
entry,
|
||||
}: {
|
||||
view: FeedViewType
|
||||
entry?: FlatEntryModel | null
|
||||
}) => {
|
||||
const entryReadabilityStatus = useEntryInReadabilityStatus(entry?.entries.id)
|
||||
|
||||
const { t } = useTranslation()
|
||||
|
||||
const feed = useFeedById(entry?.feedId)
|
||||
|
||||
const populatedEntry = useMemo(() => {
|
||||
if (!entry) return null
|
||||
if (!feed) return null
|
||||
return {
|
||||
...entry,
|
||||
feeds: feed!,
|
||||
} as CombinedEntryModel
|
||||
}, [entry, feed])
|
||||
|
||||
const readabilityToggle = useEntryReadabilityToggle({
|
||||
id: populatedEntry?.entries.id ?? "",
|
||||
url: populatedEntry?.entries.url ?? "",
|
||||
})
|
||||
|
||||
const [ttsLoading, setTtsLoading] = useState(false)
|
||||
|
||||
if (!populatedEntry) return null
|
||||
|
||||
const items = [
|
||||
{
|
||||
key: "tts",
|
||||
name: t("entry_content.header.play_tts"),
|
||||
shortcut: shortcuts.entry.tts.key,
|
||||
className: ttsLoading ? "i-mgc-loading-3-cute-re animate-spin" : "i-mgc-voice-cute-re",
|
||||
|
||||
disabled: !populatedEntry.entries.content,
|
||||
onClick: async () => {
|
||||
if (ttsLoading) return
|
||||
if (!populatedEntry.entries.content) return
|
||||
setTtsLoading(true)
|
||||
if (getAudioPlayerAtomValue().entryId === populatedEntry.entries.id) {
|
||||
AudioPlayer.togglePlayAndPause()
|
||||
} else {
|
||||
const filePath = await tipcClient?.tts({
|
||||
id: populatedEntry.entries.id,
|
||||
text: (await parseHtml(populatedEntry.entries.content)).toText(),
|
||||
})
|
||||
if (filePath) {
|
||||
AudioPlayer.mount({
|
||||
type: "audio",
|
||||
entryId: populatedEntry.entries.id,
|
||||
src: `file://${filePath}`,
|
||||
currentTime: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
setTtsLoading(false)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: t("entry_content.header.readability"),
|
||||
className: cn(
|
||||
isInReadability(entryReadabilityStatus)
|
||||
? `i-mgc-docment-cute-fi`
|
||||
: `i-mgc-docment-cute-re`,
|
||||
entryReadabilityStatus === ReadabilityStatus.WAITING ? `animate-pulse` : "",
|
||||
),
|
||||
key: "readability",
|
||||
hide: views[view].wideMode || !populatedEntry.entries.url,
|
||||
active: isInReadability(entryReadabilityStatus),
|
||||
onClick: readabilityToggle,
|
||||
},
|
||||
]
|
||||
|
||||
if (items.length === 0) return null
|
||||
return (
|
||||
<>
|
||||
{items
|
||||
.filter((item) => !item.hide)
|
||||
.map((item) => (
|
||||
<ActionButton
|
||||
disabled={item.disabled}
|
||||
icon={<i className={item.className} />}
|
||||
active={item.active}
|
||||
shortcut={item.shortcut}
|
||||
onClick={item.onClick}
|
||||
tooltip={item.name}
|
||||
key={item.name}
|
||||
/>
|
||||
))}
|
||||
<DividerVertical className="mx-2 w-px" />
|
||||
</>
|
||||
)
|
||||
}
|
||||
: noop
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user