@gryt/core 0.3.0 → 0.4.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/conversations/title.d.ts +35 -0
- package/dist/conversations/title.js +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a direct conversation is called in a list.
|
|
3
|
+
*
|
|
4
|
+
* Both apps had this and they had drifted: the phone returns "Group" when an
|
|
5
|
+
* unnamed group has no members to name, and the desktop returned an empty
|
|
6
|
+
* string, because `[].join(" and ")` is "". A group whose members have not
|
|
7
|
+
* arrived yet draws a blank row there.
|
|
8
|
+
*
|
|
9
|
+
* The phone's version is the one kept. This is the shape of drift GRYT-406
|
|
10
|
+
* warned about — not two implementations disagreeing loudly, but one of them
|
|
11
|
+
* quietly having a case the other never got.
|
|
12
|
+
*/
|
|
13
|
+
export interface ConversationParticipant {
|
|
14
|
+
server_user_id: string;
|
|
15
|
+
nickname: string;
|
|
16
|
+
avatar_file_id: string | null;
|
|
17
|
+
/** The owl look, so a row draws the same face the member list does. */
|
|
18
|
+
avatar_worn: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface DirectConversation {
|
|
21
|
+
conversation_id: string;
|
|
22
|
+
/** Two people, or more than two. Groups get their own section. */
|
|
23
|
+
kind: "dm" | "group";
|
|
24
|
+
/** What a group was named. Null means read it off `members`. */
|
|
25
|
+
name: string | null;
|
|
26
|
+
/** An upload. Null means draw one from the name. */
|
|
27
|
+
icon_file_id: string | null;
|
|
28
|
+
created_at: string;
|
|
29
|
+
last_message_at: string | null;
|
|
30
|
+
/** Everybody but you. */
|
|
31
|
+
members: ConversationParticipant[];
|
|
32
|
+
/** The first of `members`. The whole story on a one-to-one. */
|
|
33
|
+
other: ConversationParticipant;
|
|
34
|
+
}
|
|
35
|
+
export declare function conversationTitle(conversation: DirectConversation): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a direct conversation is called in a list.
|
|
3
|
+
*
|
|
4
|
+
* Both apps had this and they had drifted: the phone returns "Group" when an
|
|
5
|
+
* unnamed group has no members to name, and the desktop returned an empty
|
|
6
|
+
* string, because `[].join(" and ")` is "". A group whose members have not
|
|
7
|
+
* arrived yet draws a blank row there.
|
|
8
|
+
*
|
|
9
|
+
* The phone's version is the one kept. This is the shape of drift GRYT-406
|
|
10
|
+
* warned about — not two implementations disagreeing loudly, but one of them
|
|
11
|
+
* quietly having a case the other never got.
|
|
12
|
+
*/
|
|
13
|
+
export function conversationTitle(conversation) {
|
|
14
|
+
if (conversation.kind === "dm")
|
|
15
|
+
return conversation.other.nickname;
|
|
16
|
+
if (conversation.name)
|
|
17
|
+
return conversation.name;
|
|
18
|
+
const names = conversation.members.map((m) => m.nickname);
|
|
19
|
+
if (names.length === 0)
|
|
20
|
+
return "Group";
|
|
21
|
+
if (names.length <= 2)
|
|
22
|
+
return names.join(" and ");
|
|
23
|
+
return `${names.slice(0, 2).join(", ")} and ${names.length - 2} more`;
|
|
24
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
export { buildReport, describeAttached, MESSAGE_MAX, TITLE_MAX, type Diagnostics, type Report, type ReportType, } from "./reports/report.js";
|
|
15
15
|
export { getAccentColor, getLinkProvider, getProviderDetail, hostnameOf, LINK_PROVIDERS, type LinkProvider, } from "./links/providers.js";
|
|
16
16
|
export { describePreviewFailure, extractUrls, getCardSubtitle, getLinkCardLayout, type LinkCardLayout, type LinkPreviewData, } from "./links/preview.js";
|
|
17
|
+
export { conversationTitle, type DirectConversation, } from "./conversations/title.js";
|
|
17
18
|
export { normalizeCode, normalizeHost, parseServerInput, type ServerInput, } from "./servers/address.js";
|
|
18
19
|
export { NAME_POOL, pickRandomName } from "./profile/randomName.js";
|
|
19
20
|
export { cellState, CUSTOM_VALUE, describeRules, EVERYONE_VALUE, indexRules, nextCellState, scopeChoiceFromValue, scopeChoiceValue, scopeOptions, scopeSetPayload, withCell, type CellState, type ChannelRule, type RuleEffect, type ScopeChoice, } from "./permissions/channelRules.js";
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
export { buildReport, describeAttached, MESSAGE_MAX, TITLE_MAX, } from "./reports/report.js";
|
|
15
15
|
export { getAccentColor, getLinkProvider, getProviderDetail, hostnameOf, LINK_PROVIDERS, } from "./links/providers.js";
|
|
16
16
|
export { describePreviewFailure, extractUrls, getCardSubtitle, getLinkCardLayout, } from "./links/preview.js";
|
|
17
|
+
export { conversationTitle, } from "./conversations/title.js";
|
|
17
18
|
export { normalizeCode, normalizeHost, parseServerInput, } from "./servers/address.js";
|
|
18
19
|
export { NAME_POOL, pickRandomName } from "./profile/randomName.js";
|
|
19
20
|
export { cellState, CUSTOM_VALUE, describeRules, EVERYONE_VALUE, indexRules, nextCellState, scopeChoiceFromValue, scopeChoiceValue, scopeOptions, scopeSetPayload, withCell, } from "./permissions/channelRules.js";
|
package/package.json
CHANGED