@weavy/uikit-react 11.0.0 → 11.2.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/README.md +6 -5
- package/changelog.md +19 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/client/WeavyClient.d.ts +1 -1
- package/dist/cjs/types/contexts/MessengerContext.d.ts +1 -2
- package/dist/cjs/types/hooks/useUser.d.ts +2 -1
- package/dist/cjs/types/types/Messenger.d.ts +0 -1
- package/dist/cjs/types/types/types.d.ts +10 -6
- package/dist/cjs/types/utils/styles.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/client/WeavyClient.d.ts +1 -1
- package/dist/esm/types/contexts/MessengerContext.d.ts +1 -2
- package/dist/esm/types/hooks/useUser.d.ts +2 -1
- package/dist/esm/types/types/Messenger.d.ts +0 -1
- package/dist/esm/types/types/types.d.ts +10 -6
- package/dist/esm/types/utils/styles.d.ts +2 -2
- package/dist/index.d.ts +2 -3
- package/package.json +1 -1
- package/src/client/WeavyClient.ts +3 -3
- package/src/components/Chat.tsx +8 -11
- package/src/components/Conversation.tsx +2 -2
- package/src/components/ConversationListItem.tsx +2 -2
- package/src/components/FileBrowser.tsx +1 -1
- package/src/components/Messages.tsx +14 -13
- package/src/components/Messenger.tsx +4 -4
- package/src/components/Reactions.tsx +2 -1
- package/src/components/SearchUsers.tsx +2 -2
- package/src/components/Typing.tsx +4 -4
- package/src/contexts/MessengerContext.tsx +4 -12
- package/src/contexts/WeavyContext.tsx +8 -1
- package/src/hooks/useBadge.ts +1 -1
- package/src/hooks/useChat.ts +1 -1
- package/src/hooks/useConversation.ts +1 -1
- package/src/hooks/useConversations.ts +1 -1
- package/src/hooks/useFileUploader.ts +5 -1
- package/src/hooks/useMembers.ts +1 -1
- package/src/hooks/useMessages.ts +1 -1
- package/src/hooks/useMutateChat.ts +1 -1
- package/src/hooks/useMutateConversation.ts +1 -1
- package/src/hooks/useMutateConversationName.ts +1 -1
- package/src/hooks/useMutateDeleteReaction.ts +1 -1
- package/src/hooks/useMutateExternalBlobs.ts +1 -1
- package/src/hooks/useMutateMeeting.ts +1 -1
- package/src/hooks/useMutateMembers.ts +1 -1
- package/src/hooks/useMutateMessage.ts +2 -1
- package/src/hooks/useMutatePinned.ts +1 -1
- package/src/hooks/useMutateReaction.ts +1 -1
- package/src/hooks/useMutateRead.ts +1 -1
- package/src/hooks/useMutateRemoveMembers.ts +1 -1
- package/src/hooks/useMutateTyping.ts +1 -1
- package/src/hooks/usePresence.ts +4 -0
- package/src/hooks/useSearchUsers.ts +1 -1
- package/src/hooks/useUser.ts +4 -3
- package/src/index.ts +2 -2
- package/src/types/Messenger.ts +1 -1
- package/src/types/types.ts +12 -9
- package/src/utils/scrollbarDetection.js +50 -0
- package/src/utils/styles.ts +21 -6
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
export declare const MessengerContext: React.Context<MessengerContextProps>;
|
|
3
3
|
declare type Props = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
|
-
options?: MessengerContextOptions;
|
|
6
5
|
};
|
|
7
|
-
declare const MessengerProvider: ({ children
|
|
6
|
+
declare const MessengerProvider: ({ children }: Props) => JSX.Element;
|
|
8
7
|
export default MessengerProvider;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import WeavyClient from "../client/WeavyClient";
|
|
2
|
+
export default function useUser(client: WeavyClient): import("react-query").UseQueryResult<UserType, unknown>;
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
interface WeavyClient {
|
|
3
|
+
url: string;
|
|
4
|
+
tokenFactory: (() => string | Promise<string>);
|
|
5
|
+
subscribe: Function;
|
|
6
|
+
unsubscribe: Function;
|
|
7
|
+
}
|
|
2
8
|
declare type WeavyClientOptions = {
|
|
3
|
-
|
|
9
|
+
url: string;
|
|
4
10
|
tokenFactory: (() => string | Promise<string>);
|
|
5
11
|
};
|
|
6
12
|
declare type WeavyContextProps = {
|
|
7
|
-
client:
|
|
13
|
+
client: WeavyClient | null;
|
|
8
14
|
options?: WeavyContextOptions;
|
|
9
15
|
};
|
|
10
16
|
declare type WeavyContextOptions = {
|
|
11
17
|
zoomAuthenticationUrl?: string;
|
|
12
18
|
teamsAuthenticationUrl?: string;
|
|
13
19
|
enableCloudFiles?: boolean;
|
|
20
|
+
enableScrollbarDetection?: boolean;
|
|
14
21
|
filebrowserUrl?: string;
|
|
22
|
+
reactions?: string[];
|
|
15
23
|
};
|
|
16
24
|
declare type MessengerContextProps = {
|
|
17
|
-
options?: MessengerContextOptions;
|
|
18
25
|
selectedConversationId: null | number;
|
|
19
26
|
setSelectedConversationId: Function;
|
|
20
27
|
};
|
|
21
28
|
declare type UserContextProps = {
|
|
22
29
|
user: UserType;
|
|
23
30
|
};
|
|
24
|
-
declare type MessengerContextOptions = {
|
|
25
|
-
reactions?: string[];
|
|
26
|
-
};
|
|
27
31
|
declare type PreviewContextProps = {
|
|
28
32
|
openPreview: Function;
|
|
29
33
|
closePreview: Function;
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function setPrefix(prefix: string): void;
|
|
6
6
|
/**
|
|
7
|
-
* Prefixes one or more classnames (with or without dot) using the themePrefix
|
|
7
|
+
* Prefixes one or more classnames (with or without dot or double dash) using the themePrefix
|
|
8
8
|
* @param {...string} strs
|
|
9
9
|
* @returns string[]
|
|
10
10
|
*/
|
|
11
11
|
export declare function prefixes(...strs: string[]): string[];
|
|
12
12
|
/**
|
|
13
|
-
* Prefixes
|
|
13
|
+
* Prefixes a classname string (containing one or multiple space-separated classnames, with or without dot or double dash) using the themePrefix
|
|
14
14
|
* @param {string} str
|
|
15
15
|
* @returns string
|
|
16
16
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import React, { FC } from 'react';
|
|
|
4
4
|
import { Styles } from 'react-modal';
|
|
5
5
|
|
|
6
6
|
declare class WeavyClient {
|
|
7
|
-
|
|
7
|
+
url: string;
|
|
8
8
|
tokenFactory: () => string | Promise<string>;
|
|
9
9
|
connection: _microsoft_signalr.HubConnection;
|
|
10
10
|
groups: string[];
|
|
@@ -31,9 +31,8 @@ declare const WeavyProvider: ({ children, client, options }: Props$2) => JSX.Ele
|
|
|
31
31
|
declare const MessengerContext: React.Context<MessengerContextProps>;
|
|
32
32
|
declare type Props$1 = {
|
|
33
33
|
children: React.ReactNode;
|
|
34
|
-
options?: MessengerContextOptions;
|
|
35
34
|
};
|
|
36
|
-
declare const MessengerProvider: ({ children
|
|
35
|
+
declare const MessengerProvider: ({ children }: Props$1) => JSX.Element;
|
|
37
36
|
|
|
38
37
|
declare const Messenger: FC<Messenger>;
|
|
39
38
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
|
|
2
2
|
|
|
3
3
|
export default class WeavyClient {
|
|
4
|
-
|
|
4
|
+
url;
|
|
5
5
|
tokenFactory;
|
|
6
6
|
connection;
|
|
7
7
|
groups: string[];
|
|
@@ -14,14 +14,14 @@ export default class WeavyClient {
|
|
|
14
14
|
EVENT_RECONNECTED = "reconnected";
|
|
15
15
|
|
|
16
16
|
constructor(options: WeavyClientOptions) {
|
|
17
|
-
this.
|
|
17
|
+
this.url = options.url;
|
|
18
18
|
this.tokenFactory = options.tokenFactory
|
|
19
19
|
this.groups = [];
|
|
20
20
|
this.connectionEvents = [];
|
|
21
21
|
|
|
22
22
|
this.connection = new HubConnectionBuilder()
|
|
23
23
|
.configureLogging(LogLevel.None)
|
|
24
|
-
.withUrl(this.
|
|
24
|
+
.withUrl(this.url + "/hubs/rtm", {
|
|
25
25
|
accessTokenFactory: this.tokenFactory
|
|
26
26
|
})
|
|
27
27
|
.withAutomaticReconnect()
|
package/src/components/Chat.tsx
CHANGED
|
@@ -37,19 +37,16 @@ const Chat = ({ id }: ChatProps) => {
|
|
|
37
37
|
}, [dataChat]);
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
|
|
40
|
+
<div className={wy('messenger-conversation scroll-y')}>
|
|
41
41
|
<header className={wy('appbars')}>
|
|
42
42
|
<nav className={wy('appbar')}>
|
|
43
|
-
|
|
43
|
+
<div></div>
|
|
44
44
|
{selectedId && dataConversation &&
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</Typing>
|
|
51
|
-
</div>
|
|
52
|
-
</>
|
|
45
|
+
<div className="wy-appbar-text">
|
|
46
|
+
<Typing id={selectedId} context="conversation">
|
|
47
|
+
{dataConversation.display_name}
|
|
48
|
+
</Typing>
|
|
49
|
+
</div>
|
|
53
50
|
}
|
|
54
51
|
</nav>
|
|
55
52
|
</header>
|
|
@@ -61,7 +58,7 @@ const Chat = ({ id }: ChatProps) => {
|
|
|
61
58
|
{selectedId && dataMembers &&
|
|
62
59
|
<Messages id={selectedId} members={dataMembers} />
|
|
63
60
|
}
|
|
64
|
-
|
|
61
|
+
</div>
|
|
65
62
|
)
|
|
66
63
|
}
|
|
67
64
|
|
|
@@ -131,7 +131,7 @@ const Conversation = ({ id, showBackButton }: ConversationProps) => {
|
|
|
131
131
|
{selectedConversationId && dataConversation &&
|
|
132
132
|
|
|
133
133
|
<>
|
|
134
|
-
<div>
|
|
134
|
+
<div className='wy-appbar-text'>
|
|
135
135
|
<Typing id={selectedConversationId} context="conversation">
|
|
136
136
|
{dataConversation.display_name}
|
|
137
137
|
</Typing>
|
|
@@ -157,7 +157,7 @@ const Conversation = ({ id, showBackButton }: ConversationProps) => {
|
|
|
157
157
|
<div className={wy('avatar-header')}>
|
|
158
158
|
<Avatar src={user.avatar_url} name={user.title} presence={user.presence} id={user.id} size={256} />
|
|
159
159
|
<h2>Welcome {user.name}!</h2>
|
|
160
|
-
|
|
160
|
+
Create or select a conversation to get started
|
|
161
161
|
</div>
|
|
162
162
|
}
|
|
163
163
|
{selectedConversationId && dataMembers &&
|
|
@@ -40,10 +40,10 @@ const ConversationListItem = ({ item, refetchConversations }: ConversationListIt
|
|
|
40
40
|
}, [item.id])
|
|
41
41
|
|
|
42
42
|
useEffect(() => {
|
|
43
|
-
client
|
|
43
|
+
client?.subscribe(`a${item.id}`, "app-updated", handleAppUpdated);
|
|
44
44
|
|
|
45
45
|
return () => {
|
|
46
|
-
client
|
|
46
|
+
client?.unsubscribe(`a${item.id}`, "app-updated", handleAppUpdated);
|
|
47
47
|
}
|
|
48
48
|
}, [item.id])
|
|
49
49
|
|
|
@@ -61,7 +61,7 @@ const FileBrowser = ({ onFileAdded }: Props) => {
|
|
|
61
61
|
$filebrowserFrame.name = "weavy-filebrowser";
|
|
62
62
|
$filebrowserFrame.src = filebrowserSrc;
|
|
63
63
|
$filebrowserFrame.className = wy('filebrowser-frame');
|
|
64
|
-
$filebrowserFrame.style.cssText = "position:
|
|
64
|
+
$filebrowserFrame.style.cssText = "position: fixed; top: 0; left: 0; height: 100%; width: 100%; background: rgba(1,1,1,.4); z-index: 10000; display:none"
|
|
65
65
|
|
|
66
66
|
window.top?.document.body.appendChild($filebrowserFrame);
|
|
67
67
|
|
|
@@ -64,7 +64,7 @@ const Messages = ({ id, members, displayName, avatarUrl }: Props) => {
|
|
|
64
64
|
})
|
|
65
65
|
}
|
|
66
66
|
})
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
} else {
|
|
69
69
|
reverseScroller?.disconnect();
|
|
70
70
|
reverseScroller = null;
|
|
@@ -94,30 +94,31 @@ const Messages = ({ id, members, displayName, avatarUrl }: Props) => {
|
|
|
94
94
|
// mark conversation as read
|
|
95
95
|
readMessageMutation.mutate({ id: id, read: true })
|
|
96
96
|
|
|
97
|
-
client
|
|
98
|
-
client
|
|
99
|
-
client
|
|
100
|
-
client
|
|
97
|
+
client?.subscribe(`a${id}`, "message-inserted", handleRealtimeMessage);
|
|
98
|
+
client?.subscribe(`a${id}`, "conversation-read", handleRealtimeSeenBy);
|
|
99
|
+
client?.subscribe(`a${id}`, "reaction-inserted", handleRealtimeReactionInserted);
|
|
100
|
+
client?.subscribe(`a${id}`, "reaction-deleted", handleRealtimeReactionDeleted);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
return () => {
|
|
104
104
|
window.removeEventListener('focus', handleFocus, false)
|
|
105
105
|
|
|
106
106
|
if (id) {
|
|
107
|
-
|
|
108
107
|
// remove additional pages in cache. Only get first page
|
|
109
108
|
let qd = queryClient.getQueryData(["messages", id]);
|
|
109
|
+
|
|
110
110
|
if (qd) {
|
|
111
|
+
|
|
111
112
|
queryClient.setQueryData(["messages", id], (data: any) => ({
|
|
112
|
-
pages: data?.pages.
|
|
113
|
-
pageParams:
|
|
114
|
-
}));
|
|
113
|
+
pages: data?.pages.slice(0,1),
|
|
114
|
+
pageParams: [undefined]
|
|
115
|
+
}));
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
client
|
|
118
|
-
client
|
|
119
|
-
client
|
|
120
|
-
client
|
|
118
|
+
client?.unsubscribe(`a${id}`, "message-inserted", handleRealtimeMessage);
|
|
119
|
+
client?.unsubscribe(`a${id}`, "conversation-read", handleRealtimeSeenBy);
|
|
120
|
+
client?.unsubscribe(`a${id}`, "reaction-inserted", handleRealtimeReactionInserted);
|
|
121
|
+
client?.unsubscribe(`a${id}`, "reaction-deleted", handleRealtimeReactionDeleted);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
}, [id]);
|
|
@@ -6,7 +6,7 @@ import { Messenger } from '../types/Messenger';
|
|
|
6
6
|
import { WeavyContext } from '../contexts/WeavyContext';
|
|
7
7
|
import { prefix as wy } from "../utils/styles";
|
|
8
8
|
|
|
9
|
-
const Messenger: FC<Messenger> = (
|
|
9
|
+
const Messenger: FC<Messenger> = () => {
|
|
10
10
|
|
|
11
11
|
const { client } = useContext(WeavyContext);
|
|
12
12
|
|
|
@@ -15,14 +15,14 @@ const Messenger: FC<Messenger> = ({ options }) => {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
<MessengerProvider
|
|
18
|
+
<MessengerProvider>
|
|
19
19
|
<div className={wy('messenger-provider')}>
|
|
20
20
|
|
|
21
|
-
<div className={wy('messenger-sidebar')}>
|
|
21
|
+
<div className={wy('messenger-sidebar scroll-y')}>
|
|
22
22
|
<ConversationList />
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
-
<div
|
|
25
|
+
<div className={wy('messenger-conversation scroll-y')}>
|
|
26
26
|
<Conversation id={null} />
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
@@ -8,6 +8,7 @@ import classNames from "classnames";
|
|
|
8
8
|
import { prefix as wy } from "../utils/styles";
|
|
9
9
|
import useReactions from "../hooks/useReactions";
|
|
10
10
|
import useMutateDeleteReaction from "../hooks/useMutateDeleteReaction";
|
|
11
|
+
import { WeavyContext } from "../contexts/WeavyContext";
|
|
11
12
|
|
|
12
13
|
type ReactionMenuProps = {
|
|
13
14
|
id: number,
|
|
@@ -25,7 +26,7 @@ export const ReactionsMenu = ({ id, reactions }: ReactionMenuProps) => {
|
|
|
25
26
|
const reactionMutation = useMutateReaction();
|
|
26
27
|
const reactionDeleteMutation = useMutateDeleteReaction();
|
|
27
28
|
const [visible, setVisible] = useState<boolean>(false);
|
|
28
|
-
const { options } = useContext(
|
|
29
|
+
const { options } = useContext(WeavyContext);
|
|
29
30
|
const [reactedEmoji, setReactedEmoji] = useState<string>('');
|
|
30
31
|
|
|
31
32
|
const emojis = options?.reactions;
|
|
@@ -60,8 +60,8 @@ const SearchUsers = ({handleSubmit, buttonTitle}: SearchUsersProps) => {
|
|
|
60
60
|
<td className={wy('search-result-table-icon')}>
|
|
61
61
|
<Avatar src={user.avatar_url} size={24} id={user.id} presence={user.presence} name={user.display_name} />
|
|
62
62
|
</td>
|
|
63
|
-
<td>{user.display_name}</td>
|
|
64
|
-
<td className={wy('search-result-table-icon')}><input type="checkbox" checked={isChecked(user.id)} onChange={(e) => handleSelected(e, user)} /></td>
|
|
63
|
+
<td><label htmlFor={'chk' + user.id}>{user.display_name}</label></td>
|
|
64
|
+
<td className={wy('search-result-table-icon')}><input type="checkbox" id={'chk' + user.id} checked={isChecked(user.id)} onChange={(e) => handleSelected(e, user)} /></td>
|
|
65
65
|
</tr>
|
|
66
66
|
)
|
|
67
67
|
})}
|
|
@@ -26,12 +26,12 @@ const Typing = ({ children, id, context }: Props) => {
|
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
setActiveTypers([]);
|
|
28
28
|
|
|
29
|
-
client
|
|
30
|
-
client
|
|
29
|
+
client?.subscribe(`a${id}`, "typing", handleTyping);
|
|
30
|
+
client?.subscribe(`a${id}`, "message-inserted", handleStopTyping);
|
|
31
31
|
|
|
32
32
|
return () => {
|
|
33
|
-
client
|
|
34
|
-
client
|
|
33
|
+
client?.unsubscribe(`a${id}`, "typing", handleTyping);
|
|
34
|
+
client?.unsubscribe(`a${id}`, "message-inserted", handleStopTyping);
|
|
35
35
|
}
|
|
36
36
|
}, [id])
|
|
37
37
|
|
|
@@ -3,22 +3,14 @@ import usePresence from "../hooks/usePresence";
|
|
|
3
3
|
|
|
4
4
|
export const MessengerContext = createContext<MessengerContextProps>({
|
|
5
5
|
selectedConversationId: null,
|
|
6
|
-
setSelectedConversationId: (id: any) => { }
|
|
7
|
-
options: {}
|
|
6
|
+
setSelectedConversationId: (id: any) => { }
|
|
8
7
|
});
|
|
9
8
|
|
|
10
9
|
type Props = {
|
|
11
|
-
children: React.ReactNode
|
|
12
|
-
options?: MessengerContextOptions
|
|
10
|
+
children: React.ReactNode
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
const MessengerProvider = ({ children
|
|
16
|
-
|
|
17
|
-
let defaultOptions: MessengerContextOptions = {
|
|
18
|
-
reactions: ['😍', '😎', '😉', '😜', '👍']
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
let opts = { ...defaultOptions, ...options };
|
|
13
|
+
const MessengerProvider = ({ children }: Props) => {
|
|
22
14
|
|
|
23
15
|
const [selectedConversationId, setSelectedConversation] = useState(null);
|
|
24
16
|
|
|
@@ -31,7 +23,7 @@ const MessengerProvider = ({ children, options }: Props) => {
|
|
|
31
23
|
|
|
32
24
|
return (
|
|
33
25
|
<>
|
|
34
|
-
<MessengerContext.Provider value={{
|
|
26
|
+
<MessengerContext.Provider value={{ selectedConversationId, setSelectedConversationId }}>
|
|
35
27
|
{children}
|
|
36
28
|
</MessengerContext.Provider>
|
|
37
29
|
</>
|
|
@@ -8,6 +8,7 @@ import timezone from 'dayjs/plugin/timezone';
|
|
|
8
8
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
9
9
|
import PreviewProvider from "./PreviewContext";
|
|
10
10
|
import WeavyClient from "../client/WeavyClient";
|
|
11
|
+
import detectScrollbars from '../utils/scrollbarDetection';
|
|
11
12
|
|
|
12
13
|
dayjs.extend(relativeTime);
|
|
13
14
|
dayjs.extend(utc);
|
|
@@ -40,11 +41,17 @@ const WeavyProvider = ({ children, client, options }: Props) => {
|
|
|
40
41
|
zoomAuthenticationUrl: undefined,
|
|
41
42
|
teamsAuthenticationUrl: undefined,
|
|
42
43
|
enableCloudFiles: true,
|
|
43
|
-
|
|
44
|
+
enableScrollbarDetection: true,
|
|
45
|
+
filebrowserUrl: "https://filebrowser.weavycloud.com/index10.html",
|
|
46
|
+
reactions: ['😍', '😎', '😉', '😜', '👍']
|
|
44
47
|
};
|
|
45
48
|
|
|
46
49
|
let opts = { ...defaultOptions, ...options }
|
|
47
50
|
|
|
51
|
+
if (opts.enableScrollbarDetection) {
|
|
52
|
+
detectScrollbars();
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
return (
|
|
49
56
|
<>
|
|
50
57
|
{client &&
|
package/src/hooks/useBadge.ts
CHANGED
|
@@ -12,7 +12,7 @@ export default function useBadge() {
|
|
|
12
12
|
|
|
13
13
|
const getBadge = async () => {
|
|
14
14
|
|
|
15
|
-
const response = await fetch(client.
|
|
15
|
+
const response = await fetch(client.url + "/api/conversations/badge", {
|
|
16
16
|
headers: {
|
|
17
17
|
"content-type": "application/json",
|
|
18
18
|
"Authorization": "Bearer " + await client.tokenFactory()
|
package/src/hooks/useChat.ts
CHANGED
|
@@ -12,7 +12,7 @@ export default function useChat(id: string, options: any) {
|
|
|
12
12
|
|
|
13
13
|
const getConversation = async () => {
|
|
14
14
|
|
|
15
|
-
const response = await fetch(client.
|
|
15
|
+
const response = await fetch(client.url + "/api/apps/idf/" + id, {
|
|
16
16
|
headers: {
|
|
17
17
|
"content-type": "application/json",
|
|
18
18
|
"Authorization": "Bearer " + await client.tokenFactory()
|
|
@@ -13,7 +13,7 @@ export default function useConversation(id: number | null, options: any) {
|
|
|
13
13
|
|
|
14
14
|
const getConversation = async () => {
|
|
15
15
|
|
|
16
|
-
const response = await fetch(client.
|
|
16
|
+
const response = await fetch(client.url + "/api/conversations/" + id, {
|
|
17
17
|
headers: {
|
|
18
18
|
"content-type": "application/json",
|
|
19
19
|
"Authorization": "Bearer " + await client.tokenFactory()
|
|
@@ -12,7 +12,7 @@ export default function useConversations() {
|
|
|
12
12
|
|
|
13
13
|
const getConversations = async () => {
|
|
14
14
|
|
|
15
|
-
const response = await fetch(client.
|
|
15
|
+
const response = await fetch(client.url + "/api/conversations?contextual=false", {
|
|
16
16
|
headers: {
|
|
17
17
|
"content-type": "application/json",
|
|
18
18
|
"Authorization": "Bearer " + await client.tokenFactory()
|
|
@@ -7,13 +7,17 @@ export default function useFileUploader(callback: Function) {
|
|
|
7
7
|
|
|
8
8
|
const { client } = useContext(WeavyContext);
|
|
9
9
|
|
|
10
|
+
if (!client) {
|
|
11
|
+
throw new Error('useFileUploader must be used within an WeavyProvider');
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
return useMutation(
|
|
11
15
|
async ({ request }: any) => {
|
|
12
16
|
|
|
13
17
|
const formData = new FormData();
|
|
14
18
|
formData.append('blob', request.file);
|
|
15
19
|
|
|
16
|
-
var response = await fetch(client.
|
|
20
|
+
var response = await fetch(client.url + "/api/blobs", {
|
|
17
21
|
method: 'POST',
|
|
18
22
|
body: formData,
|
|
19
23
|
headers: {
|
package/src/hooks/useMembers.ts
CHANGED
|
@@ -12,7 +12,7 @@ export default function useMembers(id: number | null, options: any) {
|
|
|
12
12
|
|
|
13
13
|
const getConversationMembers = async () => {
|
|
14
14
|
|
|
15
|
-
const response = await fetch(client.
|
|
15
|
+
const response = await fetch(client.url + "/api/apps/" + id + "/members", {
|
|
16
16
|
headers: {
|
|
17
17
|
"content-type": "application/json",
|
|
18
18
|
"Authorization": "Bearer " + await client.tokenFactory()
|
package/src/hooks/useMessages.ts
CHANGED
|
@@ -14,7 +14,7 @@ export default function useMessages(id: number | null, options: any) {
|
|
|
14
14
|
const getMessages = async (opt: any) => {
|
|
15
15
|
let skip = opt.pageParam || 0;
|
|
16
16
|
|
|
17
|
-
const response = await fetch(client.
|
|
17
|
+
const response = await fetch(client.url + "/api/apps/" + id + "/messages?orderby=createdat+desc&skip=" + skip + "&top=" + PAGE_SIZE, {
|
|
18
18
|
headers: {
|
|
19
19
|
"content-type": "application/json",
|
|
20
20
|
"Authorization": "Bearer " + await client.tokenFactory()
|
|
@@ -21,7 +21,7 @@ export default function useMutateChat() {
|
|
|
21
21
|
// create new conversation
|
|
22
22
|
const mutateChat = async ({ identifier, members }: MutateProps) => {
|
|
23
23
|
|
|
24
|
-
const response = await fetch(client.
|
|
24
|
+
const response = await fetch(client.url + "/api/apps/", {
|
|
25
25
|
method: "POST",
|
|
26
26
|
body: JSON.stringify({
|
|
27
27
|
identifier: identifier,
|
|
@@ -20,7 +20,7 @@ export default function useMutateConversation() {
|
|
|
20
20
|
// create new conversation
|
|
21
21
|
const mutateConversation = async ({ members }: MutateProps) => {
|
|
22
22
|
|
|
23
|
-
const response = await fetch(client.
|
|
23
|
+
const response = await fetch(client.url + "/api/conversations/", {
|
|
24
24
|
method: "POST",
|
|
25
25
|
body: JSON.stringify({ members: members }),
|
|
26
26
|
headers: {
|
|
@@ -20,7 +20,7 @@ export default function useMutateConversationName() {
|
|
|
20
20
|
|
|
21
21
|
const mutateConversationName = async ({ id, name }: MutateProps) => {
|
|
22
22
|
|
|
23
|
-
const response = await fetch(client.
|
|
23
|
+
const response = await fetch(client.url + "/api/apps/" + id, {
|
|
24
24
|
method: "PATCH",
|
|
25
25
|
body: JSON.stringify({ name: name }),
|
|
26
26
|
headers: {
|
|
@@ -22,7 +22,7 @@ export default function useMutateDeleteReaction() {
|
|
|
22
22
|
const mutateDeleteReaction = async ({ id, reaction }: MutateProps) => {
|
|
23
23
|
|
|
24
24
|
// remove the existing reaction
|
|
25
|
-
const response = await fetch(client.
|
|
25
|
+
const response = await fetch(client.url + "/api/messages/" + id + "/reactions/", {
|
|
26
26
|
method: "DELETE",
|
|
27
27
|
headers: {
|
|
28
28
|
"content-type": "application/json",
|
|
@@ -19,7 +19,7 @@ export default function useMutateExternalBlobs() {
|
|
|
19
19
|
|
|
20
20
|
const mutateExternalBlobs = async ({ blobs }: MutateProps) => {
|
|
21
21
|
|
|
22
|
-
const response = await fetch(client.
|
|
22
|
+
const response = await fetch(client.url + "/api/blobs/external", {
|
|
23
23
|
method: "POST",
|
|
24
24
|
body: JSON.stringify(blobs),
|
|
25
25
|
headers: {
|
|
@@ -19,7 +19,7 @@ export default function useMutateMeeting() {
|
|
|
19
19
|
|
|
20
20
|
const mutateMeeting = async ({ provider }: MutateProps) => {
|
|
21
21
|
|
|
22
|
-
const response = await fetch(client.
|
|
22
|
+
const response = await fetch(client.url + "/api/meetings", {
|
|
23
23
|
method: "POST",
|
|
24
24
|
body: JSON.stringify({provider: provider}),
|
|
25
25
|
headers: {
|
|
@@ -21,7 +21,7 @@ export default function useMutateMembers() {
|
|
|
21
21
|
// add members to conversation
|
|
22
22
|
const mutateMembers = async ({ id, members }: MutateProps) => {
|
|
23
23
|
|
|
24
|
-
const response = await fetch(client.
|
|
24
|
+
const response = await fetch(client.url + "/api/apps/" + id + "/members/", {
|
|
25
25
|
method: "POST",
|
|
26
26
|
body: JSON.stringify(members),
|
|
27
27
|
headers: {
|
|
@@ -22,7 +22,7 @@ export default function useMutateMessage() {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const mutateMessage = async ({ id, text, userId, attachments, meetings }: MutateProps) => {
|
|
25
|
-
const response = await fetch(client.
|
|
25
|
+
const response = await fetch(client.url + "/api/apps/" + id + "/messages", {
|
|
26
26
|
method: "POST",
|
|
27
27
|
body: JSON.stringify({
|
|
28
28
|
text: text,
|
|
@@ -86,6 +86,7 @@ export default function useMutateMessage() {
|
|
|
86
86
|
let pageMessages = [...data, {
|
|
87
87
|
id: tempId,
|
|
88
88
|
text: variables.text,
|
|
89
|
+
html: variables.text,
|
|
89
90
|
display_name: "",
|
|
90
91
|
temp: true,
|
|
91
92
|
parent_id: null,
|
|
@@ -20,7 +20,7 @@ export default function useMutatePinned() {
|
|
|
20
20
|
|
|
21
21
|
const mutatePinned = async ({ id, pin }: MutateProps) => {
|
|
22
22
|
|
|
23
|
-
const response = await fetch(client.
|
|
23
|
+
const response = await fetch(client.url + "/api/conversations/" + id + "/pin", {
|
|
24
24
|
method: + !pin ? "DELETE": "PUT",
|
|
25
25
|
body: "",
|
|
26
26
|
headers: {
|
|
@@ -22,7 +22,7 @@ export default function useMutateReaction() {
|
|
|
22
22
|
const mutateReaction = async ({id, reaction }: MutateProps) => {
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
const response = await fetch(client.
|
|
25
|
+
const response = await fetch(client.url + "/api/messages/" + id + "/reactions/", {
|
|
26
26
|
method: "POST",
|
|
27
27
|
body: JSON.stringify({ content: reaction}),
|
|
28
28
|
headers: {
|
|
@@ -20,7 +20,7 @@ export default function useMutateRead() {
|
|
|
20
20
|
|
|
21
21
|
const mutateRead = async ({ id, read }: MutateProps) => {
|
|
22
22
|
|
|
23
|
-
const response = await fetch(client.
|
|
23
|
+
const response = await fetch(client.url + "/api/conversations/" + id + "/read", {
|
|
24
24
|
method: !read ? "DELETE": "PUT",
|
|
25
25
|
body: "",
|
|
26
26
|
headers: {
|
|
@@ -22,7 +22,7 @@ export default function useMutateRemoveMembers() {
|
|
|
22
22
|
|
|
23
23
|
const mutateRemove = async ({ id, members }: MutateProps) => {
|
|
24
24
|
|
|
25
|
-
const response = await fetch(client.
|
|
25
|
+
const response = await fetch(client.url + "/api/apps/" + id + "/members/" + members.join(","), {
|
|
26
26
|
method: "DELETE",
|
|
27
27
|
body: JSON.stringify(members),
|
|
28
28
|
headers: {
|