@wix/himalaya-cli 0.2008.0 → 0.2009.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/cli.mjs +38 -11
- package/guides/one-app-to-himi-app.md +1 -1
- package/package.json +2 -2
- package/templates/branded-lite/l10n/ar.json +10 -0
- package/templates/branded-lite/l10n/cs.json +10 -0
- package/templates/branded-lite/l10n/da.json +10 -0
- package/templates/branded-lite/l10n/de.json +10 -0
- package/templates/branded-lite/l10n/el.json +10 -0
- package/templates/branded-lite/l10n/es.json +10 -0
- package/templates/branded-lite/l10n/fi.json +10 -0
- package/templates/branded-lite/l10n/fr.json +10 -0
- package/templates/branded-lite/l10n/he.json +10 -0
- package/templates/branded-lite/l10n/hu.json +10 -0
- package/templates/branded-lite/l10n/id.json +10 -0
- package/templates/branded-lite/l10n/it.json +10 -0
- package/templates/branded-lite/l10n/ja.json +10 -0
- package/templates/branded-lite/l10n/ko.json +10 -0
- package/templates/branded-lite/l10n/lt.json +10 -0
- package/templates/branded-lite/l10n/nl.json +10 -0
- package/templates/branded-lite/l10n/no.json +10 -0
- package/templates/branded-lite/l10n/pl.json +10 -0
- package/templates/branded-lite/l10n/pt.json +10 -0
- package/templates/branded-lite/l10n/ru.json +10 -0
- package/templates/branded-lite/l10n/sv.json +10 -0
- package/templates/branded-lite/l10n/th.json +10 -0
- package/templates/branded-lite/l10n/tr.json +10 -0
- package/templates/branded-lite/l10n/uk.json +10 -0
- package/templates/branded-lite/l10n/vi.json +10 -0
- package/templates/branded-lite/l10n/zh.json +10 -0
- package/templates/branded-lite/recipes/group-feed.json +135 -5
- package/templates/branded-lite/recipes/groups-newsfeed.json +241 -95
- package/templates/branded-lite/tier5-src/_shared/group-feed-section.ts +131 -17
- package/templates/branded-lite/tier5-src/_shared/groups-newsfeed-section.ts +8 -5
- package/templates/branded-lite/tier5-src/_shared/groups-section.ts +7 -1
|
@@ -4,15 +4,21 @@
|
|
|
4
4
|
// A group that is not public is shown the way the group screen shows it to someone who is not a member: its name, its privacy and the
|
|
5
5
|
// invitation message, and the feed is never read, so no post of a private group reaches the page. A public group whose feed Wix refuses
|
|
6
6
|
// the viewer (401/403: the feed read is a member scope) shows the same state with its own sentence.
|
|
7
|
-
// Each post has the source's Like and Share
|
|
8
|
-
//
|
|
7
|
+
// Each post has the source's Like, Comment and Share. The feed read's permissions decide what a tap does, never whether the control shows:
|
|
8
|
+
// the One App shows Like and Comment to a visitor and to a member outside the group too, and asks them to sign in or join first. So a
|
|
9
|
+
// viewer the read lets react likes in place, one it lets comment opens a comment field under the post (the comment goes to the post
|
|
10
|
+
// through the Comments API's Groups scope), and a viewer the read refuses is sent to sign in (a visitor) or to the group to join it (a
|
|
11
|
+
// member). The section also shows a sign-in or join gate (`noSignInGate` / `noJoinGate`) when the viewer may neither like nor comment.
|
|
12
|
+
// A read that names no permissions grants nothing and gates nothing: no Like, no Comment, no Share.
|
|
9
13
|
// A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe group-feed.json).
|
|
10
|
-
import { defineService } from "@himalaya/state";
|
|
14
|
+
import { defineService, navigate } from "@himalaya/state";
|
|
11
15
|
import { hostSessionFromGlobal } from "@himalaya/iap";
|
|
12
16
|
import { share as shareSheet } from "@himalaya/share";
|
|
13
17
|
import { memberAccess } from "./member-access.js";
|
|
14
18
|
import { getGroup, type WixGroup } from "@himalaya/wix-groups";
|
|
15
19
|
import { DEFAULT_REACTION, listFeedItems, reactToFeedItem, unreactFeedItem, type WixFeedItem, type WixFeedItemPermissions, type WixFeedProfile, type WixListFeedItemsResponse } from "@himalaya/wix-social-feed";
|
|
20
|
+
import { createGroupPostComment } from "@himalaya/wix-comments";
|
|
21
|
+
import { memberScreenNav } from "./member-screen.js";
|
|
16
22
|
import { copyParam, stashCopy } from "./himi-copy.js";
|
|
17
23
|
import { initials } from "./himi-text.js";
|
|
18
24
|
import { groupPrivacyLabel } from "./group-privacy.js";
|
|
@@ -37,20 +43,34 @@ export interface GroupFeedRow {
|
|
|
37
43
|
likes?: number; likeLabel: string;
|
|
38
44
|
/** The viewer has liked the post: the next tap removes the like. */
|
|
39
45
|
liked: boolean;
|
|
40
|
-
/** The viewer may
|
|
46
|
+
/** The viewer may react to the post: a tap likes it. Otherwise a tap on the Like signs in or opens the group to join it. */
|
|
47
|
+
mayLike: boolean;
|
|
48
|
+
/** The read named no permissions for the post: the like is hidden (nothing says what a tap would do). */
|
|
41
49
|
noLike: boolean;
|
|
42
|
-
/** The
|
|
50
|
+
/** The post's comment count as the feed gives it, and Comment's label ("Comment", "Comment · 2"). */
|
|
51
|
+
comments?: number; commentLabel: string;
|
|
52
|
+
/** The viewer may comment on the post: a tap opens the comment field. Otherwise a tap signs in or opens the group to join it. */
|
|
53
|
+
mayComment: boolean;
|
|
54
|
+
/** The read named no permissions for the post: Comment is hidden. */
|
|
55
|
+
noComment: boolean;
|
|
56
|
+
/** The comment field under the post is closed (it opens on the viewer's Comment tap, one post at a time). */
|
|
57
|
+
noComposer: boolean;
|
|
58
|
+
/** The read named the viewer's permissions and they refuse both the like and the comment: the post counts toward the sign-in or join gate. */
|
|
43
59
|
gated: boolean;
|
|
44
60
|
/** The viewer may not share the post: the share is hidden. */
|
|
45
61
|
noShare: boolean;
|
|
46
|
-
/** Neither Like nor Share: the post's action row is hidden. */
|
|
62
|
+
/** Neither Like, Comment nor Share: the post's action row is hidden. */
|
|
47
63
|
noActions: boolean;
|
|
48
64
|
}
|
|
49
65
|
|
|
66
|
+
/** The comment field the sections share: what is typed in it, and what the last send did ("" when nothing to say). */
|
|
67
|
+
export interface CommentFields { commentText: string; commentMessage: string; noCommentMessage: boolean }
|
|
68
|
+
export const commentIdle = (message = ""): CommentFields => ({ commentText: "", commentMessage: message, noCommentMessage: !message });
|
|
69
|
+
|
|
50
70
|
/** Which gate shows instead of the posts' Like: none while the viewer may react (or there is no post). */
|
|
51
71
|
export interface FeedGates { noSignInGate: boolean; noJoinGate: boolean }
|
|
52
72
|
|
|
53
|
-
export interface GroupFeedState extends FeedGates {
|
|
73
|
+
export interface GroupFeedState extends FeedGates, CommentFields {
|
|
54
74
|
status: "loading" | "ready" | "error";
|
|
55
75
|
rows: GroupFeedRow[];
|
|
56
76
|
/** The group's name and privacy label, shown with the restricted state. */
|
|
@@ -92,15 +112,24 @@ const likeFields = (liked: boolean, count: number | undefined): Pick<GroupFeedRo
|
|
|
92
112
|
return { liked, likes: count, likeLabel: `\u{1F44D} ${verb}${count === undefined ? "" : ` · ${count}`}` };
|
|
93
113
|
};
|
|
94
114
|
|
|
115
|
+
/** Comment's label: the app's one "Comment" key, with the feed's count once there is a comment. */
|
|
116
|
+
const commentFields = (count: number | undefined): Pick<GroupFeedRow, "comments" | "commentLabel"> => {
|
|
117
|
+
const verb = copyParam("forum.commentCta", "Comment");
|
|
118
|
+
return { comments: count, commentLabel: count ? `${verb} · ${count}` : verb };
|
|
119
|
+
};
|
|
120
|
+
|
|
95
121
|
/** What the viewer may do to a feed read's posts: anyone's (`all`) and their own (`own`); `undefined` when the read names none. */
|
|
96
122
|
export type FeedPermissions = { all?: WixFeedItemPermissions; own?: WixFeedItemPermissions } | undefined;
|
|
97
123
|
export const feedPermissions = (feed: WixListFeedItemsResponse): FeedPermissions =>
|
|
98
124
|
feed.permissions ? { all: feed.permissions.allFeedItemPermissions, own: feed.permissions.ownFeedItemPermissions } : undefined;
|
|
99
125
|
|
|
100
|
-
/** Whether the viewer's member id is worth reading: only a signed-in viewer who may like some post of the read
|
|
126
|
+
/** Whether the viewer's member id is worth reading: only a signed-in viewer who may like or comment on some post of the read needs it,
|
|
127
|
+
* to find their own like and to apply the own-post permissions (`own`) to their own posts. A viewer whose own posts take comments but
|
|
128
|
+
* no reaction needs it too, or their own posts would follow the everyone-else permissions. */
|
|
101
129
|
export const mayLikeAny = (feed: WixListFeedItemsResponse, signedIn: boolean): boolean => {
|
|
102
130
|
const permissions = feedPermissions(feed);
|
|
103
|
-
|
|
131
|
+
const acts = (granted: WixFeedItemPermissions | undefined) => granted?.canReact === true || granted?.canAddComment === true;
|
|
132
|
+
return signedIn && (acts(permissions?.all) || acts(permissions?.own) || (feed.feedItems ?? []).some((item) => acts(item.permissions)));
|
|
104
133
|
};
|
|
105
134
|
|
|
106
135
|
/** The signed-in member's id, to find their own reaction and posts ("" when not `wanted` — see mayLikeAny — or when it cannot be read).
|
|
@@ -112,26 +141,43 @@ export async function viewerMemberId(wanted: boolean): Promise<string> {
|
|
|
112
141
|
}
|
|
113
142
|
|
|
114
143
|
/** A post's row. The feed's permissions apply (its `own` set to the viewer's own post), and the post's own fields override them one by
|
|
115
|
-
* one; with none at all the post grants nothing: no Like, no Share, and no gate.
|
|
144
|
+
* one; with none at all the post grants nothing: no Like, no Comment, no Share, and no gate. With some, Like and Comment always show
|
|
145
|
+
* (as the One App shows them), and the permissions say whether a tap acts or asks the viewer to sign in or join first. */
|
|
116
146
|
export function postRow(item: WixFeedItem, profiles: WixFeedProfile[], now: number, groupId: string, permissions: FeedPermissions, viewerId = ""): GroupFeedRow {
|
|
117
147
|
const { name, avatar } = authorOf(item, profiles);
|
|
118
148
|
const mine = !!viewerId && item.author?.id === viewerId;
|
|
119
149
|
const feedLevel = mine ? permissions?.own ?? permissions?.all : permissions?.all;
|
|
120
150
|
const named = feedLevel || item.permissions ? { ...feedLevel, ...item.permissions } : undefined;
|
|
121
151
|
const granted: WixFeedItemPermissions = named ?? {};
|
|
122
|
-
const
|
|
152
|
+
const mayLike = granted.canReact === true, mayComment = granted.canAddComment === true;
|
|
153
|
+
const noLike = !mayLike && named === undefined, noComment = !mayComment && named === undefined, noShare = granted.canShare !== true;
|
|
123
154
|
// The section's Like is the 👍 reaction: another reaction the member left is not this like.
|
|
124
155
|
const liked = !!viewerId && (item.reactionsList ?? []).some((reaction) => reaction.userId === viewerId && reaction.reaction === DEFAULT_REACTION);
|
|
156
|
+
const count = typeof item.commentsCount === "number" && item.commentsCount >= 0 ? item.commentsCount : undefined;
|
|
125
157
|
return {
|
|
126
158
|
id: item.feedItemId || "", author: name, initials: initials(name),
|
|
127
159
|
avatar,
|
|
128
160
|
text: postText(item), timeLabel: relativeTime(item.created ?? item.createdAt, now),
|
|
129
|
-
groupId, ...likeFields(liked, undefined),
|
|
130
|
-
noLike,
|
|
161
|
+
groupId, ...likeFields(liked, undefined), ...commentFields(count),
|
|
162
|
+
mayLike, noLike, mayComment, noComment, noComposer: true, noShare, noActions: noLike && noComment && noShare,
|
|
163
|
+
gated: named !== undefined && !mayLike && !mayComment,
|
|
131
164
|
};
|
|
132
165
|
}
|
|
133
166
|
|
|
134
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* A refused Like or Comment: the One App's gated control. A visitor signs in and comes back to the group; a member is taken to the group,
|
|
169
|
+
* where its Join (or Request to join) is. The session is read at the tap. The recipe names both screens (`screenId`, `signInScreenId`).
|
|
170
|
+
*/
|
|
171
|
+
async function gatedTap<S extends object>(state: S, row: GroupFeedRow, arg: unknown): Promise<S | undefined> {
|
|
172
|
+
const field = (key: string): string => { const v = (arg as Record<string, unknown> | undefined)?.[key]; return typeof v === "string" ? v : ""; };
|
|
173
|
+
const screenId = field("screenId");
|
|
174
|
+
if (!screenId) return undefined;
|
|
175
|
+
const viewer = await memberAccess();
|
|
176
|
+
const nav = memberScreenNav({ screenId, id: row.groupId, signInScreenId: field("signInScreenId") }, viewer.signedIn === true ? viewer.email || "signed-in" : viewer.email);
|
|
177
|
+
return nav ? navigate(state, nav) : undefined;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** The gate shown when no post may be liked or commented on: sign in for a visitor, join the group for a member. Only posts whose read
|
|
135
181
|
* named the viewer's permissions count (`gated`): a read without them shows no gate, so a member is never asked to join. */
|
|
136
182
|
export const feedGates = (rows: GroupFeedRow[], signedIn: boolean): FeedGates => {
|
|
137
183
|
const gated = rows.length > 0 && rows.every((row) => row.gated);
|
|
@@ -141,7 +187,8 @@ export const feedGates = (rows: GroupFeedRow[], signedIn: boolean): FeedGates =>
|
|
|
141
187
|
/**
|
|
142
188
|
* The sections' `like` action: the first tap likes the post, the next one removes that like, as the source's Like toggles. A tap while
|
|
143
189
|
* the post's last one is still out is ignored. An answer that arrives after the section loaded again (`generation` moved: a refresh, or
|
|
144
|
-
* another viewer signed in) is dropped, so it never marks the next viewer's post. A failed call leaves the post as it was.
|
|
190
|
+
* another viewer signed in) is dropped, so it never marks the next viewer's post. A failed call leaves the post as it was. A viewer the
|
|
191
|
+
* read does not let react is sent to sign in or to the group instead (`gatedTap`): nothing is sent to Wix for them.
|
|
145
192
|
*/
|
|
146
193
|
export function likeAction<R extends GroupFeedRow, S extends { rows: R[] }>(current: () => S, generation: () => number) {
|
|
147
194
|
const pending = new Set<string>();
|
|
@@ -149,6 +196,7 @@ export function likeAction<R extends GroupFeedRow, S extends { rows: R[] }>(curr
|
|
|
149
196
|
const row = state.rows.find((candidate) => candidate.id === idOf(arg));
|
|
150
197
|
const key = row ? `${row.groupId}/${row.id}` : "";
|
|
151
198
|
if (!row || row.noLike || pending.has(key)) return undefined;
|
|
199
|
+
if (!row.mayLike) return gatedTap(current(), row, arg);
|
|
152
200
|
pending.add(key);
|
|
153
201
|
const started = generation();
|
|
154
202
|
try {
|
|
@@ -174,6 +222,71 @@ export async function sharePost<R extends GroupFeedRow>(rows: R[], arg: unknown,
|
|
|
174
222
|
try { await shareSheet({ subject: groupName(row), text: `${row.author}: ${row.text}` }); } catch { /* the sheet is best-effort */ }
|
|
175
223
|
}
|
|
176
224
|
|
|
225
|
+
const textOf = (arg: unknown): string => {
|
|
226
|
+
if (typeof arg === "string") return arg;
|
|
227
|
+
const value = (arg as { value?: unknown; text?: unknown } | undefined)?.value ?? (arg as { text?: unknown } | undefined)?.text;
|
|
228
|
+
return typeof value === "string" ? value : "";
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The sections' comment actions. `comment` is the post's Comment tap: a viewer the read lets comment opens (or closes) the field under that
|
|
233
|
+
* post, one post at a time; any other viewer is sent to sign in or to the group (`gatedTap`). `sendComment` posts what was typed to the
|
|
234
|
+
* post through the Comments API (`createGroupPostComment`: the Groups scope, the group as context and the post as resource). A send in
|
|
235
|
+
* flight for the post ignores a second tap, and an answer after the section loaded again (`generation` moved) is dropped. A failed send
|
|
236
|
+
* keeps the text and says so.
|
|
237
|
+
*/
|
|
238
|
+
export type CommentActions<S> = {
|
|
239
|
+
comment: (state: S, arg?: unknown) => Promise<S | undefined>;
|
|
240
|
+
setComment: (state: S, arg?: unknown) => S;
|
|
241
|
+
cancelComment: (state: S) => S;
|
|
242
|
+
sendComment: (state: S, arg?: unknown) => Promise<S | undefined>;
|
|
243
|
+
};
|
|
244
|
+
export function commentActions<R extends GroupFeedRow, S extends { rows: R[] } & CommentFields>(current: () => S, generation: () => number): CommentActions<S> {
|
|
245
|
+
const sending = new Set<string>();
|
|
246
|
+
const close = (rows: R[]): R[] => rows.map((row) => (row.noComposer ? row : { ...row, noComposer: true }));
|
|
247
|
+
return {
|
|
248
|
+
comment: async (state: S, arg: unknown): Promise<S | undefined> => {
|
|
249
|
+
const row = state.rows.find((candidate) => candidate.id === idOf(arg));
|
|
250
|
+
if (!row || row.noComment) return undefined;
|
|
251
|
+
if (!row.mayComment) return gatedTap(current(), row, arg);
|
|
252
|
+
const now = current();
|
|
253
|
+
const opening = row.noComposer;
|
|
254
|
+
return { ...now, ...commentIdle(), rows: now.rows.map((candidate) => ({ ...candidate, noComposer: !(opening && candidate.id === row.id && candidate.groupId === row.groupId) })) };
|
|
255
|
+
},
|
|
256
|
+
setComment: (state: S, arg: unknown): S => ({ ...state, commentText: textOf(arg) }),
|
|
257
|
+
cancelComment: (state: S): S => ({ ...state, ...commentIdle(), rows: close(state.rows) }),
|
|
258
|
+
sendComment: async (state: S, arg: unknown): Promise<S | undefined> => {
|
|
259
|
+
const row = state.rows.find((candidate) => candidate.id === idOf(arg));
|
|
260
|
+
const text = state.commentText.trim();
|
|
261
|
+
const key = row ? `${row.groupId}/${row.id}` : "";
|
|
262
|
+
if (!row || !row.mayComment || row.noComposer || !text || sending.has(key)) return undefined;
|
|
263
|
+
sending.add(key);
|
|
264
|
+
const started = generation();
|
|
265
|
+
try {
|
|
266
|
+
await createGroupPostComment(row.groupId, row.id, text);
|
|
267
|
+
if (generation() !== started) return undefined;
|
|
268
|
+
const now = current();
|
|
269
|
+
const posted = copyParam("groupFeed.commentPostedMessage", "Your comment was posted.");
|
|
270
|
+
const counted = (rows: R[]): R[] => rows.map((candidate) => candidate.id === row.id && candidate.groupId === row.groupId
|
|
271
|
+
// A count the feed gave moves by one; an unknown one stays unknown (the reader's own comment is not the post's total).
|
|
272
|
+
? { ...candidate, ...commentFields(candidate.comments === undefined ? undefined : candidate.comments + 1) } : candidate);
|
|
273
|
+
// The field closes and empties only while it still holds this send: this post's field, with the text that was sent. A reader
|
|
274
|
+
// who moved on to another post's field, or typed something new, while this send was out keeps that field and their text.
|
|
275
|
+
const stillOpen = now.rows.some((candidate) => candidate.id === row.id && candidate.groupId === row.groupId && !candidate.noComposer);
|
|
276
|
+
if (!stillOpen || now.commentText.trim() !== text) return { ...now, commentMessage: posted, noCommentMessage: false, rows: counted(now.rows) };
|
|
277
|
+
return { ...now, ...commentIdle(posted), rows: counted(close(now.rows)) };
|
|
278
|
+
} catch (error) {
|
|
279
|
+
if (generation() !== started) return undefined;
|
|
280
|
+
console.warn("group feed: the comment could not be sent", error);
|
|
281
|
+
const message = copyParam("groupFeed.commentFailedMessage", "The comment could not be posted. Try again.");
|
|
282
|
+
return { ...current(), commentMessage: message, noCommentMessage: false };
|
|
283
|
+
} finally {
|
|
284
|
+
sending.delete(key);
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
177
290
|
const idOf = (arg: unknown): string => typeof arg === "string" ? arg : String((arg as { id?: unknown } | undefined)?.id ?? "");
|
|
178
291
|
|
|
179
292
|
/** The feed read is a member scope: Wix answers a viewer it will not show with `HTTP 401` / `HTTP 403`. */
|
|
@@ -187,7 +300,7 @@ export function registerGroupFeedSection(serviceName: string, options: GroupFeed
|
|
|
187
300
|
emptyText: status === "ready" && !rows.length && !restrictedText ? copyParam("groupFeed.emptyText", "No posts in this group yet.") : "",
|
|
188
301
|
notLoading: status !== "loading", notErrored: status !== "error",
|
|
189
302
|
noRows: !rows.length, noEmpty: !(status === "ready" && !rows.length && !restrictedText), noRestricted: !restrictedText,
|
|
190
|
-
...feedGates(rows, parts.signedIn === true), noShortcuts: status !== "ready",
|
|
303
|
+
...feedGates(rows, parts.signedIn === true), noShortcuts: status !== "ready", ...commentIdle(),
|
|
191
304
|
};
|
|
192
305
|
};
|
|
193
306
|
const session = hostSessionFromGlobal();
|
|
@@ -198,7 +311,7 @@ export function registerGroupFeedSection(serviceName: string, options: GroupFeed
|
|
|
198
311
|
const service = defineService<GroupFeedState, {
|
|
199
312
|
load: (state: GroupFeedState, arg?: unknown) => Promise<GroupFeedState | undefined>; clear: () => Promise<GroupFeedState>;
|
|
200
313
|
like: (state: GroupFeedState, arg?: unknown) => Promise<GroupFeedState | undefined>; share: (state: GroupFeedState, arg?: unknown) => Promise<GroupFeedState | undefined>;
|
|
201
|
-
}
|
|
314
|
+
} & CommentActions<GroupFeedState>>(serviceName, {
|
|
202
315
|
state: view("loading"),
|
|
203
316
|
// A group's posts are member-scoped: never written to disk and restored for the next person on the device.
|
|
204
317
|
notHydrated: Object.keys(view("loading")) as Array<keyof GroupFeedState>,
|
|
@@ -241,6 +354,7 @@ export function registerGroupFeedSection(serviceName: string, options: GroupFeed
|
|
|
241
354
|
},
|
|
242
355
|
like: likeAction((): GroupFeedState => service.getState(), () => sequence),
|
|
243
356
|
share: async (state, arg) => { await sharePost(state.rows, arg, () => state.groupName); return undefined; },
|
|
357
|
+
...commentActions((): GroupFeedState => service.getState(), () => sequence),
|
|
244
358
|
},
|
|
245
359
|
});
|
|
246
360
|
// Signing in or out on another screen changes who the feed is read for.
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
// It is the single-group feed (group-feed-section.ts) read for several groups and merged: the same post rows, and the same rule that a group
|
|
5
5
|
// which is not public is never read, so no post of a private group reaches the page. A public group whose feed Wix refuses the viewer
|
|
6
6
|
// (401/403: the feed read is a member scope) adds nothing; when every group refuses, the section says posts are for members.
|
|
7
|
-
// A post has the Like and Share
|
|
7
|
+
// A post has the Like, Comment and Share of the single-group feed, read against its own group's feed permissions: a refused Like or
|
|
8
|
+
// Comment still shows and sends the viewer to sign in or to the post's group to join it; when no post may be liked or commented on, a
|
|
9
|
+
// sign-in or join gate shows too.
|
|
8
10
|
// A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe groups-newsfeed.json).
|
|
9
11
|
import { defineService } from "@himalaya/state";
|
|
10
12
|
import { hostSessionFromGlobal } from "@himalaya/iap";
|
|
@@ -12,7 +14,7 @@ import { memberAccess } from "./member-access.js";
|
|
|
12
14
|
import { queryGroups, type WixGroup } from "@himalaya/wix-groups";
|
|
13
15
|
import { listFeedItems } from "@himalaya/wix-social-feed";
|
|
14
16
|
import { copyParam, stashCopy } from "./himi-copy.js";
|
|
15
|
-
import { feedGates, feedPermissions, isRefusal, likeAction, mayLikeAny, postRow, viewerMemberId, sharePost, type FeedGates, type GroupFeedRow } from "./group-feed-section.js";
|
|
17
|
+
import { commentActions, commentIdle, feedGates, feedPermissions, isRefusal, likeAction, mayLikeAny, postRow, viewerMemberId, sharePost, type CommentActions, type CommentFields, type FeedGates, type GroupFeedRow } from "./group-feed-section.js";
|
|
16
18
|
|
|
17
19
|
export interface GroupsNewsfeedOptions {
|
|
18
20
|
/** Show only these groups' posts. */
|
|
@@ -26,7 +28,7 @@ export interface NewsfeedRow extends GroupFeedRow {
|
|
|
26
28
|
groupName: string;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
export interface GroupsNewsfeedState extends FeedGates {
|
|
31
|
+
export interface GroupsNewsfeedState extends FeedGates, CommentFields {
|
|
30
32
|
status: "loading" | "ready" | "error";
|
|
31
33
|
rows: NewsfeedRow[];
|
|
32
34
|
/** Why the posts are not shown ("" when they are): every group's feed refused the viewer. */
|
|
@@ -51,7 +53,7 @@ export function registerGroupsNewsfeedSection(serviceName: string, options: Grou
|
|
|
51
53
|
return {
|
|
52
54
|
status, rows, restrictedText, emptyText: empty ? copyParam("feed.emptyText", "Nothing has been posted yet — start the conversation.") : "",
|
|
53
55
|
notLoading: status !== "loading", notErrored: status !== "error", noRows: !rows.length, noEmpty: !empty, noRestricted: !restrictedText,
|
|
54
|
-
...feedGates(rows, parts.signedIn === true),
|
|
56
|
+
...feedGates(rows, parts.signedIn === true), ...commentIdle(),
|
|
55
57
|
};
|
|
56
58
|
};
|
|
57
59
|
const session = hostSessionFromGlobal();
|
|
@@ -62,7 +64,7 @@ export function registerGroupsNewsfeedSection(serviceName: string, options: Grou
|
|
|
62
64
|
const service = defineService<GroupsNewsfeedState, {
|
|
63
65
|
load: (state: GroupsNewsfeedState, arg?: unknown) => Promise<GroupsNewsfeedState | undefined>; clear: () => Promise<GroupsNewsfeedState>;
|
|
64
66
|
like: (state: GroupsNewsfeedState, arg?: unknown) => Promise<GroupsNewsfeedState | undefined>; share: (state: GroupsNewsfeedState, arg?: unknown) => Promise<GroupsNewsfeedState | undefined>;
|
|
65
|
-
}
|
|
67
|
+
} & CommentActions<GroupsNewsfeedState>>(serviceName, {
|
|
66
68
|
state: view("loading"),
|
|
67
69
|
// The posts are member-scoped: never written to disk and restored for the next person on the device.
|
|
68
70
|
notHydrated: Object.keys(view("loading")) as Array<keyof GroupsNewsfeedState>,
|
|
@@ -105,6 +107,7 @@ export function registerGroupsNewsfeedSection(serviceName: string, options: Grou
|
|
|
105
107
|
},
|
|
106
108
|
like: likeAction((): GroupsNewsfeedState => service.getState(), () => sequence),
|
|
107
109
|
share: async (state, arg) => { await sharePost(state.rows, arg, (row) => row.groupName); return undefined; },
|
|
110
|
+
...commentActions((): GroupsNewsfeedState => service.getState(), () => sequence),
|
|
108
111
|
},
|
|
109
112
|
});
|
|
110
113
|
// Signing in or out on another screen changes who the feed is read for.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// confirmed public call that submits a join request: the group screen is where its policy is explained);
|
|
8
8
|
// a group the member joined or asked to join -> "Joined" / "Pending request", a status rather than a control.
|
|
9
9
|
// A visitor's tap signs in first and then opens the group (the shared member-screen opener). A secret group is listed only to its members.
|
|
10
|
+
// Each row's line under the name is the One App's "Public · 2 members": the group's visibility and its member count.
|
|
10
11
|
// The list's header Search (the source's `groups.openGroupsListSearch`) opens a search field in the section: it finds a group by name or
|
|
11
12
|
// teaser among every group the section may show, not only the first `limit` (himi_groups hides its own search on a short list).
|
|
12
13
|
// A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipes groups-list.json, groups-cards.json).
|
|
@@ -17,6 +18,7 @@ import { getMyMember } from "@himalaya/wix-members";
|
|
|
17
18
|
import { groupImage } from "./himi-media.js";
|
|
18
19
|
import { copyParam, stashCopy } from "./himi-copy.js";
|
|
19
20
|
import { groupMemberCount } from "./group-member-count.js";
|
|
21
|
+
import { groupPrivacyLabel } from "./group-privacy.js";
|
|
20
22
|
import { descriptionBody } from "./rich-body.js";
|
|
21
23
|
import { memberIdentity } from "./himi-account.js";
|
|
22
24
|
import { CONTINUATION_BUDGET_MS, memberScreenNav, within } from "./member-screen.js";
|
|
@@ -170,7 +172,11 @@ function groupRow(group: WixGroup, cards: boolean, membership: string | undefine
|
|
|
170
172
|
const image = groupImage(group, cards ? GROUP_CARD : GROUP_THUMB);
|
|
171
173
|
const teaser = descriptionBody(group.teaser).bodyText;
|
|
172
174
|
const body = descriptionBody(group.description, teaser).bodyText;
|
|
173
|
-
|
|
175
|
+
// The One App's line under the name: the group's visibility and its member count ("Public · 2 members"), either one alone when the
|
|
176
|
+
// other is unknown. A status Wix did not send (or sent as UNKNOWN) adds no label.
|
|
177
|
+
const status = privacyOf(group);
|
|
178
|
+
const privacy = status && status !== "UNKNOWN" ? groupPrivacyLabel(status) : "";
|
|
179
|
+
const meta = [privacy, count == null ? "" : groupMemberCount(count)].filter(Boolean).join(" · ");
|
|
174
180
|
return {
|
|
175
181
|
id: group.id || title, title,
|
|
176
182
|
subtitle: snippet(teaser) || snippet(body) || copyParam("groups.subtitleFallback", "Join the conversation."),
|