~james/core

core/web/src/fixtures/comments.ts -rw-r--r-- 4.6 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// real comment data pulled from tangled.org/tangled.org/core/issues/245, used across
// the comment stories so the fixtures live in one place.
import type { MarkupContext } from "#lib/markup/index.ts";
import type { CommentPage, CommentThread, CommentView } from "#lib/components/comment/comments.ts";

export const sampleMarkup: MarkupContext = {
	repo: "tangled.org/core",
	ref: "main",
	host: "tangled.org"
};

export const sampleSubjectUri = "at://did:plc:xan/sh.tangled.repo.issue/245";
export const sampleSubjectCid = "bafyreib2rxk3rh6kzwq6yhkp6bd4vjxj3xj2xj2xj2xj2xj2xj2xj2xj4a";

const cid = "bafyreib2rxk3rh6kzwq6yhkp6bd4vjxj3xj2xj2xj2xj2xj2xj2xj2xj2a";

const c = (
	rkey: string,
	authorDid: string,
	authorHandle: string,
	createdAt: string,
	body: string
): CommentView => ({
	uri: `at://${authorDid}/sh.tangled.feed.comment/${rkey}`,
	cid,
	rkey,
	authorDid,
	authorHandle,
	createdAt,
	body
});

export const sampleComments = {
	erin: c(
		"erin",
		"did:plc:erin",
		"erin.tngl.sh",
		"2024-10-02T09:15:00Z",
		`I'm on the cusp, but I reacted "👎", as:

- I quite like the "@"!
- it clearly differentiates between user stuff, and site stuff; \`tangled.org/settings\` vs. \`tangled.org/@settings.in\`
- it feels quite "ATProto" to have an AT☺️

Plus I think I'd keep the @s in the UI anyway (eg. in the header of a repo page "[@tangled.org](/tangled.org)/core") — so then the URLs would match what's displayed.`
	),
	frank: c(
		"frank",
		"did:plc:frank",
		"frank.tngl.sh",
		"2024-10-02T11:00:00Z",
		`I also found these two reasons convincing enough to vote in favor of removal.

One small, silly side effect of this will be that the address for tangled itself will be tangled.org/tangled.org`
	),
	grace: c(
		"grace",
		"did:plc:grace",
		"grace.tngl.sh",
		"2024-10-03T08:20:00Z",
		"I vote removing them. You can tell if it's a handle by the presence of the `.`s"
	),
	heidi: c(
		"heidi",
		"did:plc:heidi",
		"heidi.tngl.sh",
		"2024-10-03T14:05:00Z",
		"i vote yes, i'm probably stupid but i dont think go modules like there being @s in the url so i just use github, i'm sure theres a way around it, but its best to minimize friction"
	),
	bob: c(
		"bob",
		"did:plc:bob",
		"bob.tngl.sh",
		"2024-10-04T10:00:00Z",
		"For what it's worth, we've always supported the non-@ URL as well. We just redirect it to the @'d version—which Go seems to be content with."
	),
	ivan: c(
		"ivan",
		"did:plc:ivan",
		"ivan.tngl.sh",
		"2024-10-05T16:30:00Z",
		`So i'm a 👍 I dig the poetry of having an @ in the URI, but mostly i think it's confusing. This isn't a practice the other Apps & AppServers use. It's also confusing because an AT:// URI is something distinct and different.

And just personally, it's a URL eyesore for me.`
	),
	judy: c(
		"judy",
		"did:plc:judy",
		"judy.tngl.sh",
		"2024-11-10T12:00:00Z",
		"This has tripped me up quite a few times on the SSH URLs with extraneous @s, so thank you for making this change!"
	),
	// authored by the story's logged-in user (MockAuth = did:plc:alice), for edit cases
	mine: c(
		"mine",
		"did:plc:alice",
		"alice.tngl.sh",
		"2024-10-06T09:00:00Z",
		"I vote removing them. You can tell if it's a handle by the presence of the `.`s"
	)
};

// a top-level comment on its own
export const soloThread: CommentThread = { self: sampleComments.erin, replies: [] };

// a thread with a couple of replies
export const sampleThread: CommentThread = {
	self: sampleComments.erin,
	replies: [sampleComments.frank, sampleComments.grace]
};

export const sampleThreads: CommentThread[] = [
	sampleThread,
	{ self: sampleComments.ivan, replies: [] }
];

export const sampleCommentPage: CommentPage = {
	inputs: sampleThreads.flatMap(({ self, replies }) => [
		{ comment: self, replyTo: null },
		...replies.map((comment) => ({ comment, replyTo: self.uri }))
	]),
	cursor: null,
	total: 4
};

// more than one reply, to show the connector line running down the replies
export const multiReplyThread: CommentThread = {
	self: sampleComments.erin,
	replies: [sampleComments.frank, sampleComments.grace, sampleComments.heidi]
};

// a long thread whose middle reply belongs to the logged-in user (for edit-in-place)
export const longThread: CommentThread = {
	self: sampleComments.erin,
	replies: [
		sampleComments.frank,
		sampleComments.heidi,
		sampleComments.mine,
		sampleComments.bob,
		sampleComments.judy
	]
};

export const freshComment = (n: number): CommentView =>
	c(
		`fresh${n}`,
		"did:plc:alice",
		"alice.tngl.sh",
		new Date().toISOString(),
		`Fresh comment number ${n}, posted just now.`
	);

export const reportedComment = {
	uri: "at://did:plc:bob/sh.tangled.feed.comment/aaa",
	cid: "bafyreidfayvfuwqa7qlnopdjiqrxzs6blmoeu4rujcjtnci5beludirz2a"
};