@wix/himalaya-cli 0.1782.0 → 0.1783.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/comments-v1/src/extensions.d.ts +68 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-comments.mjs +126 -18
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{d71e5b22a5ff1965fd887118ee8b2a74497b48a88f4459c9800569457e1fb547.bin → ef0d32c6770cbe9b695a3774a00fc3da19cd4f8655784f5cd935938054a34541.bin} +1 -1
- package/dist/browser-plane/sw.js +6 -6
- package/dist/cli.mjs +82 -48
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +4 -0
- package/guides/release-notes.md +31 -0
- package/guides/sdk-reference.json +62 -1
- package/package.json +2 -2
- package/templates/beauty-salon/config.ts +1 -1
- package/templates/beauty-salon/dev/index.ts +2684 -916
- package/templates/beauty-salon/l10n/ar.json +95 -36
- package/templates/beauty-salon/l10n/cs.json +95 -36
- package/templates/beauty-salon/l10n/da.json +95 -36
- package/templates/beauty-salon/l10n/de.json +95 -36
- package/templates/beauty-salon/l10n/el.json +95 -36
- package/templates/beauty-salon/l10n/en.json +71 -15
- package/templates/beauty-salon/l10n/es.json +95 -36
- package/templates/beauty-salon/l10n/fi.json +95 -36
- package/templates/beauty-salon/l10n/fr.json +95 -36
- package/templates/beauty-salon/l10n/he.json +78 -29
- package/templates/beauty-salon/l10n/hu.json +95 -36
- package/templates/beauty-salon/l10n/id.json +95 -36
- package/templates/beauty-salon/l10n/it.json +95 -36
- package/templates/beauty-salon/l10n/ja.json +95 -36
- package/templates/beauty-salon/l10n/ko.json +95 -36
- package/templates/beauty-salon/l10n/lt.json +95 -36
- package/templates/beauty-salon/l10n/nl.json +95 -36
- package/templates/beauty-salon/l10n/no.json +95 -36
- package/templates/beauty-salon/l10n/pl.json +95 -36
- package/templates/beauty-salon/l10n/pt.json +95 -36
- package/templates/beauty-salon/l10n/ru.json +95 -36
- package/templates/beauty-salon/l10n/sv.json +95 -36
- package/templates/beauty-salon/l10n/th.json +95 -36
- package/templates/beauty-salon/l10n/tr.json +95 -36
- package/templates/beauty-salon/l10n/uk.json +95 -36
- package/templates/beauty-salon/l10n/vi.json +95 -36
- package/templates/beauty-salon/l10n/zh.json +95 -36
- package/templates/beauty-salon/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/beauty-salon/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/beauty-salon/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/beauty-salon/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/branded-lite/config.ts +1 -1
- package/templates/branded-lite/dev/index.ts +2686 -930
- package/templates/branded-lite/l10n/ar.json +80 -41
- package/templates/branded-lite/l10n/cs.json +80 -41
- package/templates/branded-lite/l10n/da.json +80 -41
- package/templates/branded-lite/l10n/de.json +80 -41
- package/templates/branded-lite/l10n/el.json +80 -41
- package/templates/branded-lite/l10n/en.json +71 -20
- package/templates/branded-lite/l10n/es.json +80 -41
- package/templates/branded-lite/l10n/fi.json +80 -41
- package/templates/branded-lite/l10n/fr.json +80 -41
- package/templates/branded-lite/l10n/he.json +66 -33
- package/templates/branded-lite/l10n/hu.json +80 -41
- package/templates/branded-lite/l10n/id.json +80 -41
- package/templates/branded-lite/l10n/it.json +80 -41
- package/templates/branded-lite/l10n/ja.json +80 -41
- package/templates/branded-lite/l10n/ko.json +80 -41
- package/templates/branded-lite/l10n/lt.json +80 -41
- package/templates/branded-lite/l10n/nl.json +80 -41
- package/templates/branded-lite/l10n/no.json +80 -41
- package/templates/branded-lite/l10n/pl.json +80 -41
- package/templates/branded-lite/l10n/pt.json +80 -41
- package/templates/branded-lite/l10n/ru.json +80 -41
- package/templates/branded-lite/l10n/sv.json +80 -41
- package/templates/branded-lite/l10n/th.json +80 -41
- package/templates/branded-lite/l10n/tr.json +80 -41
- package/templates/branded-lite/l10n/uk.json +80 -41
- package/templates/branded-lite/l10n/vi.json +80 -41
- package/templates/branded-lite/l10n/zh.json +80 -41
- package/templates/branded-lite/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/branded-lite/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/branded-lite/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/community-club/config.ts +1 -1
- package/templates/community-club/dev/index.ts +2742 -974
- package/templates/community-club/l10n/ar.json +95 -36
- package/templates/community-club/l10n/cs.json +95 -36
- package/templates/community-club/l10n/da.json +95 -36
- package/templates/community-club/l10n/de.json +95 -36
- package/templates/community-club/l10n/el.json +95 -36
- package/templates/community-club/l10n/en.json +71 -15
- package/templates/community-club/l10n/es.json +95 -36
- package/templates/community-club/l10n/fi.json +95 -36
- package/templates/community-club/l10n/fr.json +95 -36
- package/templates/community-club/l10n/he.json +78 -29
- package/templates/community-club/l10n/hu.json +95 -36
- package/templates/community-club/l10n/id.json +95 -36
- package/templates/community-club/l10n/it.json +95 -36
- package/templates/community-club/l10n/ja.json +95 -36
- package/templates/community-club/l10n/ko.json +95 -36
- package/templates/community-club/l10n/lt.json +95 -36
- package/templates/community-club/l10n/nl.json +95 -36
- package/templates/community-club/l10n/no.json +95 -36
- package/templates/community-club/l10n/pl.json +95 -36
- package/templates/community-club/l10n/pt.json +95 -36
- package/templates/community-club/l10n/ru.json +95 -36
- package/templates/community-club/l10n/sv.json +95 -36
- package/templates/community-club/l10n/th.json +95 -36
- package/templates/community-club/l10n/tr.json +95 -36
- package/templates/community-club/l10n/uk.json +95 -36
- package/templates/community-club/l10n/vi.json +95 -36
- package/templates/community-club/l10n/zh.json +95 -36
- package/templates/community-club/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/community-club/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/community-club/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/community-club/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/events-meetups/config.ts +1 -1
- package/templates/events-meetups/dev/index.ts +2705 -937
- package/templates/events-meetups/l10n/ar.json +95 -36
- package/templates/events-meetups/l10n/cs.json +95 -36
- package/templates/events-meetups/l10n/da.json +95 -36
- package/templates/events-meetups/l10n/de.json +95 -36
- package/templates/events-meetups/l10n/el.json +95 -36
- package/templates/events-meetups/l10n/en.json +71 -15
- package/templates/events-meetups/l10n/es.json +95 -36
- package/templates/events-meetups/l10n/fi.json +95 -36
- package/templates/events-meetups/l10n/fr.json +95 -36
- package/templates/events-meetups/l10n/he.json +78 -29
- package/templates/events-meetups/l10n/hu.json +95 -36
- package/templates/events-meetups/l10n/id.json +95 -36
- package/templates/events-meetups/l10n/it.json +95 -36
- package/templates/events-meetups/l10n/ja.json +95 -36
- package/templates/events-meetups/l10n/ko.json +95 -36
- package/templates/events-meetups/l10n/lt.json +95 -36
- package/templates/events-meetups/l10n/nl.json +95 -36
- package/templates/events-meetups/l10n/no.json +95 -36
- package/templates/events-meetups/l10n/pl.json +95 -36
- package/templates/events-meetups/l10n/pt.json +95 -36
- package/templates/events-meetups/l10n/ru.json +95 -36
- package/templates/events-meetups/l10n/sv.json +95 -36
- package/templates/events-meetups/l10n/th.json +95 -36
- package/templates/events-meetups/l10n/tr.json +95 -36
- package/templates/events-meetups/l10n/uk.json +95 -36
- package/templates/events-meetups/l10n/vi.json +95 -36
- package/templates/events-meetups/l10n/zh.json +95 -36
- package/templates/events-meetups/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/events-meetups/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/events-meetups/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/events-meetups/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/gym-fitness/config.ts +1 -1
- package/templates/gym-fitness/dev/index.ts +2621 -853
- package/templates/gym-fitness/l10n/ar.json +95 -36
- package/templates/gym-fitness/l10n/cs.json +95 -36
- package/templates/gym-fitness/l10n/da.json +95 -36
- package/templates/gym-fitness/l10n/de.json +95 -36
- package/templates/gym-fitness/l10n/el.json +95 -36
- package/templates/gym-fitness/l10n/en.json +71 -15
- package/templates/gym-fitness/l10n/es.json +95 -36
- package/templates/gym-fitness/l10n/fi.json +95 -36
- package/templates/gym-fitness/l10n/fr.json +95 -36
- package/templates/gym-fitness/l10n/he.json +78 -29
- package/templates/gym-fitness/l10n/hu.json +95 -36
- package/templates/gym-fitness/l10n/id.json +95 -36
- package/templates/gym-fitness/l10n/it.json +95 -36
- package/templates/gym-fitness/l10n/ja.json +95 -36
- package/templates/gym-fitness/l10n/ko.json +95 -36
- package/templates/gym-fitness/l10n/lt.json +95 -36
- package/templates/gym-fitness/l10n/nl.json +95 -36
- package/templates/gym-fitness/l10n/no.json +95 -36
- package/templates/gym-fitness/l10n/pl.json +95 -36
- package/templates/gym-fitness/l10n/pt.json +95 -36
- package/templates/gym-fitness/l10n/ru.json +95 -36
- package/templates/gym-fitness/l10n/sv.json +95 -36
- package/templates/gym-fitness/l10n/th.json +95 -36
- package/templates/gym-fitness/l10n/tr.json +95 -36
- package/templates/gym-fitness/l10n/uk.json +95 -36
- package/templates/gym-fitness/l10n/vi.json +95 -36
- package/templates/gym-fitness/l10n/zh.json +95 -36
- package/templates/gym-fitness/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/gym-fitness/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/gym-fitness/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/gym-fitness/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/nonprofit-cause/config.ts +1 -1
- package/templates/nonprofit-cause/dev/index.ts +2704 -936
- package/templates/nonprofit-cause/l10n/ar.json +95 -36
- package/templates/nonprofit-cause/l10n/cs.json +95 -36
- package/templates/nonprofit-cause/l10n/da.json +95 -36
- package/templates/nonprofit-cause/l10n/de.json +95 -36
- package/templates/nonprofit-cause/l10n/el.json +95 -36
- package/templates/nonprofit-cause/l10n/en.json +71 -15
- package/templates/nonprofit-cause/l10n/es.json +95 -36
- package/templates/nonprofit-cause/l10n/fi.json +95 -36
- package/templates/nonprofit-cause/l10n/fr.json +95 -36
- package/templates/nonprofit-cause/l10n/he.json +78 -29
- package/templates/nonprofit-cause/l10n/hu.json +95 -36
- package/templates/nonprofit-cause/l10n/id.json +95 -36
- package/templates/nonprofit-cause/l10n/it.json +95 -36
- package/templates/nonprofit-cause/l10n/ja.json +95 -36
- package/templates/nonprofit-cause/l10n/ko.json +95 -36
- package/templates/nonprofit-cause/l10n/lt.json +95 -36
- package/templates/nonprofit-cause/l10n/nl.json +95 -36
- package/templates/nonprofit-cause/l10n/no.json +95 -36
- package/templates/nonprofit-cause/l10n/pl.json +95 -36
- package/templates/nonprofit-cause/l10n/pt.json +95 -36
- package/templates/nonprofit-cause/l10n/ru.json +95 -36
- package/templates/nonprofit-cause/l10n/sv.json +95 -36
- package/templates/nonprofit-cause/l10n/th.json +95 -36
- package/templates/nonprofit-cause/l10n/tr.json +95 -36
- package/templates/nonprofit-cause/l10n/uk.json +95 -36
- package/templates/nonprofit-cause/l10n/vi.json +95 -36
- package/templates/nonprofit-cause/l10n/zh.json +95 -36
- package/templates/nonprofit-cause/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/nonprofit-cause/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/nonprofit-cause/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/nonprofit-cause/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/podcast-creator/config.ts +1 -1
- package/templates/podcast-creator/dev/index.ts +2704 -936
- package/templates/podcast-creator/l10n/ar.json +95 -36
- package/templates/podcast-creator/l10n/cs.json +95 -36
- package/templates/podcast-creator/l10n/da.json +95 -36
- package/templates/podcast-creator/l10n/de.json +95 -36
- package/templates/podcast-creator/l10n/el.json +95 -36
- package/templates/podcast-creator/l10n/en.json +71 -15
- package/templates/podcast-creator/l10n/es.json +95 -36
- package/templates/podcast-creator/l10n/fi.json +95 -36
- package/templates/podcast-creator/l10n/fr.json +95 -36
- package/templates/podcast-creator/l10n/he.json +78 -29
- package/templates/podcast-creator/l10n/hu.json +95 -36
- package/templates/podcast-creator/l10n/id.json +95 -36
- package/templates/podcast-creator/l10n/it.json +95 -36
- package/templates/podcast-creator/l10n/ja.json +95 -36
- package/templates/podcast-creator/l10n/ko.json +95 -36
- package/templates/podcast-creator/l10n/lt.json +95 -36
- package/templates/podcast-creator/l10n/nl.json +95 -36
- package/templates/podcast-creator/l10n/no.json +95 -36
- package/templates/podcast-creator/l10n/pl.json +95 -36
- package/templates/podcast-creator/l10n/pt.json +95 -36
- package/templates/podcast-creator/l10n/ru.json +95 -36
- package/templates/podcast-creator/l10n/sv.json +95 -36
- package/templates/podcast-creator/l10n/th.json +95 -36
- package/templates/podcast-creator/l10n/tr.json +95 -36
- package/templates/podcast-creator/l10n/uk.json +95 -36
- package/templates/podcast-creator/l10n/vi.json +95 -36
- package/templates/podcast-creator/l10n/zh.json +95 -36
- package/templates/podcast-creator/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/podcast-creator/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/podcast-creator/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/podcast-creator/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/portfolio-creative/config.ts +1 -1
- package/templates/portfolio-creative/dev/index.ts +2499 -731
- package/templates/portfolio-creative/l10n/ar.json +95 -36
- package/templates/portfolio-creative/l10n/cs.json +95 -36
- package/templates/portfolio-creative/l10n/da.json +95 -36
- package/templates/portfolio-creative/l10n/de.json +95 -36
- package/templates/portfolio-creative/l10n/el.json +95 -36
- package/templates/portfolio-creative/l10n/en.json +71 -15
- package/templates/portfolio-creative/l10n/es.json +95 -36
- package/templates/portfolio-creative/l10n/fi.json +95 -36
- package/templates/portfolio-creative/l10n/fr.json +95 -36
- package/templates/portfolio-creative/l10n/he.json +78 -29
- package/templates/portfolio-creative/l10n/hu.json +95 -36
- package/templates/portfolio-creative/l10n/id.json +95 -36
- package/templates/portfolio-creative/l10n/it.json +95 -36
- package/templates/portfolio-creative/l10n/ja.json +95 -36
- package/templates/portfolio-creative/l10n/ko.json +95 -36
- package/templates/portfolio-creative/l10n/lt.json +95 -36
- package/templates/portfolio-creative/l10n/nl.json +95 -36
- package/templates/portfolio-creative/l10n/no.json +95 -36
- package/templates/portfolio-creative/l10n/pl.json +95 -36
- package/templates/portfolio-creative/l10n/pt.json +95 -36
- package/templates/portfolio-creative/l10n/ru.json +95 -36
- package/templates/portfolio-creative/l10n/sv.json +95 -36
- package/templates/portfolio-creative/l10n/th.json +95 -36
- package/templates/portfolio-creative/l10n/tr.json +95 -36
- package/templates/portfolio-creative/l10n/uk.json +95 -36
- package/templates/portfolio-creative/l10n/vi.json +95 -36
- package/templates/portfolio-creative/l10n/zh.json +95 -36
- package/templates/portfolio-creative/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/portfolio-creative/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/portfolio-creative/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/portfolio-creative/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/restaurant/config.ts +1 -1
- package/templates/restaurant/dev/index.ts +2528 -760
- package/templates/restaurant/l10n/ar.json +95 -36
- package/templates/restaurant/l10n/cs.json +95 -36
- package/templates/restaurant/l10n/da.json +95 -36
- package/templates/restaurant/l10n/de.json +95 -36
- package/templates/restaurant/l10n/el.json +95 -36
- package/templates/restaurant/l10n/en.json +71 -15
- package/templates/restaurant/l10n/es.json +95 -36
- package/templates/restaurant/l10n/fi.json +95 -36
- package/templates/restaurant/l10n/fr.json +95 -36
- package/templates/restaurant/l10n/he.json +78 -29
- package/templates/restaurant/l10n/hu.json +95 -36
- package/templates/restaurant/l10n/id.json +95 -36
- package/templates/restaurant/l10n/it.json +95 -36
- package/templates/restaurant/l10n/ja.json +95 -36
- package/templates/restaurant/l10n/ko.json +95 -36
- package/templates/restaurant/l10n/lt.json +95 -36
- package/templates/restaurant/l10n/nl.json +95 -36
- package/templates/restaurant/l10n/no.json +95 -36
- package/templates/restaurant/l10n/pl.json +95 -36
- package/templates/restaurant/l10n/pt.json +95 -36
- package/templates/restaurant/l10n/ru.json +95 -36
- package/templates/restaurant/l10n/sv.json +95 -36
- package/templates/restaurant/l10n/th.json +95 -36
- package/templates/restaurant/l10n/tr.json +95 -36
- package/templates/restaurant/l10n/uk.json +95 -36
- package/templates/restaurant/l10n/vi.json +95 -36
- package/templates/restaurant/l10n/zh.json +95 -36
- package/templates/restaurant/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/restaurant/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/restaurant/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/restaurant/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/retail-store/config.ts +1 -1
- package/templates/retail-store/dev/index.ts +2417 -661
- package/templates/retail-store/l10n/ar.json +95 -41
- package/templates/retail-store/l10n/cs.json +95 -41
- package/templates/retail-store/l10n/da.json +95 -41
- package/templates/retail-store/l10n/de.json +95 -41
- package/templates/retail-store/l10n/el.json +95 -41
- package/templates/retail-store/l10n/en.json +71 -20
- package/templates/retail-store/l10n/es.json +95 -41
- package/templates/retail-store/l10n/fi.json +95 -41
- package/templates/retail-store/l10n/fr.json +95 -41
- package/templates/retail-store/l10n/he.json +78 -33
- package/templates/retail-store/l10n/hu.json +95 -41
- package/templates/retail-store/l10n/id.json +95 -41
- package/templates/retail-store/l10n/it.json +95 -41
- package/templates/retail-store/l10n/ja.json +95 -41
- package/templates/retail-store/l10n/ko.json +95 -41
- package/templates/retail-store/l10n/lt.json +95 -41
- package/templates/retail-store/l10n/nl.json +95 -41
- package/templates/retail-store/l10n/no.json +95 -41
- package/templates/retail-store/l10n/pl.json +95 -41
- package/templates/retail-store/l10n/pt.json +95 -41
- package/templates/retail-store/l10n/ru.json +95 -41
- package/templates/retail-store/l10n/sv.json +95 -41
- package/templates/retail-store/l10n/th.json +95 -41
- package/templates/retail-store/l10n/tr.json +95 -41
- package/templates/retail-store/l10n/uk.json +95 -41
- package/templates/retail-store/l10n/vi.json +95 -41
- package/templates/retail-store/l10n/zh.json +95 -41
- package/templates/retail-store/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/retail-store/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/retail-store/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/retail-store/tier5-src/himi-blog-post/index.ts +501 -50
- package/templates/yoga-studio/config.ts +1 -1
- package/templates/yoga-studio/dev/index.ts +2619 -851
- package/templates/yoga-studio/l10n/ar.json +95 -36
- package/templates/yoga-studio/l10n/cs.json +95 -36
- package/templates/yoga-studio/l10n/da.json +95 -36
- package/templates/yoga-studio/l10n/de.json +95 -36
- package/templates/yoga-studio/l10n/el.json +95 -36
- package/templates/yoga-studio/l10n/en.json +71 -15
- package/templates/yoga-studio/l10n/es.json +95 -36
- package/templates/yoga-studio/l10n/fi.json +95 -36
- package/templates/yoga-studio/l10n/fr.json +95 -36
- package/templates/yoga-studio/l10n/he.json +78 -29
- package/templates/yoga-studio/l10n/hu.json +95 -36
- package/templates/yoga-studio/l10n/id.json +95 -36
- package/templates/yoga-studio/l10n/it.json +95 -36
- package/templates/yoga-studio/l10n/ja.json +95 -36
- package/templates/yoga-studio/l10n/ko.json +95 -36
- package/templates/yoga-studio/l10n/lt.json +95 -36
- package/templates/yoga-studio/l10n/nl.json +95 -36
- package/templates/yoga-studio/l10n/no.json +95 -36
- package/templates/yoga-studio/l10n/pl.json +95 -36
- package/templates/yoga-studio/l10n/pt.json +95 -36
- package/templates/yoga-studio/l10n/ru.json +95 -36
- package/templates/yoga-studio/l10n/sv.json +95 -36
- package/templates/yoga-studio/l10n/th.json +95 -36
- package/templates/yoga-studio/l10n/tr.json +95 -36
- package/templates/yoga-studio/l10n/uk.json +95 -36
- package/templates/yoga-studio/l10n/vi.json +95 -36
- package/templates/yoga-studio/l10n/zh.json +95 -36
- package/templates/yoga-studio/tier5-src/_shared/himi-blog-post-row.ts +5 -1
- package/templates/yoga-studio/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/yoga-studio/tier5-src/himi-blog-feed/index.ts +9 -0
- package/templates/yoga-studio/tier5-src/himi-blog-post/index.ts +501 -50
|
@@ -3,16 +3,19 @@ import { defineService, navigate } from "@himalaya/state";
|
|
|
3
3
|
import { snackbar } from "@himalaya/ui";
|
|
4
4
|
import { share as shareSheet } from "@himalaya/share";
|
|
5
5
|
import { getPost, likePost, unlikePost, queryPosts, queryCategories, queryTags, type WixPost, type WixPostWithContent, type WixQueryPostsRequest } from "@himalaya/wix-blog";
|
|
6
|
-
import {
|
|
6
|
+
import { likedBlogComments, listBlogCommentPage, postBlogComment, setBlogCommentLike, type WixBlogCommentRow } from "@himalaya/wix-comments";
|
|
7
|
+
import { getMyMember } from "@himalaya/wix-members";
|
|
8
|
+
import { dismiss as dismissKeyboard } from "@himalaya/keyboard";
|
|
7
9
|
import { get, type DbEntity } from "@himalaya/local-db";
|
|
8
10
|
import { isSavedId, toggleSavedId } from "../_shared/himi-blog-saved";
|
|
9
11
|
import { hideId, isHiddenId, unhideId } from "../_shared/himi-blog-hidden";
|
|
10
12
|
import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
11
|
-
import { formatDateMedium
|
|
13
|
+
import { formatDateMedium } from "../_shared/engine-intl.js";
|
|
14
|
+
import { relativeTime } from "../_shared/relative-time.js";
|
|
12
15
|
import { openRichLink } from "../_shared/rich-content-link.js";
|
|
13
16
|
import { richBody, ROW_IMAGE_WIDTH } from "../_shared/rich-body.js";
|
|
14
17
|
import { readAccess, assertReadAccess, readAccessDenied, readSignInFlags, NO_READ_SIGN_IN, type ReadAccess } from "../_shared/member-read.js";
|
|
15
|
-
import { authorFields, BLOG_HERO_IMAGE, BLOG_THUMB_IMAGE, commentsLabelFor, type BlogAuthor, countsOf, coverOf, dateLineOf, dateOf, legacyRowFixes, LIST_FIELDSETS, cachedCover, NO_AUTHOR, likesLabelFor, resolveAuthors, viewsLabelFor, type AuthorFields, type BlogPostShape } from "../_shared/himi-blog-post-row.js";
|
|
18
|
+
import { authorFields, BLOG_HERO_IMAGE, BLOG_THUMB_IMAGE, commentsLabelFor, type BlogAuthor, countsOf, coverOf, dateLineOf, dateOf, legacyRowFixes, LIST_FIELDSETS, cachedCover, NO_AUTHOR, likesLabelFor, profilePhoto, resolveAuthors, viewsLabelFor, type AuthorFields, type BlogPostShape } from "../_shared/himi-blog-post-row.js";
|
|
16
19
|
|
|
17
20
|
// Offline-first (data-offline): the post body is a public read-through — when the
|
|
18
21
|
// live fetch fails (offline) fall back to the last-synced row the feed cached under
|
|
@@ -26,20 +29,52 @@ async function readCachedPost(id: string): Promise<DbEntity | null> {
|
|
|
26
29
|
|
|
27
30
|
/** How many "Recent posts" rows the end of the post shows. */
|
|
28
31
|
const RECENT_COUNT = 3;
|
|
32
|
+
/** How many comments the post's comments box shows (the newest); the sheet shows them all. */
|
|
33
|
+
const LATEST_COMMENTS = 3;
|
|
34
|
+
/** Top-level comments per page the comments sheet reads. */
|
|
35
|
+
const COMMENTS_PAGE = 20;
|
|
29
36
|
|
|
30
37
|
interface CommentRow {
|
|
31
38
|
id: string;
|
|
39
|
+
/** A reply's parent comment id ("" on a top-level comment). Replies are one level deep. */
|
|
40
|
+
parentId: string;
|
|
41
|
+
isReply: boolean;
|
|
42
|
+
notReply: boolean;
|
|
43
|
+
/** The author's member id ("" for a visitor): the row's name and photo come from it. */
|
|
44
|
+
authorMemberId: string;
|
|
32
45
|
authorName: string;
|
|
33
|
-
/** The author's first letter, for the round initial
|
|
46
|
+
/** The author's first letter, for the round initial when there is no photo. */
|
|
34
47
|
authorInitial: string;
|
|
48
|
+
authorPhoto: string;
|
|
49
|
+
hasAuthorPhoto: boolean;
|
|
50
|
+
noAuthorPhoto: boolean;
|
|
35
51
|
/** The comment's plain text: the row RichContent's fallback. */
|
|
36
52
|
text: string;
|
|
53
|
+
/** The box's two-line preview: the text with no empty lines between its paragraphs. */
|
|
54
|
+
preview: string;
|
|
55
|
+
/** When it was written, relative ("2 hours ago") for the last week. */
|
|
37
56
|
meta: string;
|
|
57
|
+
createdDate: string;
|
|
38
58
|
/** [rico] #3372 — the comment's Ricos document as ONE string for the row's RichContent; "" when it has none
|
|
39
59
|
* or the encoder rejected it. */
|
|
40
60
|
bodyJson: string;
|
|
41
61
|
/** bodyJson !== "" — gates the row's plain text, because RichContent draws nothing for "". */
|
|
42
62
|
hasBodyJson: boolean;
|
|
63
|
+
/** Likes: the count, the reader's own like, and `noLikes` when the site sent no reaction summary
|
|
64
|
+
* (it takes no reactions there, so Like is not offered). */
|
|
65
|
+
likeCount: number;
|
|
66
|
+
likes: string;
|
|
67
|
+
liked: boolean;
|
|
68
|
+
notLiked: boolean;
|
|
69
|
+
noLikes: boolean;
|
|
70
|
+
/** No Reply on this site (its comments carry no reply count). */
|
|
71
|
+
noReply: boolean;
|
|
72
|
+
/** The ⋮ menu's Report is not offered: the reader's own comment, or one they reported. */
|
|
73
|
+
noReport: boolean;
|
|
74
|
+
/** The comment the reader just sent, tinted until the sheet closes or they send another. */
|
|
75
|
+
highlight: boolean;
|
|
76
|
+
/** The row's background token: `accentSurface` while highlighted, "" otherwise. */
|
|
77
|
+
rowBackground: string;
|
|
43
78
|
}
|
|
44
79
|
|
|
45
80
|
interface TagRow { id: string; label: string }
|
|
@@ -119,8 +154,45 @@ interface S extends AuthorFields {
|
|
|
119
154
|
reported: boolean;
|
|
120
155
|
notReported: boolean;
|
|
121
156
|
commentText: string;
|
|
157
|
+
/** Every loaded comment, newest first, each one's replies under it (oldest reply first). */
|
|
122
158
|
comments: CommentRow[];
|
|
159
|
+
/** The newest LATEST_COMMENTS top-level comments: the post's comments box. */
|
|
160
|
+
latestComments: CommentRow[];
|
|
161
|
+
hasComments: boolean;
|
|
162
|
+
noComments: boolean;
|
|
163
|
+
/** "Show all (N)" — the box's link to the comments sheet. */
|
|
164
|
+
showAllLabel: string;
|
|
165
|
+
/** The comments sheet ("Show all", a tap on the box's input or on Reply) is open. */
|
|
166
|
+
commentsSheetOpen: boolean;
|
|
167
|
+
/** The cursor of the next page of comments ("" when they are all loaded). */
|
|
168
|
+
commentsCursor: string;
|
|
169
|
+
hasMoreComments: boolean;
|
|
170
|
+
noMoreComments: boolean;
|
|
171
|
+
/** A nonce: a new value focuses the sheet's comment field (and opens the keyboard). */
|
|
172
|
+
composerFocus: string;
|
|
173
|
+
/** The comment a reply goes to ("" = a new comment), and "Replying to <name>". */
|
|
174
|
+
replyToId: string;
|
|
175
|
+
replyingLine: string;
|
|
176
|
+
isReplying: boolean;
|
|
177
|
+
notReplying: boolean;
|
|
178
|
+
/** The field has text to send. */
|
|
179
|
+
canSend: boolean;
|
|
180
|
+
cannotSend: boolean;
|
|
181
|
+
/** Why the last send failed, under the field ("" = none). The text stays to send again. */
|
|
182
|
+
sendError: string;
|
|
183
|
+
noSendError: boolean;
|
|
184
|
+
/** The reader is a signed-in member (a visitor signs in before a comment, a like or a reply). */
|
|
185
|
+
isMember: boolean;
|
|
186
|
+
/** The member's own id, name, photo and initial: the comment inputs' avatar and their new comments. */
|
|
187
|
+
memberId: string;
|
|
188
|
+
memberName: string;
|
|
189
|
+
memberPhoto: string;
|
|
190
|
+
memberInitial: string;
|
|
191
|
+
hasMemberPhoto: boolean;
|
|
192
|
+
noMemberPhoto: boolean;
|
|
123
193
|
commentsTitle: string;
|
|
194
|
+
/** "Comments (N)" in the sheet. */
|
|
195
|
+
sheetTitle: string;
|
|
124
196
|
commentsUnavailable: boolean;
|
|
125
197
|
commentsAvailable: boolean;
|
|
126
198
|
/** The owner turned comments off for this post (Blog v3 `commentingEnabled: false`). */
|
|
@@ -128,6 +200,9 @@ interface S extends AuthorFields {
|
|
|
128
200
|
commentsOn: boolean;
|
|
129
201
|
commentStatusText: string;
|
|
130
202
|
noCommentStatus: boolean;
|
|
203
|
+
/** The comments loaded, there are none, and the post takes comments: the box's empty state. */
|
|
204
|
+
commentsEmpty: boolean;
|
|
205
|
+
notCommentsEmpty: boolean;
|
|
131
206
|
recent: RecentRow[];
|
|
132
207
|
/** A "Recent posts" read failed; the section shows what the other reads found. */
|
|
133
208
|
recentUnavailable: boolean;
|
|
@@ -202,36 +277,90 @@ function bodyText(post: PostWithExtras): string {
|
|
|
202
277
|
return post.plainContent || post.contentText || post.excerpt || copyParam("blogPost.bodyFallback", "This post has no readable body yet.");
|
|
203
278
|
}
|
|
204
279
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
280
|
+
/** The reader's own profile, for the comment inputs' avatar and the comments they send. */
|
|
281
|
+
interface Me { id: string; name: string; photo: string }
|
|
282
|
+
const NO_ME: Me = { id: "", name: "", photo: "" };
|
|
209
283
|
|
|
210
|
-
function toCommentRow(row: WixBlogCommentRow): CommentRow {
|
|
284
|
+
function toCommentRow(row: WixBlogCommentRow, authors: Map<string, BlogAuthor>, liked: ReadonlySet<string>, now = Date.now()): CommentRow {
|
|
211
285
|
// The plain text is the document's own (runs joined as written, not space-separated) when it has one.
|
|
212
286
|
// `forum.commentCta` is the app's one "Comment": the pack forwards that single key to this screen (see the prefixes).
|
|
213
287
|
const { bodyJson, bodyText } = richBody(row.richContent, row.text || copyParam("forum.commentCta", "Comment"), ROW_IMAGE_WIDTH);
|
|
214
|
-
const
|
|
288
|
+
const memberId = row.authorMemberId ?? "";
|
|
289
|
+
// The Comments API names an author by id only: the public profile names them. "Member" only for an
|
|
290
|
+
// author with no public profile (a visitor, a private profile).
|
|
291
|
+
const author = authors.get(memberId);
|
|
292
|
+
const authorName = author?.name || row.authorName || copyParam("blogPost.memberFallback", "Member");
|
|
293
|
+
const photo = author?.photo ?? "";
|
|
294
|
+
const likeCount = Math.max(0, row.reactionTotal ?? 0);
|
|
295
|
+
const isLiked = liked.has(row.id);
|
|
296
|
+
const parentId = row.parentCommentId ?? "";
|
|
215
297
|
return {
|
|
216
298
|
id: row.id,
|
|
299
|
+
parentId,
|
|
300
|
+
isReply: !!parentId,
|
|
301
|
+
notReply: !parentId,
|
|
302
|
+
authorMemberId: memberId,
|
|
217
303
|
authorName,
|
|
218
304
|
authorInitial: (authorName[0] || "#").toUpperCase(),
|
|
305
|
+
authorPhoto: photo,
|
|
306
|
+
hasAuthorPhoto: !!photo,
|
|
307
|
+
noAuthorPhoto: !photo,
|
|
219
308
|
text: bodyText,
|
|
220
|
-
|
|
309
|
+
preview: bodyText.split(/\n\s*\n+/).join("\n").trim(),
|
|
310
|
+
meta: relativeTime(row.createdDate, skewedNow(row.createdDate, now)),
|
|
311
|
+
createdDate: row.createdDate,
|
|
221
312
|
bodyJson,
|
|
222
313
|
hasBodyJson: bodyJson !== "",
|
|
314
|
+
likeCount,
|
|
315
|
+
likes: String(likeCount),
|
|
316
|
+
liked: isLiked,
|
|
317
|
+
notLiked: !isLiked,
|
|
318
|
+
noLikes: row.reactionTotal === undefined,
|
|
319
|
+
noReply: row.replyCount === undefined && !parentId,
|
|
320
|
+
noReport: reportedComments.has(row.id),
|
|
321
|
+
highlight: false,
|
|
322
|
+
rowBackground: "",
|
|
223
323
|
};
|
|
224
324
|
}
|
|
225
325
|
|
|
326
|
+
const HIGHLIGHT = "accentSurface";
|
|
327
|
+
const unhighlighted = (row: CommentRow): CommentRow => row.highlight ? { ...row, highlight: false, rowBackground: "" } : row;
|
|
328
|
+
|
|
329
|
+
/** The site's clock can run a few seconds ahead of the device: a comment just sent then reads as
|
|
330
|
+
* in the future, which `relativeTime` shows as a date. Up to CLOCK_SKEW_MS ahead counts as now. */
|
|
331
|
+
const CLOCK_SKEW_MS = 5 * 60_000;
|
|
332
|
+
function skewedNow(iso: string, now: number): number {
|
|
333
|
+
const at = Date.parse(iso);
|
|
334
|
+
return Number.isFinite(at) && at > now && at - now <= CLOCK_SKEW_MS ? at : now;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Comments this reader reported in this session: Report is not offered on them again. No site
|
|
338
|
+
* API takes a member's report on a comment, so, as for the post, the tap is the signal. */
|
|
339
|
+
const reportedComments = new Set<string>();
|
|
340
|
+
|
|
341
|
+
/** Report is not offered on the reader's own comments. */
|
|
342
|
+
const withOwnComments = (rows: CommentRow[], memberId: string): CommentRow[] =>
|
|
343
|
+
memberId ? rows.map((row) => row.authorMemberId === memberId && !row.noReport ? { ...row, noReport: true } : row) : rows;
|
|
344
|
+
|
|
345
|
+
/** A row with a new like state and count. */
|
|
346
|
+
function withLike(row: CommentRow, liked: boolean): CommentRow {
|
|
347
|
+
const likeCount = Math.max(0, row.likeCount + (liked === row.liked ? 0 : liked ? 1 : -1));
|
|
348
|
+
return { ...row, liked, notLiked: !liked, likeCount, likes: String(likeCount) };
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Add a sent comment: a new one at the top, a reply after its parent's last reply. */
|
|
352
|
+
function insertComment(rows: CommentRow[], created: CommentRow): CommentRow[] {
|
|
353
|
+
const plain = rows.map(unhighlighted);
|
|
354
|
+
if (!created.parentId) return [created, ...plain];
|
|
355
|
+
let at = plain.findIndex((row) => row.id === created.parentId);
|
|
356
|
+
if (at < 0) return [created, ...plain];
|
|
357
|
+
while (plain[at + 1]?.parentId === created.parentId) at++;
|
|
358
|
+
return [...plain.slice(0, at + 1), created, ...plain.slice(at + 1)];
|
|
359
|
+
}
|
|
360
|
+
|
|
226
361
|
const commentsTitleFor = (count: number): string =>
|
|
227
362
|
count > 0 ? copyTemplate("blogPost.commentsTitleCount", "Comments ({count})", { count }) : copyParam("blogPost.commentsTitle", "Comments");
|
|
228
363
|
|
|
229
|
-
/** The comment text as Ricos rich content, typed against the auto tier's REST types. */
|
|
230
|
-
const commentRichContent = (text: string): comments.RichContent => ({
|
|
231
|
-
nodes: [{ type: "PARAGRAPH", id: "himi-blog-comment", nodes: [{ type: "TEXT", id: "himi-blog-comment-text", textData: { text } }] }],
|
|
232
|
-
metadata: { version: 1 },
|
|
233
|
-
});
|
|
234
|
-
|
|
235
364
|
function toRecentRow(post: WixPost): RecentRow {
|
|
236
365
|
const cover = coverOf(post as PostWithExtras, BLOG_THUMB_IMAGE);
|
|
237
366
|
return { id: post.id, title: post.title || copyParam("blogCommon.untitled", "Untitled post"), date: dateOf(post as PostWithExtras), cover, hasCover: !!cover, noCover: !cover, detailScreenId: "himi_blog_post" };
|
|
@@ -300,6 +429,33 @@ async function loadTags(post: PostWithExtras): Promise<{ rows: TagRow[]; failed:
|
|
|
300
429
|
return { rows: ids.map((id) => ({ id, label: byId.get(id) ?? "" })).filter((tag) => tag.label), failed };
|
|
301
430
|
}
|
|
302
431
|
|
|
432
|
+
/** The comment flags the box, the sheet and the composer bind. */
|
|
433
|
+
function commentFlags(s: S): Partial<S> {
|
|
434
|
+
const comments = withOwnComments(s.comments, s.memberId);
|
|
435
|
+
// The site's count when it is ahead (a page not loaded yet), the loaded list when the metric lags.
|
|
436
|
+
const total = Math.max(Number(s.commentCount) || 0, s.comments.length);
|
|
437
|
+
const empty = s.status === "ready" && !s.commentsUnavailable && !s.commentsOff && s.comments.length === 0;
|
|
438
|
+
return {
|
|
439
|
+
comments,
|
|
440
|
+
latestComments: comments.filter((row) => !row.parentId).slice(0, LATEST_COMMENTS),
|
|
441
|
+
hasComments: s.comments.length > 0,
|
|
442
|
+
noComments: s.comments.length === 0,
|
|
443
|
+
showAllLabel: copyTemplate("blogPost.showAllComments", "Show all ({count})", { count: total }),
|
|
444
|
+
sheetTitle: commentsTitleFor(total),
|
|
445
|
+
commentsEmpty: empty,
|
|
446
|
+
notCommentsEmpty: !empty,
|
|
447
|
+
hasMoreComments: !!s.commentsCursor,
|
|
448
|
+
noMoreComments: !s.commentsCursor,
|
|
449
|
+
isReplying: !!s.replyToId,
|
|
450
|
+
notReplying: !s.replyToId,
|
|
451
|
+
canSend: !!s.commentText.trim(),
|
|
452
|
+
cannotSend: !s.commentText.trim(),
|
|
453
|
+
noSendError: !s.sendError,
|
|
454
|
+
hasMemberPhoto: !!s.memberPhoto,
|
|
455
|
+
noMemberPhoto: !s.memberPhoto,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
303
459
|
function derive(s: S): S {
|
|
304
460
|
const isLoading = s.status === "loading";
|
|
305
461
|
const errored = s.status === "error";
|
|
@@ -334,6 +490,7 @@ function derive(s: S): S {
|
|
|
334
490
|
notReported: !s.reported,
|
|
335
491
|
commentsAvailable: !s.commentsUnavailable,
|
|
336
492
|
commentsOn: !s.commentsOff,
|
|
493
|
+
...commentFlags(s),
|
|
337
494
|
hasRecent: s.recent.length > 0,
|
|
338
495
|
noRecent: s.recent.length === 0,
|
|
339
496
|
};
|
|
@@ -429,13 +586,40 @@ const baseState: S = derive({
|
|
|
429
586
|
notReported: true,
|
|
430
587
|
commentText: "",
|
|
431
588
|
comments: [],
|
|
589
|
+
latestComments: [],
|
|
590
|
+
hasComments: false,
|
|
591
|
+
noComments: true,
|
|
592
|
+
showAllLabel: "",
|
|
593
|
+
commentsSheetOpen: false,
|
|
594
|
+
commentsCursor: "",
|
|
595
|
+
hasMoreComments: false,
|
|
596
|
+
noMoreComments: true,
|
|
597
|
+
composerFocus: "",
|
|
598
|
+
replyToId: "",
|
|
599
|
+
replyingLine: "",
|
|
600
|
+
isReplying: false,
|
|
601
|
+
notReplying: true,
|
|
602
|
+
canSend: false,
|
|
603
|
+
cannotSend: true,
|
|
604
|
+
sendError: "",
|
|
605
|
+
noSendError: true,
|
|
606
|
+
isMember: false,
|
|
607
|
+
memberId: "",
|
|
608
|
+
memberName: "",
|
|
609
|
+
memberPhoto: "",
|
|
610
|
+
memberInitial: "",
|
|
611
|
+
hasMemberPhoto: false,
|
|
612
|
+
noMemberPhoto: true,
|
|
432
613
|
commentsTitle: "Comments",
|
|
614
|
+
sheetTitle: "Comments",
|
|
433
615
|
commentsUnavailable: false,
|
|
434
616
|
commentsAvailable: true,
|
|
435
617
|
commentsOff: false,
|
|
436
618
|
commentsOn: true,
|
|
437
619
|
commentStatusText: "",
|
|
438
620
|
noCommentStatus: true,
|
|
621
|
+
commentsEmpty: false,
|
|
622
|
+
notCommentsEmpty: true,
|
|
439
623
|
recent: [],
|
|
440
624
|
recentUnavailable: false,
|
|
441
625
|
hasRecent: false,
|
|
@@ -486,7 +670,7 @@ async function cachedPostState(s: S, id: string): Promise<S> {
|
|
|
486
670
|
saved: isSavedId(id),
|
|
487
671
|
hidden: isHiddenId(id),
|
|
488
672
|
comments: [],
|
|
489
|
-
|
|
673
|
+
commentsCursor: "",
|
|
490
674
|
commentsUnavailable: true,
|
|
491
675
|
commentStatusText: copyParam("blogPost.commentsUnavailable", "Comments are unavailable right now."),
|
|
492
676
|
errorText: "",
|
|
@@ -496,9 +680,47 @@ async function cachedPostState(s: S, id: string): Promise<S> {
|
|
|
496
680
|
|
|
497
681
|
/** The network half of a post load: the post and its comments, author, category, tags and recent
|
|
498
682
|
* posts, unmapped (the copy pack that names them arrives with the screen's onAppear load). */
|
|
683
|
+
interface CommentFetch {
|
|
684
|
+
rows: WixBlogCommentRow[];
|
|
685
|
+
nextCursor: string;
|
|
686
|
+
unavailable: boolean;
|
|
687
|
+
/** The comment authors' public names and photos, read in ONE members query for the page. */
|
|
688
|
+
authors: Map<string, BlogAuthor>;
|
|
689
|
+
/** The comments on the page the reader liked (empty for a visitor). */
|
|
690
|
+
liked: Set<string>;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/** A page of the post's comments with their authors and the reader's likes. A failed authors or
|
|
694
|
+
* likes read leaves those out ("Member", no like); a failed page is "comments unavailable". */
|
|
695
|
+
async function fetchComments(resourceId: string, member: boolean, cursor = ""): Promise<CommentFetch> {
|
|
696
|
+
if (!resourceId) return { rows: [], nextCursor: "", unavailable: true, authors: new Map(), liked: new Set() };
|
|
697
|
+
let page: { comments: WixBlogCommentRow[]; nextCursor: string };
|
|
698
|
+
try { page = await listBlogCommentPage(resourceId, { limit: COMMENTS_PAGE, ...(cursor ? { cursor } : {}) }); }
|
|
699
|
+
catch { return { rows: [], nextCursor: "", unavailable: true, authors: new Map(), liked: new Set() }; }
|
|
700
|
+
const [authors, liked] = await Promise.all([
|
|
701
|
+
resolveAuthors(page.comments.map((row) => row.authorMemberId)).catch(() => new Map<string, BlogAuthor>()),
|
|
702
|
+
member && page.comments.length ? likedBlogComments(resourceId, page.comments.map((row) => row.id)).catch(() => new Set<string>()) : Promise.resolve(new Set<string>()),
|
|
703
|
+
]);
|
|
704
|
+
return { rows: page.comments, nextCursor: page.nextCursor, unavailable: false, authors, liked };
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** The signed-in member's name (public nickname, else contact name) and photo ("" for a visitor, or when the read fails). */
|
|
708
|
+
async function fetchMe(member: boolean): Promise<Me> {
|
|
709
|
+
if (!member) return NO_ME;
|
|
710
|
+
try {
|
|
711
|
+
// FULL: the member's own record, so a member with no public nickname shows their contact name on
|
|
712
|
+
// the comment they just sent (as the account screen does), never "Member".
|
|
713
|
+
const found = (await getMyMember({ fieldsets: ["FULL"] }))?.member;
|
|
714
|
+
const name = (found?.profile?.nickname ?? "").trim()
|
|
715
|
+
|| [found?.contact?.firstName, found?.contact?.lastName].map((part) => (part ?? "").trim()).filter(Boolean).join(" ");
|
|
716
|
+
return { id: found?.id ?? "", name, photo: profilePhoto(found?.profile?.photo) };
|
|
717
|
+
} catch { return NO_ME; }
|
|
718
|
+
}
|
|
719
|
+
|
|
499
720
|
interface PostFetch {
|
|
500
721
|
post: PostWithExtras;
|
|
501
|
-
comments:
|
|
722
|
+
comments: CommentFetch;
|
|
723
|
+
me: Me;
|
|
502
724
|
authors: Map<string, BlogAuthor>;
|
|
503
725
|
categoryLabel: string;
|
|
504
726
|
tags: { rows: TagRow[]; failed: boolean };
|
|
@@ -514,19 +736,16 @@ async function fetchPost(id: string, access: ReadAccess): Promise<PostFetch> {
|
|
|
514
736
|
// Native Blog v3 Comments scopes by internalId, not the navigation UUID.
|
|
515
737
|
// A missing projection cannot establish that the post has no comments.
|
|
516
738
|
const commentResourceId = post.internalId?.trim() ?? "";
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
};
|
|
522
|
-
const [comments, authors, categoryLabel, tags, recent] = await Promise.all([
|
|
523
|
-
loadComments(),
|
|
739
|
+
const member = !!access.member.email;
|
|
740
|
+
const [comments, me, authors, categoryLabel, tags, recent] = await Promise.all([
|
|
741
|
+
fetchComments(commentResourceId, member),
|
|
742
|
+
fetchMe(member),
|
|
524
743
|
resolveAuthors([post.memberId]),
|
|
525
744
|
loadCategoryLabel(post),
|
|
526
745
|
loadTags(post),
|
|
527
746
|
loadRecent(post),
|
|
528
747
|
]);
|
|
529
|
-
return { post, comments, authors, categoryLabel, tags, recent };
|
|
748
|
+
return { post, comments, me, authors, categoryLabel, tags, recent };
|
|
530
749
|
}
|
|
531
750
|
|
|
532
751
|
// The worker loads at boot AND again on the screen's onAppear (which carries the copy pack). The
|
|
@@ -549,6 +768,81 @@ function sharedFetch(id: string, access: ReadAccess, fresh: boolean): Promise<Po
|
|
|
549
768
|
* reused answer predates the change. */
|
|
550
769
|
function forgetFetch(): void { lastFetch = null; }
|
|
551
770
|
|
|
771
|
+
/** How long a sign-in may take and still reopen the comments sheet. */
|
|
772
|
+
const RESUME_COMPOSER_MS = 5 * 60_000;
|
|
773
|
+
/** The post a visitor tapped the comment input on (or Reply) before signing in, and when. In the
|
|
774
|
+
* device KV, not only in memory: on Android a sign-in changes the reader and the host starts a new
|
|
775
|
+
* worker for the post, which would forget an in-memory mark. */
|
|
776
|
+
const RESUME_COMPOSER_KEY = "himi-blog:resume-composer:v1";
|
|
777
|
+
type StorageLike = { getItem: (key: string) => string | null; setItem: (key: string, value: string) => void };
|
|
778
|
+
const kv = (): StorageLike | undefined => {
|
|
779
|
+
const host = globalThis as { himalaya?: { storage?: StorageLike }; localStorage?: StorageLike };
|
|
780
|
+
return host.himalaya?.storage ?? host.localStorage;
|
|
781
|
+
};
|
|
782
|
+
/** `replyTo` / `replyName`: the comment a visitor's Reply was for, so the reply survives sign-in.
|
|
783
|
+
* `text`: what the visitor had typed when Send took them to sign-in (Android starts a new worker). */
|
|
784
|
+
interface ComposerMark { id: string; at: number; replyTo?: string; replyName?: string; text?: string }
|
|
785
|
+
let composerMark: ComposerMark | null = null;
|
|
786
|
+
function readComposerMark(): ComposerMark | null {
|
|
787
|
+
try {
|
|
788
|
+
const raw = kv()?.getItem(RESUME_COMPOSER_KEY);
|
|
789
|
+
const mark = raw ? JSON.parse(raw) as { id?: unknown; at?: unknown; replyTo?: unknown; replyName?: unknown; text?: unknown } : null;
|
|
790
|
+
if (mark && typeof mark.id === "string" && typeof mark.at === "number") {
|
|
791
|
+
return {
|
|
792
|
+
id: mark.id, at: mark.at,
|
|
793
|
+
...(typeof mark.replyTo === "string" && mark.replyTo ? { replyTo: mark.replyTo, replyName: typeof mark.replyName === "string" ? mark.replyName : "" } : {}),
|
|
794
|
+
...(typeof mark.text === "string" && mark.text ? { text: mark.text } : {}),
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
} catch { /* unreadable: the in-memory mark below */ }
|
|
798
|
+
// Nothing stored (spent, or a store that keeps no writes): this worker's own mark, if any.
|
|
799
|
+
return composerMark;
|
|
800
|
+
}
|
|
801
|
+
function writeComposerMark(mark: ComposerMark | null): void {
|
|
802
|
+
composerMark = mark;
|
|
803
|
+
try { kv()?.setItem(RESUME_COMPOSER_KEY, mark ? JSON.stringify(mark) : ""); } catch { /* the in-memory mark stays */ }
|
|
804
|
+
}
|
|
805
|
+
/** Mark the composer as it is now (the reply it is for and the typed text), so it comes back after sign-in. */
|
|
806
|
+
function markComposer(s: S): void {
|
|
807
|
+
const target = s.replyToId ? s.comments.find((row) => row.id === s.replyToId) : undefined;
|
|
808
|
+
writeComposerMark({
|
|
809
|
+
id: s.id, at: Date.now(),
|
|
810
|
+
...(target ? { replyTo: s.replyToId, replyName: target.authorName } : {}),
|
|
811
|
+
...(s.commentText.trim() ? { text: s.commentText } : {}),
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
/** A new focus token for the comment field (see TextFieldProps.focus_path). */
|
|
815
|
+
let focusCount = 0;
|
|
816
|
+
const nonce = (): string => `${Date.now()}-${++focusCount}`;
|
|
817
|
+
|
|
818
|
+
function meFields(me: Me): Pick<S, "memberId" | "memberName" | "memberPhoto" | "memberInitial"> {
|
|
819
|
+
return { memberId: me.id, memberName: me.name, memberPhoto: me.photo, memberInitial: (me.name[0] || "").toUpperCase() };
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** The member's own fields as an author: their new comment shows their name and photo at once. */
|
|
823
|
+
function meAsAuthors(s: S, memberId: string | undefined): Map<string, BlogAuthor> {
|
|
824
|
+
return memberId && s.memberName
|
|
825
|
+
? new Map([[memberId, { name: s.memberName, photo: s.memberPhoto, initial: s.memberInitial }]])
|
|
826
|
+
: new Map();
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/** The comment `id` names in an action's args ("" when none). */
|
|
830
|
+
const argId = (arg: unknown): string => {
|
|
831
|
+
const id = (arg as { id?: unknown } | undefined)?.id;
|
|
832
|
+
return typeof id === "string" ? id : "";
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
/** Show a comment's like state now (set once the service exists). */
|
|
836
|
+
let showCommentLike: (id: string, liked: boolean) => unknown = () => undefined;
|
|
837
|
+
/** Comment likes on their way, by comment id: a second tap waits for the first. */
|
|
838
|
+
const commentLikesInFlight = new Set<string>();
|
|
839
|
+
/** The like state the reader's last tap asked for while a call on that comment was on its way. */
|
|
840
|
+
const commentLikesWanted = new Map<string, boolean>();
|
|
841
|
+
/** The post a comment is being sent on ("" = none): a second Send waits for the first. */
|
|
842
|
+
let sendInFlight = "";
|
|
843
|
+
/** The page of comments being read ("" = none). */
|
|
844
|
+
let moreCommentsInFlight = "";
|
|
845
|
+
|
|
552
846
|
let loadVersion = 0;
|
|
553
847
|
async function loadPostState(s: S, fresh = false): Promise<S | undefined> {
|
|
554
848
|
const version = ++loadVersion;
|
|
@@ -560,7 +854,7 @@ async function loadPostState(s: S, fresh = false): Promise<S | undefined> {
|
|
|
560
854
|
}
|
|
561
855
|
try {
|
|
562
856
|
const access = await readAccess();
|
|
563
|
-
const { post, comments: commentResult, authors, categoryLabel, tags, recent } = await sharedFetch(id, access, fresh);
|
|
857
|
+
const { post, comments: commentResult, me, authors, categoryLabel, tags, recent } = await sharedFetch(id, access, fresh);
|
|
564
858
|
await assertReadAccess(access);
|
|
565
859
|
if (version !== loadVersion) return undefined;
|
|
566
860
|
const commentResourceId = post.internalId?.trim() ?? "";
|
|
@@ -568,9 +862,33 @@ async function loadPostState(s: S, fresh = false): Promise<S | undefined> {
|
|
|
568
862
|
const cover = coverOf(post, BLOG_HERO_IMAGE);
|
|
569
863
|
const title = post.title || copyParam("blogCommon.untitled", "Untitled post");
|
|
570
864
|
const counts = countsOf(post);
|
|
571
|
-
const
|
|
865
|
+
const now = Date.now();
|
|
866
|
+
const commentRows = commentResult.rows.map((row) => toCommentRow(row, commentResult.authors, commentResult.liked, now));
|
|
867
|
+
const isMember = !!access.member.email;
|
|
868
|
+
// A visitor who tapped the comment input signed in and came back: the sheet opens with the keyboard.
|
|
869
|
+
// The mark stays until it is used: a reload can run before the host knows about the sign-in
|
|
870
|
+
// (seen on Android), and that one must not spend it. Another post or an old mark drops it.
|
|
871
|
+
const mark = readComposerMark();
|
|
872
|
+
const pending = mark?.id === id && Date.now() - mark.at < RESUME_COMPOSER_MS;
|
|
873
|
+
if (mark && !pending) writeComposerMark(null);
|
|
874
|
+
const resume = pending && isMember && !commentsOff;
|
|
875
|
+
if (resume) writeComposerMark(null);
|
|
876
|
+
// A load never closes a sheet already open on this post, or empties its composer: the worker
|
|
877
|
+
// loads at boot and again on the screen's onAppear, and the boot load may be the one that
|
|
878
|
+
// reopened it.
|
|
879
|
+
const sheetOpen = s.commentsSheetOpen && s.id === id;
|
|
572
880
|
return derive({
|
|
573
881
|
...clean,
|
|
882
|
+
...meFields(me),
|
|
883
|
+
isMember,
|
|
884
|
+
commentsSheetOpen: resume || sheetOpen,
|
|
885
|
+
...(sheetOpen ? { commentText: s.commentText, replyToId: s.replyToId, replyingLine: s.replyingLine } : {}),
|
|
886
|
+
// A visitor who started from Reply comes back replying to the same comment, with what they typed.
|
|
887
|
+
...(resume && mark?.replyTo && commentRows.some((row) => row.id === mark.replyTo)
|
|
888
|
+
? { replyToId: mark.replyTo, replyingLine: copyTemplate("blogPost.replyingTo", "Replying to {name}", { name: mark.replyName ?? "" }) }
|
|
889
|
+
: {}),
|
|
890
|
+
...(resume && mark?.text && !(sheetOpen && s.commentText) ? { commentText: mark.text } : {}),
|
|
891
|
+
composerFocus: resume ? nonce() : sheetOpen ? s.composerFocus : "",
|
|
574
892
|
...authorFields(authors.get(post.memberId ?? "")),
|
|
575
893
|
status: "ready",
|
|
576
894
|
id,
|
|
@@ -595,14 +913,16 @@ async function loadPostState(s: S, fresh = false): Promise<S | undefined> {
|
|
|
595
913
|
saved: isSavedId(id),
|
|
596
914
|
hidden: isHiddenId(id),
|
|
597
915
|
comments: commentRows,
|
|
598
|
-
|
|
916
|
+
commentsCursor: commentResult.nextCursor,
|
|
917
|
+
commentsTitle: copyParam("blogPost.commentsTitle", "Comments"),
|
|
599
918
|
commentsUnavailable: commentResult.unavailable,
|
|
600
919
|
commentsOff,
|
|
920
|
+
// "No comments yet" is the box's own empty state (commentsEmpty), not a status line.
|
|
601
921
|
commentStatusText: commentsOff
|
|
602
922
|
? copyParam("blogPost.commentsOff", "Comments are turned off for this post.")
|
|
603
923
|
: commentResult.unavailable
|
|
604
924
|
? copyParam("blogPost.commentsUnavailable", "Comments are unavailable right now.")
|
|
605
|
-
:
|
|
925
|
+
: "",
|
|
606
926
|
recent: recent.posts.map(toRecentRow),
|
|
607
927
|
recentUnavailable: recent.failed,
|
|
608
928
|
errorText: "",
|
|
@@ -621,6 +941,43 @@ async function loadPostState(s: S, fresh = false): Promise<S | undefined> {
|
|
|
621
941
|
}
|
|
622
942
|
}
|
|
623
943
|
|
|
944
|
+
/** Like or unlike one comment: the heart and the count change at once, and go back when the site
|
|
945
|
+
* refuses. A visitor signs in first. */
|
|
946
|
+
async function toggleCommentLike(s: S, id: string, like: boolean): Promise<S | undefined> {
|
|
947
|
+
const row = s.comments.find((comment) => comment.id === id);
|
|
948
|
+
if (!row || row.noLikes || row.liked === like) return undefined;
|
|
949
|
+
if (!s.isMember) return signIn(s);
|
|
950
|
+
// The change shows at once (through the internal action, while the call is on its way); the
|
|
951
|
+
// answer only undoes it on a refusal.
|
|
952
|
+
void showCommentLike(id, like);
|
|
953
|
+
// A tap while a call is on its way is kept: the call that follows sends the reader's last choice.
|
|
954
|
+
if (commentLikesInFlight.has(id)) { commentLikesWanted.set(id, like); return undefined; }
|
|
955
|
+
commentLikesInFlight.add(id);
|
|
956
|
+
const swap = (state: S, value: boolean): S => derive({ ...state, comments: state.comments.map((comment) => comment.id === id ? withLike(comment, value) : comment) });
|
|
957
|
+
let sent = like;
|
|
958
|
+
try {
|
|
959
|
+
for (;;) {
|
|
960
|
+
await setBlogCommentLike(id, sent);
|
|
961
|
+
// The next load reads the comments again: a reused fetch predates this like.
|
|
962
|
+
forgetFetch();
|
|
963
|
+
const wanted = commentLikesWanted.get(id);
|
|
964
|
+
commentLikesWanted.delete(id);
|
|
965
|
+
if (wanted === undefined || wanted === sent) break;
|
|
966
|
+
sent = wanted;
|
|
967
|
+
}
|
|
968
|
+
const now = samePost(s);
|
|
969
|
+
return now ? swap(now, sent) : undefined;
|
|
970
|
+
} catch (error) {
|
|
971
|
+
commentLikesWanted.delete(id);
|
|
972
|
+
const now = samePost(s);
|
|
973
|
+
if (!now) return undefined;
|
|
974
|
+
const back = swap(now, !sent);
|
|
975
|
+
return readAccessDenied(error) ? signIn(back) : say(back, copyParam("blogPost.likeFailed", "Could not update like."));
|
|
976
|
+
} finally {
|
|
977
|
+
commentLikesInFlight.delete(id);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
624
981
|
const svc = defineService<S, {
|
|
625
982
|
prepare: (s: S) => S;
|
|
626
983
|
load: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
@@ -645,7 +1002,26 @@ const svc = defineService<S, {
|
|
|
645
1002
|
/** The paid-post notice's link: the post on the site, where a subscriber can read all of it. */
|
|
646
1003
|
openOnWebsite: (s: S) => Promise<S | undefined>;
|
|
647
1004
|
setComment: (s: S, arg?: unknown) => S;
|
|
1005
|
+
/** Send the comment (or the reply) in the sheet's field. */
|
|
648
1006
|
submitComment: (s: S) => Promise<S | undefined>;
|
|
1007
|
+
/** "Show all": the comments sheet, without the keyboard. */
|
|
1008
|
+
openComments: (s: S) => S;
|
|
1009
|
+
/** The box's "Leave a comment…": the sheet with the field focused. A visitor signs in first. */
|
|
1010
|
+
openComposer: (s: S) => S;
|
|
1011
|
+
closeComments: (s: S) => S;
|
|
1012
|
+
/** `{ id }`: reply to that comment (a reply to a reply goes to its parent). Opens the sheet when
|
|
1013
|
+
* it is not open, and focuses the field. A visitor signs in first. */
|
|
1014
|
+
replyTo: (s: S, arg?: unknown) => S;
|
|
1015
|
+
cancelReply: (s: S) => S;
|
|
1016
|
+
/** `{ id }`: like or unlike that comment. A visitor signs in first. */
|
|
1017
|
+
likeComment: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
1018
|
+
unlikeComment: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
1019
|
+
/** The sheet's list reached its end: the next page of comments. */
|
|
1020
|
+
loadMoreComments: (s: S) => Promise<S | undefined>;
|
|
1021
|
+
/** Internal: `{ id, liked }` — a comment's like as the reader sees it while the call is on its way. */
|
|
1022
|
+
_commentLike: (s: S, arg?: unknown) => S;
|
|
1023
|
+
/** `{ id }`: the ⋮ menu's Report on a comment. The reader is thanked and Report goes from that comment. */
|
|
1024
|
+
reportComment: (s: S, arg?: unknown) => S;
|
|
649
1025
|
/** [rico] #3370 — RichContent's on_link: `{ url }` of the tapped link. */
|
|
650
1026
|
openLink: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
651
1027
|
}>("himiBlogPost", {
|
|
@@ -669,7 +1045,8 @@ const svc = defineService<S, {
|
|
|
669
1045
|
const after = countsOf(((await likePost(s.id))?.post ?? {}) as BlogPostShape);
|
|
670
1046
|
forgetFetch();
|
|
671
1047
|
const now = samePost(s);
|
|
672
|
-
|
|
1048
|
+
// No message: the filled heart and the count show the change.
|
|
1049
|
+
return now ? derive({ ...now, liked: true, ...countsAfter(now, after, 1) }) : undefined;
|
|
673
1050
|
} catch (error) {
|
|
674
1051
|
const now = samePost(s);
|
|
675
1052
|
if (!now) return undefined;
|
|
@@ -686,7 +1063,7 @@ const svc = defineService<S, {
|
|
|
686
1063
|
const after = countsOf(((await unlikePost(s.id))?.post ?? {}) as BlogPostShape);
|
|
687
1064
|
forgetFetch();
|
|
688
1065
|
const now = samePost(s);
|
|
689
|
-
return now ?
|
|
1066
|
+
return now ? derive({ ...now, liked: false, ...countsAfter(now, after, -1) }) : undefined;
|
|
690
1067
|
} catch (error) {
|
|
691
1068
|
const now = samePost(s);
|
|
692
1069
|
if (!now) return undefined;
|
|
@@ -736,40 +1113,113 @@ const svc = defineService<S, {
|
|
|
736
1113
|
// Opened: keep the state as it is now (the browser may have been open for a while).
|
|
737
1114
|
return (await openRichLink({ url: s.shareUrl })) ? undefined : say(s, copyParam("blogPost.linkOpenFailed", "This link could not be opened."));
|
|
738
1115
|
},
|
|
739
|
-
setComment: (s, arg) => derive({ ...s, commentText: strOf(arg) }),
|
|
1116
|
+
setComment: (s, arg) => derive({ ...s, commentText: strOf(arg), sendError: "" }),
|
|
740
1117
|
submitComment: async (s) => {
|
|
741
1118
|
const text = s.commentText.trim();
|
|
742
|
-
if (s.commentsOff) return s;
|
|
743
|
-
if (!text) return
|
|
744
|
-
if (!s.commentResourceId) return
|
|
1119
|
+
if (s.commentsOff || sendInFlight === s.id) return s;
|
|
1120
|
+
if (!text) return derive({ ...s, sendError: copyParam("blogPost.commentValidation", "Write a comment first.") });
|
|
1121
|
+
if (!s.commentResourceId) return derive({ ...s, sendError: copyParam("blogPost.commentsUnavailable", "Comments are unavailable right now.") });
|
|
1122
|
+
const parentId = s.replyToId;
|
|
1123
|
+
sendInFlight = s.id;
|
|
745
1124
|
try {
|
|
746
|
-
const
|
|
747
|
-
comment: { appId: BLOG_COMMENTS_APP_ID, contextId: s.commentResourceId, resourceId: s.commentResourceId, content: { richContent: commentRichContent(text) } },
|
|
748
|
-
});
|
|
1125
|
+
const created = await postBlogComment(s.commentResourceId, text, parentId || undefined);
|
|
749
1126
|
forgetFetch();
|
|
750
1127
|
const now = samePost(s);
|
|
751
1128
|
if (!now) return undefined;
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
const
|
|
1129
|
+
// The reader's own name and photo at once, never "Member" first.
|
|
1130
|
+
const authorId = created.authorMemberId || now.memberId;
|
|
1131
|
+
const row = { ...toCommentRow({ ...created, ...(authorId ? { authorMemberId: authorId } : {}) }, meAsAuthors(now, authorId), new Set()), highlight: true, rowBackground: HIGHLIGHT };
|
|
755
1132
|
// An unknown count (no METRICS, no comment list) stays unknown: one more of an unknown number is not 1.
|
|
756
1133
|
const total = now.commentCount === "" ? null : Math.max(Number(now.commentCount) || 0, now.comments.length) + 1;
|
|
757
|
-
|
|
1134
|
+
// The keyboard closes; the sheet stays open on the new comment.
|
|
1135
|
+
void dismissKeyboard().catch(() => undefined);
|
|
1136
|
+
return derive({
|
|
758
1137
|
...now,
|
|
759
1138
|
// Text typed while the comment was sending stays in the box.
|
|
760
1139
|
commentText: now.commentText.trim() === text ? "" : now.commentText,
|
|
761
|
-
|
|
1140
|
+
// Only the reply that was sent is done: a Reply started while it was on its way stays.
|
|
1141
|
+
...(now.replyToId === parentId ? { replyToId: "", replyingLine: "" } : {}),
|
|
1142
|
+
sendError: "",
|
|
1143
|
+
comments: insertComment(now.comments, row),
|
|
762
1144
|
commentCount: total === null ? "" : String(total),
|
|
763
|
-
commentsTitle: commentsTitleFor(total ?? 0),
|
|
764
1145
|
commentsUnavailable: false,
|
|
765
1146
|
commentStatusText: "",
|
|
766
|
-
}
|
|
1147
|
+
});
|
|
767
1148
|
} catch (error) {
|
|
768
|
-
// A refusal opens sign-in
|
|
769
|
-
//
|
|
1149
|
+
// A refusal opens sign-in, and the sheet comes back after it with the same reply and text; any
|
|
1150
|
+
// other failure says so under the field and keeps the text to send again.
|
|
770
1151
|
const now = samePost(s);
|
|
771
1152
|
if (!now) return undefined;
|
|
772
|
-
|
|
1153
|
+
if (readAccessDenied(error)) { markComposer(now); return signIn(now); }
|
|
1154
|
+
return derive({ ...now, sendError: copyParam("blogPost.commentSendFailed", "Your comment was not sent. Try again.") });
|
|
1155
|
+
} finally {
|
|
1156
|
+
sendInFlight = "";
|
|
1157
|
+
}
|
|
1158
|
+
},
|
|
1159
|
+
// No focus token: a field that mounts with a non-empty one takes focus, and "Show all" opens no keyboard.
|
|
1160
|
+
openComments: (s) => s.hasPost ? derive({ ...s, commentsSheetOpen: true, moreSheetOpen: false, hideSheetOpen: false, composerFocus: "" }) : s,
|
|
1161
|
+
openComposer: (s) => {
|
|
1162
|
+
if (!s.hasPost || s.commentsOff) return s;
|
|
1163
|
+
if (!s.isMember) { writeComposerMark({ id: s.id, at: Date.now() }); return signIn(s); }
|
|
1164
|
+
return derive({ ...s, commentsSheetOpen: true, moreSheetOpen: false, hideSheetOpen: false, composerFocus: nonce() });
|
|
1165
|
+
},
|
|
1166
|
+
closeComments: (s) => derive({
|
|
1167
|
+
...s,
|
|
1168
|
+
commentsSheetOpen: false,
|
|
1169
|
+
composerFocus: "",
|
|
1170
|
+
replyToId: "",
|
|
1171
|
+
replyingLine: "",
|
|
1172
|
+
sendError: "",
|
|
1173
|
+
comments: s.comments.map(unhighlighted),
|
|
1174
|
+
}),
|
|
1175
|
+
replyTo: (s, arg) => {
|
|
1176
|
+
const target = s.comments.find((row) => row.id === argId(arg));
|
|
1177
|
+
if (!target || s.commentsOff) return s;
|
|
1178
|
+
if (!s.isMember) {
|
|
1179
|
+
writeComposerMark({ id: s.id, at: Date.now(), replyTo: target.parentId || target.id, replyName: target.authorName });
|
|
1180
|
+
return signIn(s);
|
|
1181
|
+
}
|
|
1182
|
+
// One level, as the Wix Comments threads are: a reply to a reply goes to the same parent.
|
|
1183
|
+
return derive({
|
|
1184
|
+
...s,
|
|
1185
|
+
commentsSheetOpen: true,
|
|
1186
|
+
replyToId: target.parentId || target.id,
|
|
1187
|
+
replyingLine: copyTemplate("blogPost.replyingTo", "Replying to {name}", { name: target.authorName }),
|
|
1188
|
+
composerFocus: nonce(),
|
|
1189
|
+
});
|
|
1190
|
+
},
|
|
1191
|
+
cancelReply: (s) => derive({ ...s, replyToId: "", replyingLine: "" }),
|
|
1192
|
+
likeComment: (s, arg) => toggleCommentLike(s, argId(arg), true),
|
|
1193
|
+
unlikeComment: (s, arg) => toggleCommentLike(s, argId(arg), false),
|
|
1194
|
+
reportComment: (s, arg) => {
|
|
1195
|
+
const id = argId(arg);
|
|
1196
|
+
const row = s.comments.find((comment) => comment.id === id);
|
|
1197
|
+
if (!row || row.noReport) return s;
|
|
1198
|
+
reportedComments.add(id);
|
|
1199
|
+
return say({ ...s, comments: s.comments.map((comment) => comment.id === id ? { ...comment, noReport: true } : comment) },
|
|
1200
|
+
copyParam("blogPost.commentReportedMessage", "Comment reported"));
|
|
1201
|
+
},
|
|
1202
|
+
_commentLike: (s, arg) => {
|
|
1203
|
+
const { id, liked } = (arg ?? {}) as { id?: unknown; liked?: unknown };
|
|
1204
|
+
if (typeof id !== "string" || typeof liked !== "boolean") return s;
|
|
1205
|
+
return derive({ ...s, comments: s.comments.map((comment) => comment.id === id ? withLike(comment, liked) : comment) });
|
|
1206
|
+
},
|
|
1207
|
+
loadMoreComments: async (s) => {
|
|
1208
|
+
const cursor = s.commentsCursor;
|
|
1209
|
+
if (!cursor || moreCommentsInFlight === cursor) return undefined;
|
|
1210
|
+
moreCommentsInFlight = cursor;
|
|
1211
|
+
try {
|
|
1212
|
+
const page = await fetchComments(s.commentResourceId, s.isMember, cursor);
|
|
1213
|
+
const now = samePost(s);
|
|
1214
|
+
if (!now || now.commentsCursor !== cursor) return undefined;
|
|
1215
|
+
// A failed page keeps what is loaded and its cursor: the next scroll to the end asks again.
|
|
1216
|
+
if (page.unavailable) return undefined;
|
|
1217
|
+
const known = new Set(now.comments.map((row) => row.id));
|
|
1218
|
+
const stamp = Date.now();
|
|
1219
|
+
const added = page.rows.filter((row) => !known.has(row.id)).map((row) => toCommentRow(row, page.authors, page.liked, stamp));
|
|
1220
|
+
return derive({ ...now, comments: [...now.comments, ...added], commentsCursor: page.nextCursor });
|
|
1221
|
+
} finally {
|
|
1222
|
+
moreCommentsInFlight = "";
|
|
773
1223
|
}
|
|
774
1224
|
},
|
|
775
1225
|
// Only http(s), mailto and tel links reach open_url; a refused link, or one nothing opened, says so, and
|
|
@@ -783,6 +1233,7 @@ const svc = defineService<S, {
|
|
|
783
1233
|
});
|
|
784
1234
|
|
|
785
1235
|
committed = () => (svc as { getState?: () => S }).getState?.();
|
|
1236
|
+
showCommentLike = (id, liked) => svc._commentLike({ id, liked });
|
|
786
1237
|
svc.prepare();
|
|
787
1238
|
svc.load();
|
|
788
1239
|
export { svc };
|