@churchapps/apphelper 0.7.4 → 0.7.5
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/components/conversations/Conversations.d.ts +21 -0
- package/dist/components/conversations/Conversations.d.ts.map +1 -0
- package/dist/components/conversations/Conversations.js +92 -0
- package/dist/components/conversations/Conversations.js.map +1 -0
- package/dist/components/conversations/index.d.ts +2 -0
- package/dist/components/conversations/index.d.ts.map +1 -0
- package/dist/components/conversations/index.js +2 -0
- package/dist/components/conversations/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/notes/AddNote.d.ts.map +1 -1
- package/dist/components/notes/AddNote.js +19 -1
- package/dist/components/notes/AddNote.js.map +1 -1
- package/dist/components/notes/Notes.d.ts.map +1 -1
- package/dist/components/notes/Notes.js +89 -74
- package/dist/components/notes/Notes.js.map +1 -1
- package/dist/components/notes/SubscriptionToggle.d.ts +38 -0
- package/dist/components/notes/SubscriptionToggle.d.ts.map +1 -0
- package/dist/components/notes/SubscriptionToggle.js +76 -0
- package/dist/components/notes/SubscriptionToggle.js.map +1 -0
- package/dist/components/notes/index.d.ts +1 -0
- package/dist/components/notes/index.d.ts.map +1 -1
- package/dist/components/notes/index.js +1 -0
- package/dist/components/notes/index.js.map +1 -1
- package/dist/components/wrapper/PrivateMessages.d.ts.map +1 -1
- package/dist/components/wrapper/PrivateMessages.js +12 -0
- package/dist/components/wrapper/PrivateMessages.js.map +1 -1
- package/dist/helpers/ConversationStore.d.ts +36 -0
- package/dist/helpers/ConversationStore.d.ts.map +1 -0
- package/dist/helpers/ConversationStore.js +238 -0
- package/dist/helpers/ConversationStore.js.map +1 -0
- package/dist/helpers/NotificationService.d.ts +3 -0
- package/dist/helpers/NotificationService.d.ts.map +1 -1
- package/dist/helpers/NotificationService.js +52 -13
- package/dist/helpers/NotificationService.js.map +1 -1
- package/dist/helpers/PresenceStore.d.ts +34 -0
- package/dist/helpers/PresenceStore.d.ts.map +1 -0
- package/dist/helpers/PresenceStore.js +93 -0
- package/dist/helpers/PresenceStore.js.map +1 -0
- package/dist/helpers/SocketHelper.d.ts +17 -0
- package/dist/helpers/SocketHelper.d.ts.map +1 -1
- package/dist/helpers/SocketHelper.js +70 -3
- package/dist/helpers/SocketHelper.js.map +1 -1
- package/dist/helpers/SubscriptionManager.d.ts +23 -0
- package/dist/helpers/SubscriptionManager.d.ts.map +1 -0
- package/dist/helpers/SubscriptionManager.js +118 -0
- package/dist/helpers/SubscriptionManager.js.map +1 -0
- package/dist/helpers/WebPushHelper.d.ts +36 -0
- package/dist/helpers/WebPushHelper.d.ts.map +1 -0
- package/dist/helpers/WebPushHelper.js +180 -0
- package/dist/helpers/WebPushHelper.js.map +1 -0
- package/dist/helpers/__tests__/WebPushHelper.test.d.ts +13 -0
- package/dist/helpers/__tests__/WebPushHelper.test.d.ts.map +1 -0
- package/dist/helpers/__tests__/WebPushHelper.test.js +99 -0
- package/dist/helpers/__tests__/WebPushHelper.test.js.map +1 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +4 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useConversation.d.ts +36 -0
- package/dist/hooks/useConversation.d.ts.map +1 -0
- package/dist/hooks/useConversation.js +152 -0
- package/dist/hooks/useConversation.js.map +1 -0
- package/package.json +18 -10
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UserContextInterface } from "@churchapps/helpers";
|
|
2
|
+
interface Props {
|
|
3
|
+
contentType: string;
|
|
4
|
+
contentId: string;
|
|
5
|
+
groupId?: string;
|
|
6
|
+
context: UserContextInterface;
|
|
7
|
+
canPost?: boolean;
|
|
8
|
+
visibility?: string;
|
|
9
|
+
noWrapper?: boolean;
|
|
10
|
+
showCommentCount?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Realtime conversation surface keyed by (contentType, contentId). Hydrates via
|
|
14
|
+
* GET /conversations/messages/{contentType}/{contentId}, joins the matching room
|
|
15
|
+
* via SubscriptionManager, and re-renders on inbound message/deleteMessage events.
|
|
16
|
+
*
|
|
17
|
+
* Replaces the legacy B1App `notes/Conversations.tsx` + `notes/Conversation.tsx` pair.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Conversations(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=Conversations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Conversations.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/Conversations.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA2C,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AASpG,UAAU,KAAK;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,2CA8GzC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Box, Paper } from "@mui/material";
|
|
5
|
+
import { ApiHelper, Locale } from "../../helpers";
|
|
6
|
+
import { Loading } from "../Loading";
|
|
7
|
+
import { ConversationStore } from "../../helpers/ConversationStore";
|
|
8
|
+
import { SubscriptionManager } from "../../helpers/SubscriptionManager";
|
|
9
|
+
import { Note } from "../notes/Note";
|
|
10
|
+
import { AddNote } from "../notes/AddNote";
|
|
11
|
+
import { SubscriptionToggle, filterVisibleMessages } from "../notes/SubscriptionToggle";
|
|
12
|
+
/**
|
|
13
|
+
* Realtime conversation surface keyed by (contentType, contentId). Hydrates via
|
|
14
|
+
* GET /conversations/messages/{contentType}/{contentId}, joins the matching room
|
|
15
|
+
* via SubscriptionManager, and re-renders on inbound message/deleteMessage events.
|
|
16
|
+
*
|
|
17
|
+
* Replaces the legacy B1App `notes/Conversations.tsx` + `notes/Conversation.tsx` pair.
|
|
18
|
+
*/
|
|
19
|
+
export function Conversations(props) {
|
|
20
|
+
const canPost = props.canPost !== false;
|
|
21
|
+
const churchId = props.context?.userChurch?.church?.id;
|
|
22
|
+
const personId = props.context?.person?.id;
|
|
23
|
+
const [conversation, setConversation] = React.useState(null);
|
|
24
|
+
const [hydrated, setHydrated] = React.useState(false);
|
|
25
|
+
const [editMessageId, setEditMessageId] = React.useState(null);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
let cancelled = false;
|
|
28
|
+
let unsubscribe = null;
|
|
29
|
+
let joinedConversationId = null;
|
|
30
|
+
const run = async () => {
|
|
31
|
+
setHydrated(false);
|
|
32
|
+
setConversation(null);
|
|
33
|
+
if (!props.contentId || !props.contentType) {
|
|
34
|
+
setHydrated(true);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const initial = await ConversationStore.loadByContent(props.contentType, props.contentId);
|
|
38
|
+
if (cancelled)
|
|
39
|
+
return;
|
|
40
|
+
if (initial?.id) {
|
|
41
|
+
unsubscribe = ConversationStore.subscribe(initial.id, (conv) => {
|
|
42
|
+
if (!cancelled)
|
|
43
|
+
setConversation(conv);
|
|
44
|
+
});
|
|
45
|
+
if (churchId) {
|
|
46
|
+
joinedConversationId = initial.id;
|
|
47
|
+
SubscriptionManager.joinRoom(initial.id, churchId, personId).catch(() => { });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
setHydrated(true);
|
|
51
|
+
};
|
|
52
|
+
run();
|
|
53
|
+
return () => {
|
|
54
|
+
cancelled = true;
|
|
55
|
+
if (unsubscribe)
|
|
56
|
+
unsubscribe();
|
|
57
|
+
if (joinedConversationId && churchId)
|
|
58
|
+
SubscriptionManager.leaveRoom(joinedConversationId, churchId).catch(() => { });
|
|
59
|
+
};
|
|
60
|
+
}, [props.contentType, props.contentId, churchId, personId]);
|
|
61
|
+
const createConversation = async () => {
|
|
62
|
+
const newConv = {
|
|
63
|
+
contentType: props.contentType,
|
|
64
|
+
contentId: props.contentId,
|
|
65
|
+
groupId: props.groupId,
|
|
66
|
+
visibility: props.visibility ?? "public",
|
|
67
|
+
title: `${props.contentType}-${props.contentId} Conversation`,
|
|
68
|
+
allowAnonymousPosts: false
|
|
69
|
+
};
|
|
70
|
+
const result = await ApiHelper.post("/conversations", [newConv], "MessagingApi");
|
|
71
|
+
const created = Array.isArray(result) ? result[0] : result;
|
|
72
|
+
if (created?.id) {
|
|
73
|
+
ConversationStore.setConversation({ ...created, messages: [] });
|
|
74
|
+
if (churchId)
|
|
75
|
+
await SubscriptionManager.joinRoom(created.id, churchId, personId);
|
|
76
|
+
setConversation({ ...created, messages: [] });
|
|
77
|
+
}
|
|
78
|
+
return created?.id;
|
|
79
|
+
};
|
|
80
|
+
if (!hydrated)
|
|
81
|
+
return _jsx(Loading, {});
|
|
82
|
+
const allMessages = conversation?.messages ?? [];
|
|
83
|
+
const messages = filterVisibleMessages(allMessages);
|
|
84
|
+
const getNotes = () => messages.map((m) => (_jsx(Note, { message: m, context: props.context, showEditNote: (id) => setEditMessageId(id) }, m.id)));
|
|
85
|
+
const result = (_jsxs(_Fragment, { children: [(props.showCommentCount || conversation?.id) && (_jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", minHeight: 32 }, children: [props.showCommentCount && conversation ? (_jsx("div", { className: "commentCount", children: _jsx("div", { children: messages.length === 1
|
|
86
|
+
? "1 " + Locale.label("notes.comment", "comment")
|
|
87
|
+
: messages.length + " " + Locale.label("notes.comments", "comments") }) })) : _jsx("span", {}), _jsx(SubscriptionToggle, { conversationId: conversation?.id, messages: allMessages, personId: personId })] })), _jsxs("div", { className: "messages", children: [canPost && (_jsx(AddNote, { context: props.context, conversationId: conversation?.id, createConversation: createConversation, onUpdate: () => setEditMessageId(null), onCancel: () => setEditMessageId(null), messageId: editMessageId ?? undefined })), _jsx("div", { className: "messages-wrapper", children: getNotes() })] })] }));
|
|
88
|
+
if (props.noWrapper)
|
|
89
|
+
return result;
|
|
90
|
+
return _jsx(Paper, { sx: { padding: 1, marginBottom: 2 }, children: result });
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=Conversations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Conversations.js","sourceRoot":"","sources":["../../../src/components/conversations/Conversations.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAaxF;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,MAAM,OAAO,GAAG,KA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@@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/conversations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -16,6 +16,7 @@ export { SupportModal } from "./SupportModal";
|
|
|
16
16
|
export { TabPanel } from "./TabPanel";
|
|
17
17
|
export * from "./wrapper";
|
|
18
18
|
export * from "./notes";
|
|
19
|
+
export * from "./conversations";
|
|
19
20
|
export * from "./header";
|
|
20
21
|
export * from "./gallery";
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { SupportModal } from "./SupportModal";
|
|
|
16
16
|
export { TabPanel } from "./TabPanel";
|
|
17
17
|
export * from "./wrapper";
|
|
18
18
|
export * from "./notes";
|
|
19
|
+
export * from "./conversations";
|
|
19
20
|
export * from "./header";
|
|
20
21
|
export * from "./gallery";
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNote.d.ts","sourceRoot":"","sources":["../../../src/components/notes/AddNote.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AddNote.d.ts","sourceRoot":"","sources":["../../../src/components/notes/AddNote.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAoB,oBAAoB,EAAc,MAAM,qBAAqB,CAAC;AAczF,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,kBAAkB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,2CA2L7D"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect } from "react";
|
|
4
4
|
import { ApiHelper, Locale, PersonHelper } from "../../helpers";
|
|
5
|
+
import { ConversationStore } from "../../helpers/ConversationStore";
|
|
6
|
+
import { SubscriptionManager } from "../../helpers/SubscriptionManager";
|
|
5
7
|
import { UserHelper } from "@churchapps/helpers";
|
|
6
8
|
import { Box, Stack, TextField, IconButton, Paper, CircularProgress, Avatar, Icon } from "@mui/material";
|
|
7
9
|
import { EmojiPicker } from "./EmojiPicker";
|
|
@@ -39,11 +41,27 @@ export function AddNote({ context, onCancel, ...props }) {
|
|
|
39
41
|
return;
|
|
40
42
|
setIsSubmitting(true);
|
|
41
43
|
let cId = props.conversationId;
|
|
44
|
+
const isNewConversation = !cId;
|
|
42
45
|
if (!cId)
|
|
43
46
|
cId = await props.createConversation();
|
|
47
|
+
// If this post is creating the conversation, eagerly join the room before sending
|
|
48
|
+
// the message so the server's broadcast lands on this tab. Without this, the broadcast
|
|
49
|
+
// queries the connections table at save time and finds nobody — the message is
|
|
50
|
+
// persisted but never echoed live to either the sender or any other open tab.
|
|
51
|
+
if (isNewConversation && churchId && cId) {
|
|
52
|
+
try {
|
|
53
|
+
await SubscriptionManager.joinRoom(cId, churchId, context?.person?.id);
|
|
54
|
+
}
|
|
55
|
+
catch { /* ignore */ }
|
|
56
|
+
}
|
|
44
57
|
const m = { ...message, conversationId: cId };
|
|
45
58
|
ApiHelper.post("/messages", [m], "MessagingApi")
|
|
46
|
-
.then(() => {
|
|
59
|
+
.then((saved) => {
|
|
60
|
+
// Belt-and-suspenders: directly apply the saved message to the local store so the
|
|
61
|
+
// sender sees it instantly even if the broadcast missed (e.g. join-room race).
|
|
62
|
+
const result = Array.isArray(saved) ? saved[0] : saved;
|
|
63
|
+
if (result?.conversationId)
|
|
64
|
+
ConversationStore.applyMessage(result);
|
|
47
65
|
props.onUpdate();
|
|
48
66
|
setMessage({ ...message, content: "" });
|
|
49
67
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNote.js","sourceRoot":"","sources":["../../../src/components/notes/AddNote.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAA0C,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EACL,GAAG,EACH,KAAK,EACL,SAAS,EACT,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,MAAM,EACN,IAAI,EACL,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAWjD,MAAM,UAAU,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAS;IAC5D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAoB,CAAC;IAC3D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IACnD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC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wDACF,OAAO,EAAE,cAAc;wDACvB,KAAK,EAAE,OAAO;wDACd,SAAS,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;wDACtC,YAAY,EAAE,EAAE,OAAO,EAAE,2BAA2B,EAAE,KAAK,EAAE,iBAAiB,EAAE;qDACjF,YAEA,YAAY,CAAC,CAAC,CAAC,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAC,SAAS,GAAG,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,QAAQ,EAAC,OAAO,qBAAY,GACxF,IACT,IACF,IACF,IACA,GACF,EACR,KAAC,WAAW,IACV,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAC1F,IACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notes.d.ts","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Notes.d.ts","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":"AAOA,OAAO,EAA2C,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGpG,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,2CA2NjC"}
|
|
@@ -3,86 +3,103 @@ import React from "react";
|
|
|
3
3
|
import { Note } from "./Note";
|
|
4
4
|
import { AddNote } from "./AddNote";
|
|
5
5
|
import { DisplayBox, Loading } from "../";
|
|
6
|
-
import {
|
|
6
|
+
import { Locale } from "../../helpers";
|
|
7
|
+
import { ConversationStore } from "../../helpers/ConversationStore";
|
|
8
|
+
import { SubscriptionManager } from "../../helpers/SubscriptionManager";
|
|
9
|
+
import { SubscriptionToggle, filterVisibleMessages } from "./SubscriptionToggle";
|
|
7
10
|
export function Notes(props) {
|
|
8
11
|
const [messages, setMessages] = React.useState(null);
|
|
9
12
|
const [editMessageId, setEditMessageId] = React.useState(null);
|
|
10
13
|
const [isInitialLoad, setIsInitialLoad] = React.useState(true);
|
|
11
14
|
const [previousMessageCount, setPreviousMessageCount] = React.useState(0);
|
|
15
|
+
const churchId = props.context?.userChurch?.church?.id;
|
|
16
|
+
const personId = props.context?.person?.id;
|
|
12
17
|
// Add CSS for custom scrollbar styling
|
|
13
18
|
React.useEffect(() => {
|
|
14
19
|
const styleId = "notes-scrollbar-styles";
|
|
15
20
|
if (!document.getElementById(styleId)) {
|
|
16
21
|
const style = document.createElement("style");
|
|
17
22
|
style.id = styleId;
|
|
18
|
-
style.textContent = `
|
|
19
|
-
.notes-scroll-container {
|
|
20
|
-
scrollbar-width: thin;
|
|
21
|
-
scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.1);
|
|
22
|
-
}
|
|
23
|
-
.notes-scroll-container::-webkit-scrollbar {
|
|
24
|
-
width: 12px;
|
|
25
|
-
background: transparent;
|
|
26
|
-
}
|
|
27
|
-
.notes-scroll-container::-webkit-scrollbar-track {
|
|
28
|
-
background: rgba(0, 0, 0, 0.1);
|
|
29
|
-
border-radius: 6px;
|
|
30
|
-
margin: 4px;
|
|
31
|
-
}
|
|
32
|
-
.notes-scroll-container::-webkit-scrollbar-thumb {
|
|
33
|
-
background: rgba(0, 0, 0, 0.3);
|
|
34
|
-
border-radius: 6px;
|
|
35
|
-
border: 2px solid transparent;
|
|
36
|
-
background-clip: content-box;
|
|
37
|
-
}
|
|
38
|
-
.notes-scroll-container::-webkit-scrollbar-thumb:hover {
|
|
39
|
-
background: rgba(0, 0, 0, 0.5);
|
|
40
|
-
background-clip: content-box;
|
|
41
|
-
}
|
|
42
|
-
.notes-scroll-container::-webkit-scrollbar-corner {
|
|
43
|
-
background: transparent;
|
|
44
|
-
}
|
|
23
|
+
style.textContent = `
|
|
24
|
+
.notes-scroll-container {
|
|
25
|
+
scrollbar-width: thin;
|
|
26
|
+
scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.1);
|
|
27
|
+
}
|
|
28
|
+
.notes-scroll-container::-webkit-scrollbar {
|
|
29
|
+
width: 12px;
|
|
30
|
+
background: transparent;
|
|
31
|
+
}
|
|
32
|
+
.notes-scroll-container::-webkit-scrollbar-track {
|
|
33
|
+
background: rgba(0, 0, 0, 0.1);
|
|
34
|
+
border-radius: 6px;
|
|
35
|
+
margin: 4px;
|
|
36
|
+
}
|
|
37
|
+
.notes-scroll-container::-webkit-scrollbar-thumb {
|
|
38
|
+
background: rgba(0, 0, 0, 0.3);
|
|
39
|
+
border-radius: 6px;
|
|
40
|
+
border: 2px solid transparent;
|
|
41
|
+
background-clip: content-box;
|
|
42
|
+
}
|
|
43
|
+
.notes-scroll-container::-webkit-scrollbar-thumb:hover {
|
|
44
|
+
background: rgba(0, 0, 0, 0.5);
|
|
45
|
+
background-clip: content-box;
|
|
46
|
+
}
|
|
47
|
+
.notes-scroll-container::-webkit-scrollbar-corner {
|
|
48
|
+
background: transparent;
|
|
49
|
+
}
|
|
45
50
|
`;
|
|
46
51
|
document.head.appendChild(style);
|
|
47
52
|
}
|
|
48
53
|
}, []);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
// Hydrate via ConversationStore + subscribe + join the realtime room.
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
let cancelled = false;
|
|
57
|
+
let unsubscribe = null;
|
|
58
|
+
let joined = false;
|
|
59
|
+
const conversationId = props.conversationId;
|
|
60
|
+
if (!conversationId) {
|
|
61
|
+
setMessages([]);
|
|
62
|
+
setIsInitialLoad(false);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
(async () => {
|
|
66
|
+
try {
|
|
67
|
+
await ConversationStore.loadByConversationId(conversationId);
|
|
58
68
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// Mark as no longer initial load after first load
|
|
62
|
-
if (isInitialLoad) {
|
|
63
|
-
setIsInitialLoad(false);
|
|
69
|
+
catch (err) {
|
|
70
|
+
console.error("Notes.loadByConversationId failed:", err);
|
|
64
71
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
if (cancelled)
|
|
73
|
+
return;
|
|
74
|
+
unsubscribe = ConversationStore.subscribe(conversationId, (conv) => {
|
|
75
|
+
if (cancelled)
|
|
76
|
+
return;
|
|
77
|
+
setMessages(conv?.messages ?? []);
|
|
78
|
+
setEditMessageId(null);
|
|
79
|
+
if (isInitialLoad)
|
|
80
|
+
setIsInitialLoad(false);
|
|
81
|
+
});
|
|
82
|
+
if (churchId) {
|
|
83
|
+
joined = true;
|
|
84
|
+
SubscriptionManager.joinRoom(conversationId, churchId, personId).catch(() => { });
|
|
72
85
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
86
|
+
})();
|
|
87
|
+
return () => {
|
|
88
|
+
cancelled = true;
|
|
89
|
+
if (unsubscribe)
|
|
90
|
+
unsubscribe();
|
|
91
|
+
if (joined && churchId)
|
|
92
|
+
SubscriptionManager.leaveRoom(conversationId, churchId).catch(() => { });
|
|
93
|
+
};
|
|
94
|
+
}, [props.conversationId, props.refreshKey, churchId, personId]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
95
|
+
const visibleMessages = React.useMemo(() => filterVisibleMessages(messages), [messages]);
|
|
96
|
+
const subscriptionToggle = (_jsx(SubscriptionToggle, { conversationId: props.conversationId, messages: messages, personId: personId }));
|
|
75
97
|
const getNotes = () => {
|
|
76
98
|
if (!messages)
|
|
77
99
|
return _jsx(Loading, {});
|
|
78
|
-
if (
|
|
100
|
+
if (visibleMessages.length === 0)
|
|
79
101
|
return _jsx(_Fragment, {});
|
|
80
|
-
|
|
81
|
-
const noteArray = [];
|
|
82
|
-
for (let i = 0; i < messages.length; i++)
|
|
83
|
-
noteArray.push(_jsx(Note, { message: messages[i], showEditNote: setEditMessageId, context: props.context }, messages[i].id));
|
|
84
|
-
return noteArray;
|
|
85
|
-
}
|
|
102
|
+
return visibleMessages.map(m => (_jsx(Note, { message: m, showEditNote: setEditMessageId, context: props.context }, m.id)));
|
|
86
103
|
};
|
|
87
104
|
const getNotesWrapper = () => {
|
|
88
105
|
const notes = getNotes();
|
|
@@ -105,30 +122,28 @@ export function Notes(props) {
|
|
|
105
122
|
else
|
|
106
123
|
return notes;
|
|
107
124
|
};
|
|
108
|
-
React.useEffect(() => { loadNotes(); }, [props.conversationId, props.refreshKey]); //eslint-disable-line
|
|
109
|
-
// Simply reload notes when refreshKey changes
|
|
110
|
-
// This is triggered by the parent component when WebSocket messages arrive
|
|
111
|
-
// Auto-scroll to bottom only when new messages are added (not on initial load)
|
|
112
125
|
React.useEffect(() => {
|
|
113
|
-
if (props.maxHeight &&
|
|
114
|
-
const currentMessageCount =
|
|
115
|
-
// Only auto-scroll if messages were added
|
|
126
|
+
if (props.maxHeight && visibleMessages.length > 0 && !isInitialLoad) {
|
|
127
|
+
const currentMessageCount = visibleMessages.length;
|
|
116
128
|
if (currentMessageCount > previousMessageCount) {
|
|
117
|
-
// Use requestAnimationFrame for smoother scrolling
|
|
118
129
|
requestAnimationFrame(() => {
|
|
119
130
|
const element = window?.document?.getElementById("notesScroll");
|
|
120
|
-
if (element)
|
|
131
|
+
if (element)
|
|
121
132
|
element.scrollTop = element.scrollHeight;
|
|
122
|
-
}
|
|
123
133
|
});
|
|
124
134
|
}
|
|
125
135
|
setPreviousMessageCount(currentMessageCount);
|
|
126
136
|
}
|
|
127
|
-
else if (
|
|
128
|
-
|
|
129
|
-
setPreviousMessageCount(messages.length);
|
|
137
|
+
else if (visibleMessages.length > 0 && isInitialLoad) {
|
|
138
|
+
setPreviousMessageCount(visibleMessages.length);
|
|
130
139
|
}
|
|
131
|
-
}, [
|
|
140
|
+
}, [visibleMessages, props.maxHeight, isInitialLoad, previousMessageCount]);
|
|
141
|
+
const onLocalUpdate = () => {
|
|
142
|
+
// Realtime path is authoritative; this fallback only fires when the socket isn't delivering
|
|
143
|
+
// (e.g. a self-post that the server still echoed back). The store applies the broadcast
|
|
144
|
+
// for us, so we just clear edit mode.
|
|
145
|
+
setEditMessageId(null);
|
|
146
|
+
};
|
|
132
147
|
const result = props.maxHeight ? (_jsxs("div", { style: {
|
|
133
148
|
height: "100%",
|
|
134
149
|
display: "flex",
|
|
@@ -148,11 +163,11 @@ export function Notes(props) {
|
|
|
148
163
|
padding: "12px",
|
|
149
164
|
minHeight: "auto",
|
|
150
165
|
maxHeight: "200px"
|
|
151
|
-
}, children: _jsx(AddNote, { context: props.context, conversationId: props.conversationId, onUpdate:
|
|
166
|
+
}, children: _jsx(AddNote, { context: props.context, conversationId: props.conversationId, onUpdate: onLocalUpdate, createConversation: props.createConversation, messageId: editMessageId, onCancel: () => setEditMessageId(null) }) }))] })) : (_jsxs(_Fragment, { children: [getNotesWrapper(), messages && (_jsx(AddNote, { context: props.context, conversationId: props.conversationId, onUpdate: onLocalUpdate, createConversation: props.createConversation, messageId: editMessageId, onCancel: () => setEditMessageId(null) }))] }));
|
|
152
167
|
if (props.noDisplayBox)
|
|
153
168
|
return result;
|
|
154
169
|
else
|
|
155
|
-
return (_jsx(DisplayBox, { id: "notesBox", "data-testid": "notes-box", headerIcon: "sticky_note_2", headerText: Locale.label("notes.notes", "Notes"), children: result }));
|
|
170
|
+
return (_jsx(DisplayBox, { id: "notesBox", "data-testid": "notes-box", headerIcon: "sticky_note_2", headerText: Locale.label("notes.notes", "Notes"), editContent: subscriptionToggle, children: result }));
|
|
156
171
|
}
|
|
157
172
|
;
|
|
158
173
|
//# sourceMappingURL=Notes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notes.js","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Notes.js","sourceRoot":"","sources":["../../../src/components/notes/Notes.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAWjF,MAAM,UAAU,KAAK,CAAC,KAAY;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,IAAI,CAAC,CAAC;IACzE,M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} from "@churchapps/helpers";
|
|
3
|
+
/**
|
|
4
|
+
* Subscription markers piggyback on the messages table — messageType="subscription"
|
|
5
|
+
* rows toggle whether the poster wants notifications for new content. They never
|
|
6
|
+
* render in the visible thread; the server reads them in NotificationHelper to
|
|
7
|
+
* decide who gets the bell / push.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SUBSCRIPTION_MESSAGE_TYPE = "subscription";
|
|
10
|
+
/** Strip subscription markers from a message list before display. */
|
|
11
|
+
export declare function filterVisibleMessages(messages: MessageInterface[] | null | undefined): MessageInterface[];
|
|
12
|
+
/**
|
|
13
|
+
* Walks all messages chronologically; the latest action by `personId` wins.
|
|
14
|
+
* - real comment → subscribed
|
|
15
|
+
* - "subscription" with content="off" → muted
|
|
16
|
+
* - "subscription" with content="on" (or any non-"off") → subscribed
|
|
17
|
+
*/
|
|
18
|
+
export declare function computeSubscriptionState(messages: MessageInterface[] | null | undefined, personId: string | undefined): boolean;
|
|
19
|
+
interface Props {
|
|
20
|
+
conversationId: string | undefined;
|
|
21
|
+
messages: MessageInterface[] | null | undefined;
|
|
22
|
+
personId: string | undefined;
|
|
23
|
+
size?: "small" | "medium";
|
|
24
|
+
/** Override the default color (e.g. for a dark dialog header). */
|
|
25
|
+
color?: string;
|
|
26
|
+
/** Override the muted color. */
|
|
27
|
+
mutedColor?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Bell icon that shows whether the current user is subscribed to notifications for
|
|
31
|
+
* this conversation. Clicking flips the state by posting a marker message.
|
|
32
|
+
*
|
|
33
|
+
* Renders nothing if conversationId or personId is missing — the toggle is only
|
|
34
|
+
* meaningful once both are known.
|
|
35
|
+
*/
|
|
36
|
+
export declare const SubscriptionToggle: React.FC<Props>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=SubscriptionToggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionToggle.d.ts","sourceRoot":"","sources":["../../../src/components/notes/SubscriptionToggle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAExD,qEAAqE;AACrE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,EAAE,CAGzG;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAc/H;AAED,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAChD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA6C9C,CAAC"}
|