@stream-io/feeds-client 0.2.21 → 0.3.1
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/CHANGELOG.md +50 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +1 -57
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/react-bindings.mjs +1 -57
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/{feeds-client--EbdwYrY.js → feeds-client-CttWroOS.js} +89 -8
- package/dist/feeds-client-CttWroOS.js.map +1 -0
- package/dist/{feeds-client-5nGcdeuG.mjs → feeds-client-DJG_rRVO.mjs} +89 -8
- package/dist/feeds-client-DJG_rRVO.mjs.map +1 -0
- package/dist/types/bindings/react/index.d.ts +0 -1
- package/dist/types/bindings/react/index.d.ts.map +1 -1
- package/dist/types/common/real-time/StableWSConnection.d.ts +3 -3
- package/dist/types/common/real-time/StableWSConnection.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity/handle-activity-feedback.d.ts +4 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-feedback.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/activity-updater.d.ts +2 -1
- package/dist/types/feed/event-handlers/activity-updater.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/is-activity-pin.d.ts +3 -0
- package/dist/types/feed/event-handlers/is-activity-pin.d.ts.map +1 -0
- package/dist/types/feed/feed.d.ts +2 -2
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts +2 -2
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -1
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +53 -5
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bindings/react/index.ts +0 -1
- package/src/feed/event-handlers/activity/handle-activity-feedback.ts +78 -0
- package/src/feed/event-handlers/is-activity-pin.ts +7 -0
- package/src/feed/feed.ts +6 -1
- package/src/feeds-client/feeds-client.ts +7 -0
- package/src/gen/feeds/FeedsApi.ts +0 -3
- package/src/gen/model-decoders/decoders.ts +27 -1
- package/src/gen/model-decoders/event-decoder-mapping.ts +3 -0
- package/src/gen/models/index.ts +92 -8
- package/dist/feeds-client--EbdwYrY.js.map +0 -1
- package/dist/feeds-client-5nGcdeuG.mjs.map +0 -1
- package/dist/types/bindings/react/hooks/util/index.d.ts +0 -3
- package/dist/types/bindings/react/hooks/util/index.d.ts.map +0 -1
- package/dist/types/bindings/react/hooks/util/useBookmarkActions.d.ts +0 -14
- package/dist/types/bindings/react/hooks/util/useBookmarkActions.d.ts.map +0 -1
- package/dist/types/bindings/react/hooks/util/useReactionActions.d.ts +0 -18
- package/dist/types/bindings/react/hooks/util/useReactionActions.d.ts.map +0 -1
- package/src/bindings/react/hooks/util/index.ts +0 -2
- package/src/bindings/react/hooks/util/useBookmarkActions.ts +0 -40
- package/src/bindings/react/hooks/util/useReactionActions.ts +0 -57
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/bindings/react/hooks/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ActivityResponse } from '../../../..';
|
|
2
|
-
/**
|
|
3
|
-
* A utility hook that takes in an entity and creates bookmark actions
|
|
4
|
-
* that can then be used on the UI. The entity is expected to be an ActivityResponse.
|
|
5
|
-
* @param entity - The entity to which we want to apply reaction actions, expects an ActivityResponse.
|
|
6
|
-
*/
|
|
7
|
-
export declare const useBookmarkActions: ({ entity, }: {
|
|
8
|
-
entity: ActivityResponse;
|
|
9
|
-
}) => {
|
|
10
|
-
addBookmark: import('../internal').StableCallback<[], Promise<void>>;
|
|
11
|
-
removeBookmark: import('../internal').StableCallback<[], Promise<void>>;
|
|
12
|
-
toggleBookmark: import('../internal').StableCallback<[], Promise<void>>;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=useBookmarkActions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBookmarkActions.d.ts","sourceRoot":"","sources":["../../../../../../src/bindings/react/hooks/util/useBookmarkActions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAI9C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,aAEhC;IACD,MAAM,EAAE,gBAAgB,CAAC;CAC1B;;;;CAyBA,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CommentParent } from '../../../..';
|
|
2
|
-
/**
|
|
3
|
-
* A utility hook that takes in an entity and a reaction type, and creates reaction actions
|
|
4
|
-
* that can then be used on the UI. The entity can be either an ActivityResponse or a CommentResponse
|
|
5
|
-
* as the hook determines internally which APIs it is supposed to use, while taking the
|
|
6
|
-
* correct ownCapabilities into account.
|
|
7
|
-
* @param entity - The entity to which we want to apply reaction actions, can be either ActivityResponse or CommentResponse.
|
|
8
|
-
* @param type - The type of reaction we want to add or remove.
|
|
9
|
-
*/
|
|
10
|
-
export declare const useReactionActions: ({ entity, type, }: {
|
|
11
|
-
entity: CommentParent;
|
|
12
|
-
type: string;
|
|
13
|
-
}) => {
|
|
14
|
-
addReaction: import('../internal').StableCallback<[], Promise<void>>;
|
|
15
|
-
removeReaction: import('../internal').StableCallback<[], Promise<void>>;
|
|
16
|
-
toggleReaction: import('../internal').StableCallback<[], Promise<void>>;
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=useReactionActions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useReactionActions.d.ts","sourceRoot":"","sources":["../../../../../../src/bindings/react/hooks/util/useReactionActions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAK3C;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,mBAGhC;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;;;;CAoCA,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import type { ActivityResponse } from '@self';
|
|
3
|
-
import { useFeedsClient } from '../../contexts/StreamFeedsContext';
|
|
4
|
-
import { useStableCallback } from '../internal';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A utility hook that takes in an entity and creates bookmark actions
|
|
8
|
-
* that can then be used on the UI. The entity is expected to be an ActivityResponse.
|
|
9
|
-
* @param entity - The entity to which we want to apply reaction actions, expects an ActivityResponse.
|
|
10
|
-
*/
|
|
11
|
-
export const useBookmarkActions = ({
|
|
12
|
-
entity,
|
|
13
|
-
}: {
|
|
14
|
-
entity: ActivityResponse;
|
|
15
|
-
}) => {
|
|
16
|
-
const client = useFeedsClient();
|
|
17
|
-
|
|
18
|
-
const hasOwnBookmark = entity.own_bookmarks?.length > 0;
|
|
19
|
-
|
|
20
|
-
const addBookmark = useStableCallback(async () => {
|
|
21
|
-
await client?.addBookmark({ activity_id: entity.id });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const removeBookmark = useStableCallback(async () => {
|
|
25
|
-
await client?.deleteBookmark({ activity_id: entity.id });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const toggleBookmark = useStableCallback(async () => {
|
|
29
|
-
if (hasOwnBookmark) {
|
|
30
|
-
await removeBookmark();
|
|
31
|
-
} else {
|
|
32
|
-
await addBookmark();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return useMemo(
|
|
37
|
-
() => ({ addBookmark, removeBookmark, toggleBookmark }),
|
|
38
|
-
[addBookmark, removeBookmark, toggleBookmark],
|
|
39
|
-
);
|
|
40
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import type { CommentParent } from '@self';
|
|
3
|
-
import { isCommentResponse } from '@self';
|
|
4
|
-
import { useStableCallback } from '../internal';
|
|
5
|
-
import { useFeedsClient } from '../../contexts/StreamFeedsContext';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A utility hook that takes in an entity and a reaction type, and creates reaction actions
|
|
9
|
-
* that can then be used on the UI. The entity can be either an ActivityResponse or a CommentResponse
|
|
10
|
-
* as the hook determines internally which APIs it is supposed to use, while taking the
|
|
11
|
-
* correct ownCapabilities into account.
|
|
12
|
-
* @param entity - The entity to which we want to apply reaction actions, can be either ActivityResponse or CommentResponse.
|
|
13
|
-
* @param type - The type of reaction we want to add or remove.
|
|
14
|
-
*/
|
|
15
|
-
export const useReactionActions = ({
|
|
16
|
-
entity,
|
|
17
|
-
type,
|
|
18
|
-
}: {
|
|
19
|
-
entity: CommentParent;
|
|
20
|
-
type: string;
|
|
21
|
-
}) => {
|
|
22
|
-
const client = useFeedsClient();
|
|
23
|
-
|
|
24
|
-
const isComment = isCommentResponse(entity);
|
|
25
|
-
const hasOwnReaction = useMemo(
|
|
26
|
-
() => !!entity.own_reactions?.find((r) => r.type === type),
|
|
27
|
-
[entity.own_reactions, type],
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const addReaction = useStableCallback(async () => {
|
|
31
|
-
await (isComment
|
|
32
|
-
? client?.addCommentReaction({ id: entity.id, type })
|
|
33
|
-
: client?.addActivityReaction({ activity_id: entity.id, type }));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const removeReaction = useStableCallback(async () => {
|
|
37
|
-
await (isComment
|
|
38
|
-
? client?.deleteCommentReaction({ id: entity.id, type })
|
|
39
|
-
: client?.deleteActivityReaction({
|
|
40
|
-
activity_id: entity.id,
|
|
41
|
-
type,
|
|
42
|
-
}));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const toggleReaction = useStableCallback(async () => {
|
|
46
|
-
if (hasOwnReaction) {
|
|
47
|
-
await removeReaction();
|
|
48
|
-
} else {
|
|
49
|
-
await addReaction();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return useMemo(
|
|
54
|
-
() => ({ addReaction, removeReaction, toggleReaction }),
|
|
55
|
-
[addReaction, removeReaction, toggleReaction],
|
|
56
|
-
);
|
|
57
|
-
};
|