@stream-io/feeds-client 0.1.11 → 0.2.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 +25 -0
- package/dist/index-react-bindings.browser.cjs +537 -331
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +537 -331
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +537 -331
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +537 -331
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +536 -329
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +536 -330
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.node.cjs +536 -329
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +536 -330
- package/dist/index.node.js.map +1 -1
- package/dist/src/feed/event-handlers/activity/handle-activity-deleted.d.ts +12 -3
- package/dist/src/feed/event-handlers/activity/handle-activity-pinned.d.ts +3 -0
- package/dist/src/feed/event-handlers/activity/handle-activity-reaction-added.d.ts +10 -6
- package/dist/src/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts +10 -6
- package/dist/src/feed/event-handlers/activity/handle-activity-unpinned.d.ts +3 -0
- package/dist/src/feed/event-handlers/activity/handle-activity-updated.d.ts +7 -3
- package/dist/src/feed/event-handlers/bookmark/handle-bookmark-added.d.ts +10 -6
- package/dist/src/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts +10 -6
- package/dist/src/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts +10 -6
- package/dist/src/feed/event-handlers/index.d.ts +1 -0
- package/dist/src/feed/event-handlers/watch/handle-watch-started.d.ts +2 -0
- package/dist/src/feed/event-handlers/watch/handle-watch-stopped.d.ts +2 -0
- package/dist/src/feed/event-handlers/watch/index.d.ts +2 -0
- package/dist/src/feed/feed.d.ts +4 -12
- package/dist/src/feeds-client/event-handlers/index.d.ts +1 -0
- package/dist/src/feeds-client/event-handlers/user/handle-user-updated.d.ts +3 -0
- package/dist/src/{feeds-client.d.ts → feeds-client/feeds-client.d.ts} +16 -16
- package/dist/src/feeds-client/index.d.ts +2 -0
- package/dist/src/gen/feeds/FeedsApi.d.ts +27 -23
- package/dist/src/gen/models/index.d.ts +198 -23
- package/dist/src/test-utils/response-generators.d.ts +46 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/update-entity-in-array.d.ts +27 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -1
- package/package.json +2 -2
- package/src/feed/event-handlers/activity/activity-reaction-utils.test.ts +108 -96
- package/src/feed/event-handlers/activity/activity-utils.test.ts +84 -122
- package/src/feed/event-handlers/activity/handle-activity-deleted.ts +43 -10
- package/src/feed/event-handlers/activity/handle-activity-pinned.test.ts +60 -0
- package/src/feed/event-handlers/activity/handle-activity-pinned.ts +30 -0
- package/src/feed/event-handlers/activity/handle-activity-reaction-added.test.ts +157 -0
- package/src/feed/event-handlers/activity/handle-activity-reaction-added.ts +82 -40
- package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.test.ts +200 -0
- package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.ts +89 -51
- package/src/feed/event-handlers/activity/handle-activity-unpinned.test.ts +94 -0
- package/src/feed/event-handlers/activity/handle-activity-unpinned.ts +30 -0
- package/src/feed/event-handlers/activity/handle-activity-updated.test.ts +115 -0
- package/src/feed/event-handlers/activity/handle-activity-updated.ts +73 -35
- package/src/feed/event-handlers/bookmark/bookmark-utils.test.ts +121 -109
- package/src/feed/event-handlers/bookmark/handle-bookmark-added.test.ts +178 -0
- package/src/feed/event-handlers/bookmark/handle-bookmark-added.ts +82 -39
- package/src/feed/event-handlers/bookmark/handle-bookmark-deleted.test.ts +188 -0
- package/src/feed/event-handlers/bookmark/handle-bookmark-deleted.ts +86 -48
- package/src/feed/event-handlers/bookmark/handle-bookmark-updated.test.ts +196 -0
- package/src/feed/event-handlers/bookmark/handle-bookmark-updated.ts +83 -44
- package/src/feed/event-handlers/follow/handle-follow-created.test.ts +16 -12
- package/src/feed/event-handlers/follow/handle-follow-created.ts +4 -7
- package/src/feed/event-handlers/follow/handle-follow-deleted.test.ts +19 -15
- package/src/feed/event-handlers/follow/handle-follow-deleted.ts +6 -6
- package/src/feed/event-handlers/follow/handle-follow-updated.ts +7 -10
- package/src/feed/event-handlers/index.ts +2 -1
- package/src/feed/event-handlers/watch/handle-watch-started.ts +5 -0
- package/src/feed/event-handlers/watch/handle-watch-stopped.ts +5 -0
- package/src/feed/event-handlers/watch/index.ts +2 -0
- package/src/feed/feed.ts +15 -33
- package/src/feeds-client/event-handlers/index.ts +1 -0
- package/src/feeds-client/event-handlers/user/handle-user-updated.test.ts +53 -0
- package/src/feeds-client/event-handlers/user/handle-user-updated.ts +28 -0
- package/src/{feeds-client.ts → feeds-client/feeds-client.ts} +48 -39
- package/src/feeds-client/index.ts +2 -0
- package/src/gen/feeds/FeedsApi.ts +164 -138
- package/src/gen/model-decoders/decoders.ts +28 -0
- package/src/gen/models/index.ts +349 -29
- package/src/gen/moderation/ModerationApi.ts +1 -0
- package/src/test-utils/response-generators.ts +270 -11
- package/src/utils/index.ts +1 -0
- package/src/utils/state-update-queue.ts +1 -1
- package/src/utils/update-entity-in-array.ts +51 -0
package/dist/index.node.js
CHANGED
|
@@ -338,6 +338,7 @@ decoders.Channel = (input) => {
|
|
|
338
338
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
339
339
|
deleted_at: { type: 'DatetimeType', isSingle: true },
|
|
340
340
|
last_message_at: { type: 'DatetimeType', isSingle: true },
|
|
341
|
+
message_count_updated_at: { type: 'DatetimeType', isSingle: true },
|
|
341
342
|
active_live_locations: { type: 'SharedLocation', isSingle: false },
|
|
342
343
|
invites: { type: 'ChannelMember', isSingle: false },
|
|
343
344
|
members: { type: 'ChannelMember', isSingle: false },
|
|
@@ -615,6 +616,7 @@ decoders.FeedMemberResponse = (input) => {
|
|
|
615
616
|
user: { type: 'UserResponse', isSingle: true },
|
|
616
617
|
invite_accepted_at: { type: 'DatetimeType', isSingle: true },
|
|
617
618
|
invite_rejected_at: { type: 'DatetimeType', isSingle: true },
|
|
619
|
+
membership_level: { type: 'MembershipLevelResponse', isSingle: true },
|
|
618
620
|
};
|
|
619
621
|
return decode(typeMappings, input);
|
|
620
622
|
};
|
|
@@ -632,6 +634,7 @@ decoders.FeedResponse = (input) => {
|
|
|
632
634
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
633
635
|
created_by: { type: 'UserResponse', isSingle: true },
|
|
634
636
|
deleted_at: { type: 'DatetimeType', isSingle: true },
|
|
637
|
+
own_follows: { type: 'FollowResponse', isSingle: false },
|
|
635
638
|
};
|
|
636
639
|
return decode(typeMappings, input);
|
|
637
640
|
};
|
|
@@ -786,6 +789,13 @@ decoders.ListDevicesResponse = (input) => {
|
|
|
786
789
|
};
|
|
787
790
|
return decode(typeMappings, input);
|
|
788
791
|
};
|
|
792
|
+
decoders.MembershipLevelResponse = (input) => {
|
|
793
|
+
const typeMappings = {
|
|
794
|
+
created_at: { type: 'DatetimeType', isSingle: true },
|
|
795
|
+
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
796
|
+
};
|
|
797
|
+
return decode(typeMappings, input);
|
|
798
|
+
};
|
|
789
799
|
decoders.Message = (input) => {
|
|
790
800
|
const typeMappings = {
|
|
791
801
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -850,6 +860,13 @@ decoders.ModerationCustomActionEvent = (input) => {
|
|
|
850
860
|
};
|
|
851
861
|
return decode(typeMappings, input);
|
|
852
862
|
};
|
|
863
|
+
decoders.ModerationFlagResponse = (input) => {
|
|
864
|
+
const typeMappings = {
|
|
865
|
+
review_queue_item: { type: 'ReviewQueueItemResponse', isSingle: true },
|
|
866
|
+
user: { type: 'UserResponse', isSingle: true },
|
|
867
|
+
};
|
|
868
|
+
return decode(typeMappings, input);
|
|
869
|
+
};
|
|
853
870
|
decoders.ModerationFlaggedEvent = (input) => {
|
|
854
871
|
const typeMappings = {
|
|
855
872
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -886,6 +903,7 @@ decoders.NotificationFeedUpdatedEvent = (input) => {
|
|
|
886
903
|
};
|
|
887
904
|
decoders.NotificationStatusResponse = (input) => {
|
|
888
905
|
const typeMappings = {
|
|
906
|
+
last_read_at: { type: 'DatetimeType', isSingle: true },
|
|
889
907
|
last_seen_at: { type: 'DatetimeType', isSingle: true },
|
|
890
908
|
};
|
|
891
909
|
return decode(typeMappings, input);
|
|
@@ -1153,6 +1171,7 @@ decoders.ReviewQueueItemResponse = (input) => {
|
|
|
1153
1171
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1154
1172
|
actions: { type: 'ActionLogResponse', isSingle: false },
|
|
1155
1173
|
bans: { type: 'Ban', isSingle: false },
|
|
1174
|
+
flags: { type: 'ModerationFlagResponse', isSingle: false },
|
|
1156
1175
|
completed_at: { type: 'DatetimeType', isSingle: true },
|
|
1157
1176
|
reviewed_at: { type: 'DatetimeType', isSingle: true },
|
|
1158
1177
|
assigned_to: { type: 'UserResponse', isSingle: true },
|
|
@@ -1475,7 +1494,7 @@ class FeedsApi {
|
|
|
1475
1494
|
async addActivity(request) {
|
|
1476
1495
|
const body = {
|
|
1477
1496
|
type: request?.type,
|
|
1478
|
-
|
|
1497
|
+
feeds: request?.feeds,
|
|
1479
1498
|
expires_at: request?.expires_at,
|
|
1480
1499
|
id: request?.id,
|
|
1481
1500
|
parent_id: request?.parent_id,
|
|
@@ -1505,7 +1524,7 @@ class FeedsApi {
|
|
|
1505
1524
|
}
|
|
1506
1525
|
async deleteActivities(request) {
|
|
1507
1526
|
const body = {
|
|
1508
|
-
|
|
1527
|
+
ids: request?.ids,
|
|
1509
1528
|
hard_delete: request?.hard_delete,
|
|
1510
1529
|
};
|
|
1511
1530
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/delete', undefined, undefined, body, 'application/json');
|
|
@@ -1524,56 +1543,6 @@ class FeedsApi {
|
|
|
1524
1543
|
decoders.QueryActivitiesResponse?.(response.body);
|
|
1525
1544
|
return { ...response.body, metadata: response.metadata };
|
|
1526
1545
|
}
|
|
1527
|
-
async deleteActivity(request) {
|
|
1528
|
-
const queryParams = {
|
|
1529
|
-
hard_delete: request?.hard_delete,
|
|
1530
|
-
};
|
|
1531
|
-
const pathParams = {
|
|
1532
|
-
activity_id: request?.activity_id,
|
|
1533
|
-
};
|
|
1534
|
-
const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/activities/{activity_id}', pathParams, queryParams);
|
|
1535
|
-
decoders.DeleteActivityResponse?.(response.body);
|
|
1536
|
-
return { ...response.body, metadata: response.metadata };
|
|
1537
|
-
}
|
|
1538
|
-
async getActivity(request) {
|
|
1539
|
-
const pathParams = {
|
|
1540
|
-
activity_id: request?.activity_id,
|
|
1541
|
-
};
|
|
1542
|
-
const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined);
|
|
1543
|
-
decoders.GetActivityResponse?.(response.body);
|
|
1544
|
-
return { ...response.body, metadata: response.metadata };
|
|
1545
|
-
}
|
|
1546
|
-
async updateActivityPartial(request) {
|
|
1547
|
-
const pathParams = {
|
|
1548
|
-
activity_id: request?.activity_id,
|
|
1549
|
-
};
|
|
1550
|
-
const body = {
|
|
1551
|
-
unset: request?.unset,
|
|
1552
|
-
set: request?.set,
|
|
1553
|
-
};
|
|
1554
|
-
const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined, body, 'application/json');
|
|
1555
|
-
decoders.UpdateActivityPartialResponse?.(response.body);
|
|
1556
|
-
return { ...response.body, metadata: response.metadata };
|
|
1557
|
-
}
|
|
1558
|
-
async updateActivity(request) {
|
|
1559
|
-
const pathParams = {
|
|
1560
|
-
activity_id: request?.activity_id,
|
|
1561
|
-
};
|
|
1562
|
-
const body = {
|
|
1563
|
-
expires_at: request?.expires_at,
|
|
1564
|
-
poll_id: request?.poll_id,
|
|
1565
|
-
text: request?.text,
|
|
1566
|
-
visibility: request?.visibility,
|
|
1567
|
-
attachments: request?.attachments,
|
|
1568
|
-
filter_tags: request?.filter_tags,
|
|
1569
|
-
interest_tags: request?.interest_tags,
|
|
1570
|
-
custom: request?.custom,
|
|
1571
|
-
location: request?.location,
|
|
1572
|
-
};
|
|
1573
|
-
const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined, body, 'application/json');
|
|
1574
|
-
decoders.UpdateActivityResponse?.(response.body);
|
|
1575
|
-
return { ...response.body, metadata: response.metadata };
|
|
1576
|
-
}
|
|
1577
1546
|
async deleteBookmark(request) {
|
|
1578
1547
|
const queryParams = {
|
|
1579
1548
|
folder_id: request?.folder_id,
|
|
@@ -1612,6 +1581,21 @@ class FeedsApi {
|
|
|
1612
1581
|
decoders.AddBookmarkResponse?.(response.body);
|
|
1613
1582
|
return { ...response.body, metadata: response.metadata };
|
|
1614
1583
|
}
|
|
1584
|
+
async activityFeedback(request) {
|
|
1585
|
+
const pathParams = {
|
|
1586
|
+
activity_id: request?.activity_id,
|
|
1587
|
+
};
|
|
1588
|
+
const body = {
|
|
1589
|
+
hide: request?.hide,
|
|
1590
|
+
mute_user: request?.mute_user,
|
|
1591
|
+
reason: request?.reason,
|
|
1592
|
+
report: request?.report,
|
|
1593
|
+
show_less: request?.show_less,
|
|
1594
|
+
};
|
|
1595
|
+
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/{activity_id}/feedback', pathParams, undefined, body, 'application/json');
|
|
1596
|
+
decoders.ActivityFeedbackResponse?.(response.body);
|
|
1597
|
+
return { ...response.body, metadata: response.metadata };
|
|
1598
|
+
}
|
|
1615
1599
|
async castPollVote(request) {
|
|
1616
1600
|
const pathParams = {
|
|
1617
1601
|
activity_id: request?.activity_id,
|
|
@@ -1674,6 +1658,56 @@ class FeedsApi {
|
|
|
1674
1658
|
decoders.DeleteActivityReactionResponse?.(response.body);
|
|
1675
1659
|
return { ...response.body, metadata: response.metadata };
|
|
1676
1660
|
}
|
|
1661
|
+
async deleteActivity(request) {
|
|
1662
|
+
const queryParams = {
|
|
1663
|
+
hard_delete: request?.hard_delete,
|
|
1664
|
+
};
|
|
1665
|
+
const pathParams = {
|
|
1666
|
+
id: request?.id,
|
|
1667
|
+
};
|
|
1668
|
+
const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/activities/{id}', pathParams, queryParams);
|
|
1669
|
+
decoders.DeleteActivityResponse?.(response.body);
|
|
1670
|
+
return { ...response.body, metadata: response.metadata };
|
|
1671
|
+
}
|
|
1672
|
+
async getActivity(request) {
|
|
1673
|
+
const pathParams = {
|
|
1674
|
+
id: request?.id,
|
|
1675
|
+
};
|
|
1676
|
+
const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/activities/{id}', pathParams, undefined);
|
|
1677
|
+
decoders.GetActivityResponse?.(response.body);
|
|
1678
|
+
return { ...response.body, metadata: response.metadata };
|
|
1679
|
+
}
|
|
1680
|
+
async updateActivityPartial(request) {
|
|
1681
|
+
const pathParams = {
|
|
1682
|
+
id: request?.id,
|
|
1683
|
+
};
|
|
1684
|
+
const body = {
|
|
1685
|
+
unset: request?.unset,
|
|
1686
|
+
set: request?.set,
|
|
1687
|
+
};
|
|
1688
|
+
const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/activities/{id}', pathParams, undefined, body, 'application/json');
|
|
1689
|
+
decoders.UpdateActivityPartialResponse?.(response.body);
|
|
1690
|
+
return { ...response.body, metadata: response.metadata };
|
|
1691
|
+
}
|
|
1692
|
+
async updateActivity(request) {
|
|
1693
|
+
const pathParams = {
|
|
1694
|
+
id: request?.id,
|
|
1695
|
+
};
|
|
1696
|
+
const body = {
|
|
1697
|
+
expires_at: request?.expires_at,
|
|
1698
|
+
poll_id: request?.poll_id,
|
|
1699
|
+
text: request?.text,
|
|
1700
|
+
visibility: request?.visibility,
|
|
1701
|
+
attachments: request?.attachments,
|
|
1702
|
+
filter_tags: request?.filter_tags,
|
|
1703
|
+
interest_tags: request?.interest_tags,
|
|
1704
|
+
custom: request?.custom,
|
|
1705
|
+
location: request?.location,
|
|
1706
|
+
};
|
|
1707
|
+
const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/activities/{id}', pathParams, undefined, body, 'application/json');
|
|
1708
|
+
decoders.UpdateActivityResponse?.(response.body);
|
|
1709
|
+
return { ...response.body, metadata: response.metadata };
|
|
1710
|
+
}
|
|
1677
1711
|
async queryBookmarkFolders(request) {
|
|
1678
1712
|
const body = {
|
|
1679
1713
|
limit: request?.limit,
|
|
@@ -1769,49 +1803,52 @@ class FeedsApi {
|
|
|
1769
1803
|
return { ...response.body, metadata: response.metadata };
|
|
1770
1804
|
}
|
|
1771
1805
|
async deleteComment(request) {
|
|
1806
|
+
const queryParams = {
|
|
1807
|
+
hard_delete: request?.hard_delete,
|
|
1808
|
+
};
|
|
1772
1809
|
const pathParams = {
|
|
1773
|
-
|
|
1810
|
+
id: request?.id,
|
|
1774
1811
|
};
|
|
1775
|
-
const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{
|
|
1812
|
+
const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{id}', pathParams, queryParams);
|
|
1776
1813
|
decoders.DeleteCommentResponse?.(response.body);
|
|
1777
1814
|
return { ...response.body, metadata: response.metadata };
|
|
1778
1815
|
}
|
|
1779
1816
|
async getComment(request) {
|
|
1780
1817
|
const pathParams = {
|
|
1781
|
-
|
|
1818
|
+
id: request?.id,
|
|
1782
1819
|
};
|
|
1783
|
-
const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{
|
|
1820
|
+
const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{id}', pathParams, undefined);
|
|
1784
1821
|
decoders.GetCommentResponse?.(response.body);
|
|
1785
1822
|
return { ...response.body, metadata: response.metadata };
|
|
1786
1823
|
}
|
|
1787
1824
|
async updateComment(request) {
|
|
1788
1825
|
const pathParams = {
|
|
1789
|
-
|
|
1826
|
+
id: request?.id,
|
|
1790
1827
|
};
|
|
1791
1828
|
const body = {
|
|
1792
1829
|
comment: request?.comment,
|
|
1793
1830
|
custom: request?.custom,
|
|
1794
1831
|
};
|
|
1795
|
-
const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/comments/{
|
|
1832
|
+
const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/comments/{id}', pathParams, undefined, body, 'application/json');
|
|
1796
1833
|
decoders.UpdateCommentResponse?.(response.body);
|
|
1797
1834
|
return { ...response.body, metadata: response.metadata };
|
|
1798
1835
|
}
|
|
1799
1836
|
async addCommentReaction(request) {
|
|
1800
1837
|
const pathParams = {
|
|
1801
|
-
|
|
1838
|
+
id: request?.id,
|
|
1802
1839
|
};
|
|
1803
1840
|
const body = {
|
|
1804
1841
|
type: request?.type,
|
|
1805
1842
|
create_notification_activity: request?.create_notification_activity,
|
|
1806
1843
|
custom: request?.custom,
|
|
1807
1844
|
};
|
|
1808
|
-
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{
|
|
1845
|
+
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{id}/reactions', pathParams, undefined, body, 'application/json');
|
|
1809
1846
|
decoders.AddCommentReactionResponse?.(response.body);
|
|
1810
1847
|
return { ...response.body, metadata: response.metadata };
|
|
1811
1848
|
}
|
|
1812
1849
|
async queryCommentReactions(request) {
|
|
1813
1850
|
const pathParams = {
|
|
1814
|
-
|
|
1851
|
+
id: request?.id,
|
|
1815
1852
|
};
|
|
1816
1853
|
const body = {
|
|
1817
1854
|
limit: request?.limit,
|
|
@@ -1820,16 +1857,16 @@ class FeedsApi {
|
|
|
1820
1857
|
sort: request?.sort,
|
|
1821
1858
|
filter: request?.filter,
|
|
1822
1859
|
};
|
|
1823
|
-
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{
|
|
1860
|
+
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{id}/reactions/query', pathParams, undefined, body, 'application/json');
|
|
1824
1861
|
decoders.QueryCommentReactionsResponse?.(response.body);
|
|
1825
1862
|
return { ...response.body, metadata: response.metadata };
|
|
1826
1863
|
}
|
|
1827
1864
|
async deleteCommentReaction(request) {
|
|
1828
1865
|
const pathParams = {
|
|
1829
|
-
|
|
1866
|
+
id: request?.id,
|
|
1830
1867
|
type: request?.type,
|
|
1831
1868
|
};
|
|
1832
|
-
const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{
|
|
1869
|
+
const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{id}/reactions/{type}', pathParams, undefined);
|
|
1833
1870
|
decoders.DeleteCommentReactionResponse?.(response.body);
|
|
1834
1871
|
return { ...response.body, metadata: response.metadata };
|
|
1835
1872
|
}
|
|
@@ -1843,9 +1880,9 @@ class FeedsApi {
|
|
|
1843
1880
|
next: request?.next,
|
|
1844
1881
|
};
|
|
1845
1882
|
const pathParams = {
|
|
1846
|
-
|
|
1883
|
+
id: request?.id,
|
|
1847
1884
|
};
|
|
1848
|
-
const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{
|
|
1885
|
+
const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{id}/replies', pathParams, queryParams);
|
|
1849
1886
|
decoders.GetCommentRepliesResponse?.(response.body);
|
|
1850
1887
|
return { ...response.body, metadata: response.metadata };
|
|
1851
1888
|
}
|
|
@@ -1894,7 +1931,6 @@ class FeedsApi {
|
|
|
1894
1931
|
feed_id: request?.feed_id,
|
|
1895
1932
|
};
|
|
1896
1933
|
const body = {
|
|
1897
|
-
created_by_id: request?.created_by_id,
|
|
1898
1934
|
custom: request?.custom,
|
|
1899
1935
|
};
|
|
1900
1936
|
const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/feed_groups/{feed_group_id}/feeds/{feed_id}', pathParams, undefined, body, 'application/json');
|
|
@@ -1910,6 +1946,7 @@ class FeedsApi {
|
|
|
1910
1946
|
mark_all_read: request?.mark_all_read,
|
|
1911
1947
|
mark_all_seen: request?.mark_all_seen,
|
|
1912
1948
|
mark_read: request?.mark_read,
|
|
1949
|
+
mark_seen: request?.mark_seen,
|
|
1913
1950
|
mark_watched: request?.mark_watched,
|
|
1914
1951
|
};
|
|
1915
1952
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/feed_groups/{feed_group_id}/feeds/{feed_id}/activities/mark/batch', pathParams, undefined, body, 'application/json');
|
|
@@ -2020,7 +2057,7 @@ class FeedsApi {
|
|
|
2020
2057
|
decoders.CreateFeedsBatchResponse?.(response.body);
|
|
2021
2058
|
return { ...response.body, metadata: response.metadata };
|
|
2022
2059
|
}
|
|
2023
|
-
async
|
|
2060
|
+
async _queryFeeds(request) {
|
|
2024
2061
|
const queryParams = {
|
|
2025
2062
|
connection_id: request?.connection_id,
|
|
2026
2063
|
};
|
|
@@ -2063,8 +2100,8 @@ class FeedsApi {
|
|
|
2063
2100
|
}
|
|
2064
2101
|
async acceptFollow(request) {
|
|
2065
2102
|
const body = {
|
|
2066
|
-
|
|
2067
|
-
|
|
2103
|
+
source: request?.source,
|
|
2104
|
+
target: request?.target,
|
|
2068
2105
|
follower_role: request?.follower_role,
|
|
2069
2106
|
};
|
|
2070
2107
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/follows/accept', undefined, undefined, body, 'application/json');
|
|
@@ -2093,8 +2130,8 @@ class FeedsApi {
|
|
|
2093
2130
|
}
|
|
2094
2131
|
async rejectFollow(request) {
|
|
2095
2132
|
const body = {
|
|
2096
|
-
|
|
2097
|
-
|
|
2133
|
+
source: request?.source,
|
|
2134
|
+
target: request?.target,
|
|
2098
2135
|
};
|
|
2099
2136
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/follows/reject', undefined, undefined, body, 'application/json');
|
|
2100
2137
|
decoders.RejectFollowResponse?.(response.body);
|
|
@@ -3790,6 +3827,7 @@ class ModerationApi {
|
|
|
3790
3827
|
block_list_config: request?.block_list_config,
|
|
3791
3828
|
bodyguard_config: request?.bodyguard_config,
|
|
3792
3829
|
google_vision_config: request?.google_vision_config,
|
|
3830
|
+
llm_config: request?.llm_config,
|
|
3793
3831
|
rule_builder_config: request?.rule_builder_config,
|
|
3794
3832
|
velocity_filter_config: request?.velocity_filter_config,
|
|
3795
3833
|
video_call_rule_config: request?.video_call_rule_config,
|
|
@@ -4262,7 +4300,7 @@ const shouldUpdateState = ({ stateUpdateQueueId, stateUpdateQueue, watch, }) =>
|
|
|
4262
4300
|
};
|
|
4263
4301
|
function getStateUpdateQueueId(data, prefix) {
|
|
4264
4302
|
if (isFollowResponse(data)) {
|
|
4265
|
-
const toJoin = [data.source_feed.
|
|
4303
|
+
const toJoin = [data.source_feed.feed, data.target_feed.feed];
|
|
4266
4304
|
if (prefix) {
|
|
4267
4305
|
toJoin.unshift(prefix);
|
|
4268
4306
|
}
|
|
@@ -4273,6 +4311,23 @@ function getStateUpdateQueueId(data, prefix) {
|
|
|
4273
4311
|
throw new Error(`Cannot create state update queueId for data: ${JSON.stringify(data)}`);
|
|
4274
4312
|
}
|
|
4275
4313
|
|
|
4314
|
+
function updateEntityInArray({ matcher, updater, entities, }) {
|
|
4315
|
+
if (!entities || !entities.length) {
|
|
4316
|
+
return { changed: false, entities };
|
|
4317
|
+
}
|
|
4318
|
+
const index = entities.findIndex(matcher);
|
|
4319
|
+
if (index === -1) {
|
|
4320
|
+
return { changed: false, entities };
|
|
4321
|
+
}
|
|
4322
|
+
const newEntity = updater(entities[index]);
|
|
4323
|
+
if (newEntity === entities[index]) {
|
|
4324
|
+
return { changed: false, entities };
|
|
4325
|
+
}
|
|
4326
|
+
const updatedEntities = [...entities];
|
|
4327
|
+
updatedEntities[index] = newEntity;
|
|
4328
|
+
return { changed: true, entities: updatedEntities };
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4276
4331
|
const updateStateFollowCreated = (follow, currentState, currentFeedId, connectedUserId) => {
|
|
4277
4332
|
// filter non-accepted follows (the way getOrCreate does by default)
|
|
4278
4333
|
if (follow.status !== 'accepted') {
|
|
@@ -4280,7 +4335,7 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
|
|
|
4280
4335
|
}
|
|
4281
4336
|
let newState = { ...currentState };
|
|
4282
4337
|
// this feed followed someone
|
|
4283
|
-
if (follow.source_feed.
|
|
4338
|
+
if (follow.source_feed.feed === currentFeedId) {
|
|
4284
4339
|
newState = {
|
|
4285
4340
|
...newState,
|
|
4286
4341
|
// Update FeedResponse fields, that has the new follower/following count
|
|
@@ -4293,7 +4348,7 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
|
|
|
4293
4348
|
}
|
|
4294
4349
|
else if (
|
|
4295
4350
|
// someone followed this feed
|
|
4296
|
-
follow.target_feed.
|
|
4351
|
+
follow.target_feed.feed === currentFeedId) {
|
|
4297
4352
|
const source = follow.source_feed;
|
|
4298
4353
|
newState = {
|
|
4299
4354
|
...newState,
|
|
@@ -4322,7 +4377,7 @@ function handleFollowCreated(eventOrResponse) {
|
|
|
4322
4377
|
return;
|
|
4323
4378
|
}
|
|
4324
4379
|
const connectedUser = this.client.state.getLatestValue().connected_user;
|
|
4325
|
-
const result = updateStateFollowCreated(follow, this.currentState, this.
|
|
4380
|
+
const result = updateStateFollowCreated(follow, this.currentState, this.feed, connectedUser?.id);
|
|
4326
4381
|
if (result.changed) {
|
|
4327
4382
|
this.state.next(result.data);
|
|
4328
4383
|
}
|
|
@@ -4331,7 +4386,7 @@ function handleFollowCreated(eventOrResponse) {
|
|
|
4331
4386
|
const updateStateFollowDeleted = (follow, currentState, currentFeedId, connectedUserId) => {
|
|
4332
4387
|
let newState = { ...currentState };
|
|
4333
4388
|
// this feed unfollowed someone
|
|
4334
|
-
if (follow.source_feed.
|
|
4389
|
+
if (follow.source_feed.feed === currentFeedId) {
|
|
4335
4390
|
newState = {
|
|
4336
4391
|
...newState,
|
|
4337
4392
|
// Update FeedResponse fields, that has the new follower/following count
|
|
@@ -4339,12 +4394,12 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
|
|
|
4339
4394
|
};
|
|
4340
4395
|
// Only update if following array already exists
|
|
4341
4396
|
if (currentState.following !== undefined) {
|
|
4342
|
-
newState.following = currentState.following.filter((followItem) => followItem.target_feed.
|
|
4397
|
+
newState.following = currentState.following.filter((followItem) => followItem.target_feed.feed !== follow.target_feed.feed);
|
|
4343
4398
|
}
|
|
4344
4399
|
}
|
|
4345
4400
|
else if (
|
|
4346
4401
|
// someone unfollowed this feed
|
|
4347
|
-
follow.target_feed.
|
|
4402
|
+
follow.target_feed.feed === currentFeedId) {
|
|
4348
4403
|
const source = follow.source_feed;
|
|
4349
4404
|
newState = {
|
|
4350
4405
|
...newState,
|
|
@@ -4353,11 +4408,11 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
|
|
|
4353
4408
|
};
|
|
4354
4409
|
if (source.created_by.id === connectedUserId &&
|
|
4355
4410
|
currentState.own_follows !== undefined) {
|
|
4356
|
-
newState.own_follows = currentState.own_follows.filter((followItem) => followItem.source_feed.
|
|
4411
|
+
newState.own_follows = currentState.own_follows.filter((followItem) => followItem.source_feed.feed !== follow.source_feed.feed);
|
|
4357
4412
|
}
|
|
4358
4413
|
// Only update if followers array already exists
|
|
4359
4414
|
if (currentState.followers !== undefined) {
|
|
4360
|
-
newState.followers = currentState.followers.filter((followItem) => followItem.source_feed.
|
|
4415
|
+
newState.followers = currentState.followers.filter((followItem) => followItem.source_feed.feed !== follow.source_feed.feed);
|
|
4361
4416
|
}
|
|
4362
4417
|
}
|
|
4363
4418
|
return { changed: true, data: newState };
|
|
@@ -4372,7 +4427,7 @@ function handleFollowDeleted(eventOrResponse) {
|
|
|
4372
4427
|
return;
|
|
4373
4428
|
}
|
|
4374
4429
|
const connectedUser = this.client.state.getLatestValue().connected_user;
|
|
4375
|
-
const result = updateStateFollowDeleted(follow, this.currentState, this.
|
|
4430
|
+
const result = updateStateFollowDeleted(follow, this.currentState, this.feed, connectedUser?.id);
|
|
4376
4431
|
{
|
|
4377
4432
|
this.state.next(result.data);
|
|
4378
4433
|
}
|
|
@@ -4381,7 +4436,7 @@ function handleFollowDeleted(eventOrResponse) {
|
|
|
4381
4436
|
function handleFollowUpdated(eventOrResponse) {
|
|
4382
4437
|
const follow = eventOrResponse.follow;
|
|
4383
4438
|
const connectedUserId = this.client.state.getLatestValue().connected_user?.id;
|
|
4384
|
-
const currentFeedId = this.
|
|
4439
|
+
const currentFeedId = this.feed;
|
|
4385
4440
|
if (!shouldUpdateState({
|
|
4386
4441
|
stateUpdateQueueId: getStateUpdateQueueId(follow, 'updated'),
|
|
4387
4442
|
stateUpdateQueue: this.stateUpdateQueue,
|
|
@@ -4392,13 +4447,13 @@ function handleFollowUpdated(eventOrResponse) {
|
|
|
4392
4447
|
this.state.next((currentState) => {
|
|
4393
4448
|
let newState;
|
|
4394
4449
|
// this feed followed someone
|
|
4395
|
-
if (follow.source_feed.
|
|
4450
|
+
if (follow.source_feed.feed === currentFeedId) {
|
|
4396
4451
|
newState ?? (newState = {
|
|
4397
4452
|
...currentState,
|
|
4398
4453
|
// Update FeedResponse fields, that has the new follower/following count
|
|
4399
4454
|
...follow.source_feed,
|
|
4400
4455
|
});
|
|
4401
|
-
const index = currentState.following?.findIndex((f) => f.target_feed.
|
|
4456
|
+
const index = currentState.following?.findIndex((f) => f.target_feed.feed === follow.target_feed.feed) ?? -1;
|
|
4402
4457
|
if (index >= 0) {
|
|
4403
4458
|
newState.following = [...newState.following];
|
|
4404
4459
|
newState.following[index] = follow;
|
|
@@ -4406,7 +4461,7 @@ function handleFollowUpdated(eventOrResponse) {
|
|
|
4406
4461
|
}
|
|
4407
4462
|
else if (
|
|
4408
4463
|
// someone followed this feed
|
|
4409
|
-
follow.target_feed.
|
|
4464
|
+
follow.target_feed.feed === currentFeedId) {
|
|
4410
4465
|
const source = follow.source_feed;
|
|
4411
4466
|
newState ?? (newState = {
|
|
4412
4467
|
...currentState,
|
|
@@ -4415,13 +4470,13 @@ function handleFollowUpdated(eventOrResponse) {
|
|
|
4415
4470
|
});
|
|
4416
4471
|
if (source.created_by.id === connectedUserId &&
|
|
4417
4472
|
currentState.own_follows) {
|
|
4418
|
-
const index = currentState.own_follows.findIndex((f) => f.source_feed.
|
|
4473
|
+
const index = currentState.own_follows.findIndex((f) => f.source_feed.feed === follow.source_feed.feed);
|
|
4419
4474
|
if (index >= 0) {
|
|
4420
4475
|
newState.own_follows = [...currentState.own_follows];
|
|
4421
4476
|
newState.own_follows[index] = follow;
|
|
4422
4477
|
}
|
|
4423
4478
|
}
|
|
4424
|
-
const index = currentState.followers?.findIndex((f) => f.source_feed.
|
|
4479
|
+
const index = currentState.followers?.findIndex((f) => f.source_feed.feed === follow.source_feed.feed) ?? -1;
|
|
4425
4480
|
if (index >= 0) {
|
|
4426
4481
|
newState.followers = [...newState.followers];
|
|
4427
4482
|
newState.followers[index] = follow;
|
|
@@ -4608,6 +4663,179 @@ function handleFeedMemberRemoved(event) {
|
|
|
4608
4663
|
});
|
|
4609
4664
|
}
|
|
4610
4665
|
|
|
4666
|
+
const sharedUpdateActivity$5 = ({ currentActivity, event, eventBelongsToCurrentUser, }) => {
|
|
4667
|
+
let newOwnBookmarks = currentActivity.own_bookmarks;
|
|
4668
|
+
if (eventBelongsToCurrentUser) {
|
|
4669
|
+
newOwnBookmarks = [...newOwnBookmarks, event.bookmark];
|
|
4670
|
+
}
|
|
4671
|
+
return {
|
|
4672
|
+
...event.bookmark.activity,
|
|
4673
|
+
own_bookmarks: newOwnBookmarks,
|
|
4674
|
+
own_reactions: currentActivity.own_reactions,
|
|
4675
|
+
};
|
|
4676
|
+
};
|
|
4677
|
+
const addBookmarkToActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4678
|
+
entities: activities,
|
|
4679
|
+
matcher: (activity) => activity.id === event.bookmark.activity.id,
|
|
4680
|
+
updater: (matchedActivity) => sharedUpdateActivity$5({
|
|
4681
|
+
currentActivity: matchedActivity,
|
|
4682
|
+
event,
|
|
4683
|
+
eventBelongsToCurrentUser,
|
|
4684
|
+
}),
|
|
4685
|
+
});
|
|
4686
|
+
const addBookmarkToPinnedActivities = (event, pinnedActivities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4687
|
+
entities: pinnedActivities,
|
|
4688
|
+
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
|
|
4689
|
+
updater: (matchedPinnedActivity) => {
|
|
4690
|
+
const newActivity = sharedUpdateActivity$5({
|
|
4691
|
+
currentActivity: matchedPinnedActivity.activity,
|
|
4692
|
+
event,
|
|
4693
|
+
eventBelongsToCurrentUser,
|
|
4694
|
+
});
|
|
4695
|
+
if (newActivity === matchedPinnedActivity.activity) {
|
|
4696
|
+
return matchedPinnedActivity;
|
|
4697
|
+
}
|
|
4698
|
+
return {
|
|
4699
|
+
...matchedPinnedActivity,
|
|
4700
|
+
activity: newActivity,
|
|
4701
|
+
};
|
|
4702
|
+
},
|
|
4703
|
+
});
|
|
4704
|
+
function handleBookmarkAdded(event) {
|
|
4705
|
+
const { activities: currentActivities, pinned_activities: currentPinnedActivities, } = this.currentState;
|
|
4706
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
4707
|
+
const eventBelongsToCurrentUser = event.bookmark.user.id === connectedUser?.id;
|
|
4708
|
+
const [result1, result2] = [
|
|
4709
|
+
addBookmarkToActivities(event, currentActivities, eventBelongsToCurrentUser),
|
|
4710
|
+
addBookmarkToPinnedActivities(event, currentPinnedActivities, eventBelongsToCurrentUser),
|
|
4711
|
+
];
|
|
4712
|
+
if (result1.changed || result2.changed) {
|
|
4713
|
+
this.state.partialNext({
|
|
4714
|
+
activities: result1.entities,
|
|
4715
|
+
pinned_activities: result2.entities,
|
|
4716
|
+
});
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
|
|
4720
|
+
// Helper function to check if two bookmarks are the same
|
|
4721
|
+
// A bookmark is identified by activity_id + folder_id + user_id
|
|
4722
|
+
const isSameBookmark = (bookmark1, bookmark2) => {
|
|
4723
|
+
return (bookmark1.user.id === bookmark2.user.id &&
|
|
4724
|
+
bookmark1.activity.id === bookmark2.activity.id &&
|
|
4725
|
+
bookmark1.folder?.id === bookmark2.folder?.id);
|
|
4726
|
+
};
|
|
4727
|
+
const sharedUpdateActivity$4 = ({ currentActivity, event, eventBelongsToCurrentUser, }) => {
|
|
4728
|
+
let newOwnBookmarks = currentActivity.own_bookmarks;
|
|
4729
|
+
if (eventBelongsToCurrentUser) {
|
|
4730
|
+
newOwnBookmarks = currentActivity.own_bookmarks.filter((bookmark) => !isSameBookmark(bookmark, event.bookmark));
|
|
4731
|
+
}
|
|
4732
|
+
return {
|
|
4733
|
+
...event.bookmark.activity,
|
|
4734
|
+
own_bookmarks: newOwnBookmarks,
|
|
4735
|
+
own_reactions: currentActivity.own_reactions,
|
|
4736
|
+
};
|
|
4737
|
+
};
|
|
4738
|
+
const removeBookmarkFromActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4739
|
+
entities: activities,
|
|
4740
|
+
matcher: (activity) => activity.id === event.bookmark.activity.id,
|
|
4741
|
+
updater: (matchedActivity) => sharedUpdateActivity$4({
|
|
4742
|
+
currentActivity: matchedActivity,
|
|
4743
|
+
event,
|
|
4744
|
+
eventBelongsToCurrentUser,
|
|
4745
|
+
}),
|
|
4746
|
+
});
|
|
4747
|
+
const removeBookmarkFromPinnedActivities = (event, pinnedActivities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4748
|
+
entities: pinnedActivities,
|
|
4749
|
+
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
|
|
4750
|
+
updater: (matchedPinnedActivity) => {
|
|
4751
|
+
const newActivity = sharedUpdateActivity$4({
|
|
4752
|
+
currentActivity: matchedPinnedActivity.activity,
|
|
4753
|
+
event,
|
|
4754
|
+
eventBelongsToCurrentUser,
|
|
4755
|
+
});
|
|
4756
|
+
if (newActivity === matchedPinnedActivity.activity) {
|
|
4757
|
+
return matchedPinnedActivity;
|
|
4758
|
+
}
|
|
4759
|
+
return {
|
|
4760
|
+
...matchedPinnedActivity,
|
|
4761
|
+
activity: newActivity,
|
|
4762
|
+
};
|
|
4763
|
+
},
|
|
4764
|
+
});
|
|
4765
|
+
function handleBookmarkDeleted(event) {
|
|
4766
|
+
const { activities: currentActivities, pinned_activities: currentPinnedActivities, } = this.currentState;
|
|
4767
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
4768
|
+
const eventBelongsToCurrentUser = event.bookmark.user.id === connectedUser?.id;
|
|
4769
|
+
const [result1, result2] = [
|
|
4770
|
+
removeBookmarkFromActivities(event, currentActivities, eventBelongsToCurrentUser),
|
|
4771
|
+
removeBookmarkFromPinnedActivities(event, currentPinnedActivities, eventBelongsToCurrentUser),
|
|
4772
|
+
];
|
|
4773
|
+
if (result1.changed || result2.changed) {
|
|
4774
|
+
this.state.partialNext({
|
|
4775
|
+
activities: result1.entities,
|
|
4776
|
+
pinned_activities: result2.entities,
|
|
4777
|
+
});
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
|
|
4781
|
+
const sharedUpdateActivity$3 = ({ currentActivity, event, eventBelongsToCurrentUser, }) => {
|
|
4782
|
+
let newOwnBookmarks = currentActivity.own_bookmarks;
|
|
4783
|
+
if (eventBelongsToCurrentUser) {
|
|
4784
|
+
const bookmarkIndex = newOwnBookmarks.findIndex((bookmark) => isSameBookmark(bookmark, event.bookmark));
|
|
4785
|
+
if (bookmarkIndex !== -1) {
|
|
4786
|
+
newOwnBookmarks = [...newOwnBookmarks];
|
|
4787
|
+
newOwnBookmarks[bookmarkIndex] = event.bookmark;
|
|
4788
|
+
}
|
|
4789
|
+
}
|
|
4790
|
+
return {
|
|
4791
|
+
...event.bookmark.activity,
|
|
4792
|
+
own_bookmarks: newOwnBookmarks,
|
|
4793
|
+
own_reactions: currentActivity.own_reactions,
|
|
4794
|
+
};
|
|
4795
|
+
};
|
|
4796
|
+
const updateBookmarkInActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4797
|
+
entities: activities,
|
|
4798
|
+
matcher: (activity) => activity.id === event.bookmark.activity.id,
|
|
4799
|
+
updater: (matchedActivity) => sharedUpdateActivity$3({
|
|
4800
|
+
currentActivity: matchedActivity,
|
|
4801
|
+
event,
|
|
4802
|
+
eventBelongsToCurrentUser,
|
|
4803
|
+
}),
|
|
4804
|
+
});
|
|
4805
|
+
const updateBookmarkInPinnedActivities = (event, pinnedActivities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4806
|
+
entities: pinnedActivities,
|
|
4807
|
+
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
|
|
4808
|
+
updater: (matchedPinnedActivity) => {
|
|
4809
|
+
const newActivity = sharedUpdateActivity$3({
|
|
4810
|
+
currentActivity: matchedPinnedActivity.activity,
|
|
4811
|
+
event,
|
|
4812
|
+
eventBelongsToCurrentUser,
|
|
4813
|
+
});
|
|
4814
|
+
if (newActivity === matchedPinnedActivity.activity) {
|
|
4815
|
+
return matchedPinnedActivity;
|
|
4816
|
+
}
|
|
4817
|
+
return {
|
|
4818
|
+
...matchedPinnedActivity,
|
|
4819
|
+
activity: newActivity,
|
|
4820
|
+
};
|
|
4821
|
+
},
|
|
4822
|
+
});
|
|
4823
|
+
function handleBookmarkUpdated(event) {
|
|
4824
|
+
const { activities: currentActivities, pinned_activities: currentPinnedActivities, } = this.currentState;
|
|
4825
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
4826
|
+
const eventBelongsToCurrentUser = event.bookmark.user.id === connectedUser?.id;
|
|
4827
|
+
const [result1, result2] = [
|
|
4828
|
+
updateBookmarkInActivities(event, currentActivities, eventBelongsToCurrentUser),
|
|
4829
|
+
updateBookmarkInPinnedActivities(event, currentPinnedActivities, eventBelongsToCurrentUser),
|
|
4830
|
+
];
|
|
4831
|
+
if (result1.changed || result2.changed) {
|
|
4832
|
+
this.state.partialNext({
|
|
4833
|
+
activities: result1.entities,
|
|
4834
|
+
pinned_activities: result2.entities,
|
|
4835
|
+
});
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
|
|
4611
4839
|
const addActivitiesToState = (newActivities, activities, position) => {
|
|
4612
4840
|
let result;
|
|
4613
4841
|
if (activities === undefined) {
|
|
@@ -4652,7 +4880,8 @@ function handleActivityAdded(event) {
|
|
|
4652
4880
|
}
|
|
4653
4881
|
|
|
4654
4882
|
const removeActivityFromState = (activityResponse, activities) => {
|
|
4655
|
-
const index = activities
|
|
4883
|
+
const index = activities?.findIndex((activity) => activity.id === activityResponse.id) ??
|
|
4884
|
+
-1;
|
|
4656
4885
|
if (index !== -1) {
|
|
4657
4886
|
const newActivities = [...activities];
|
|
4658
4887
|
newActivities.splice(index, 1);
|
|
@@ -4662,13 +4891,28 @@ const removeActivityFromState = (activityResponse, activities) => {
|
|
|
4662
4891
|
return { changed: false, activities };
|
|
4663
4892
|
}
|
|
4664
4893
|
};
|
|
4894
|
+
const removePinnedActivityFromState = (activityResponse, pinnedActivities) => {
|
|
4895
|
+
const index = pinnedActivities?.findIndex((pinnedActivity) => pinnedActivity.activity.id === activityResponse.id) ?? -1;
|
|
4896
|
+
if (index !== -1) {
|
|
4897
|
+
const newActivities = [...pinnedActivities];
|
|
4898
|
+
newActivities.splice(index, 1);
|
|
4899
|
+
return { changed: true, activities: newActivities };
|
|
4900
|
+
}
|
|
4901
|
+
else {
|
|
4902
|
+
return { changed: false, pinned_activities: pinnedActivities };
|
|
4903
|
+
}
|
|
4904
|
+
};
|
|
4665
4905
|
function handleActivityDeleted(event) {
|
|
4666
|
-
const currentActivities = this.currentState
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4906
|
+
const { activities: currentActivities, pinned_activities: currentPinnedActivities, } = this.currentState;
|
|
4907
|
+
const [result1, result2] = [
|
|
4908
|
+
removeActivityFromState(event.activity, currentActivities),
|
|
4909
|
+
removePinnedActivityFromState(event.activity, currentPinnedActivities),
|
|
4910
|
+
];
|
|
4911
|
+
if (result1.changed || result2.changed) {
|
|
4912
|
+
this.state.partialNext({
|
|
4913
|
+
activities: result1.activities,
|
|
4914
|
+
pinned_activities: result2.pinned_activities,
|
|
4915
|
+
});
|
|
4672
4916
|
}
|
|
4673
4917
|
}
|
|
4674
4918
|
|
|
@@ -4682,221 +4926,163 @@ function handleActivityRemovedFromFeed(event) {
|
|
|
4682
4926
|
}
|
|
4683
4927
|
}
|
|
4684
4928
|
|
|
4685
|
-
const
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4929
|
+
const sharedUpdateActivity$2 = ({ currentActivity, event, }) => {
|
|
4930
|
+
return {
|
|
4931
|
+
...event.activity,
|
|
4932
|
+
own_reactions: currentActivity.own_reactions,
|
|
4933
|
+
own_bookmarks: currentActivity.own_bookmarks,
|
|
4934
|
+
};
|
|
4935
|
+
};
|
|
4936
|
+
const updateActivityInState = (event, activities) => updateEntityInArray({
|
|
4937
|
+
entities: activities,
|
|
4938
|
+
matcher: (activity) => activity.id === event.activity.id,
|
|
4939
|
+
updater: (matchedActivity) => sharedUpdateActivity$2({
|
|
4940
|
+
currentActivity: matchedActivity,
|
|
4941
|
+
event,
|
|
4942
|
+
}),
|
|
4943
|
+
});
|
|
4944
|
+
const updatePinnedActivityInState = (event, pinnedActivities) => updateEntityInArray({
|
|
4945
|
+
entities: pinnedActivities,
|
|
4946
|
+
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.activity.id,
|
|
4947
|
+
updater: (matchedPinnedActivity) => {
|
|
4948
|
+
const newActivity = sharedUpdateActivity$2({
|
|
4949
|
+
currentActivity: matchedPinnedActivity.activity,
|
|
4950
|
+
event,
|
|
4951
|
+
});
|
|
4952
|
+
if (newActivity === matchedPinnedActivity.activity) {
|
|
4953
|
+
return matchedPinnedActivity;
|
|
4701
4954
|
}
|
|
4702
|
-
return {
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
}
|
|
4707
|
-
};
|
|
4955
|
+
return {
|
|
4956
|
+
...matchedPinnedActivity,
|
|
4957
|
+
activity: newActivity,
|
|
4958
|
+
};
|
|
4959
|
+
},
|
|
4960
|
+
});
|
|
4708
4961
|
function handleActivityUpdated(event) {
|
|
4709
|
-
const currentActivities = this.currentState
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4962
|
+
const { activities: currentActivities, pinned_activities: currentPinnedActivities, } = this.currentState;
|
|
4963
|
+
const [result1, result2] = [
|
|
4964
|
+
updateActivityInState(event, currentActivities),
|
|
4965
|
+
updatePinnedActivityInState(event, currentPinnedActivities),
|
|
4966
|
+
];
|
|
4967
|
+
if (result1.changed || result2.changed) {
|
|
4968
|
+
this.client.hydratePollCache([event.activity]);
|
|
4969
|
+
this.state.partialNext({
|
|
4970
|
+
activities: result1.entities,
|
|
4971
|
+
pinned_activities: result2.entities,
|
|
4972
|
+
});
|
|
4716
4973
|
}
|
|
4717
4974
|
}
|
|
4718
4975
|
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
if (
|
|
4723
|
-
|
|
4976
|
+
// shared function to update the activity with the new reaction
|
|
4977
|
+
const sharedUpdateActivity$1 = ({ currentActivity, event, eventBelongsToCurrentUser, }) => {
|
|
4978
|
+
let newOwnReactions = currentActivity.own_reactions;
|
|
4979
|
+
if (eventBelongsToCurrentUser) {
|
|
4980
|
+
newOwnReactions = [...currentActivity.own_reactions, event.reaction];
|
|
4724
4981
|
}
|
|
4725
4982
|
return {
|
|
4726
|
-
...activity,
|
|
4727
|
-
own_reactions:
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4983
|
+
...event.activity,
|
|
4984
|
+
own_reactions: newOwnReactions,
|
|
4985
|
+
own_bookmarks: currentActivity.own_bookmarks,
|
|
4986
|
+
};
|
|
4987
|
+
};
|
|
4988
|
+
const addReactionToActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4989
|
+
entities: activities,
|
|
4990
|
+
matcher: (activity) => activity.id === event.activity.id,
|
|
4991
|
+
updater: (matchedActivity) => sharedUpdateActivity$1({
|
|
4992
|
+
currentActivity: matchedActivity,
|
|
4993
|
+
event,
|
|
4994
|
+
eventBelongsToCurrentUser,
|
|
4995
|
+
}),
|
|
4996
|
+
});
|
|
4997
|
+
const addReactionToPinnedActivities = (event, pinnedActivities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
4998
|
+
entities: pinnedActivities,
|
|
4999
|
+
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.activity.id,
|
|
5000
|
+
updater: (matchedPinnedActivity) => {
|
|
5001
|
+
const newActivity = sharedUpdateActivity$1({
|
|
5002
|
+
currentActivity: matchedPinnedActivity.activity,
|
|
5003
|
+
event,
|
|
5004
|
+
eventBelongsToCurrentUser,
|
|
5005
|
+
});
|
|
5006
|
+
// this should never happen, but just in case
|
|
5007
|
+
if (newActivity === matchedPinnedActivity.activity) {
|
|
5008
|
+
return matchedPinnedActivity;
|
|
5009
|
+
}
|
|
5010
|
+
return {
|
|
5011
|
+
...matchedPinnedActivity,
|
|
5012
|
+
activity: newActivity,
|
|
5013
|
+
};
|
|
5014
|
+
},
|
|
5015
|
+
});
|
|
4745
5016
|
function handleActivityReactionAdded(event) {
|
|
4746
|
-
const currentActivities = this.currentState
|
|
5017
|
+
const { activities: currentActivities, pinned_activities: currentPinnedActivities, } = this.currentState;
|
|
4747
5018
|
const connectedUser = this.client.state.getLatestValue().connected_user;
|
|
4748
|
-
const
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
r.user.id === event.reaction.user.id))
|
|
4760
|
-
: activity.own_reactions;
|
|
4761
|
-
return {
|
|
4762
|
-
...activity,
|
|
4763
|
-
own_reactions: ownReactions,
|
|
4764
|
-
latest_reactions: event.activity.latest_reactions,
|
|
4765
|
-
reaction_groups: event.activity.reaction_groups,
|
|
4766
|
-
changed: true,
|
|
4767
|
-
};
|
|
4768
|
-
};
|
|
4769
|
-
const removeReactionFromActivities = (event, activities, isCurrentUser) => {
|
|
4770
|
-
if (!activities) {
|
|
4771
|
-
return { changed: false, activities: [] };
|
|
4772
|
-
}
|
|
4773
|
-
const activityIndex = activities.findIndex((a) => a.id === event.activity.id);
|
|
4774
|
-
if (activityIndex === -1) {
|
|
4775
|
-
return { changed: false, activities };
|
|
4776
|
-
}
|
|
4777
|
-
const activity = activities[activityIndex];
|
|
4778
|
-
const updatedActivity = removeReactionFromActivity(event, activity, isCurrentUser);
|
|
4779
|
-
return updateActivityInState(updatedActivity, activities, true);
|
|
4780
|
-
};
|
|
4781
|
-
function handleActivityReactionDeleted(event) {
|
|
4782
|
-
const currentActivities = this.currentState.activities;
|
|
4783
|
-
const connectedUser = this.client.state.getLatestValue().connected_user;
|
|
4784
|
-
const isCurrentUser = Boolean(connectedUser && event.reaction.user.id === connectedUser.id);
|
|
4785
|
-
const result = removeReactionFromActivities(event, currentActivities, isCurrentUser);
|
|
4786
|
-
if (result.changed) {
|
|
4787
|
-
this.state.partialNext({ activities: result.activities });
|
|
4788
|
-
}
|
|
4789
|
-
}
|
|
4790
|
-
|
|
4791
|
-
const addBookmarkToActivity = (event, activity, isCurrentUser) => {
|
|
4792
|
-
// Update own_bookmarks if the bookmark is from the current user
|
|
4793
|
-
const ownBookmarks = [...(activity.own_bookmarks || [])];
|
|
4794
|
-
if (isCurrentUser) {
|
|
4795
|
-
ownBookmarks.push(event.bookmark);
|
|
4796
|
-
}
|
|
4797
|
-
return {
|
|
4798
|
-
...activity,
|
|
4799
|
-
own_bookmarks: ownBookmarks,
|
|
4800
|
-
changed: true,
|
|
4801
|
-
};
|
|
4802
|
-
};
|
|
4803
|
-
const addBookmarkToActivities = (event, activities, isCurrentUser) => {
|
|
4804
|
-
if (!activities) {
|
|
4805
|
-
return { changed: false, activities: [] };
|
|
4806
|
-
}
|
|
4807
|
-
const activityIndex = activities.findIndex((a) => a.id === event.bookmark.activity.id);
|
|
4808
|
-
if (activityIndex === -1) {
|
|
4809
|
-
return { changed: false, activities };
|
|
4810
|
-
}
|
|
4811
|
-
const activity = activities[activityIndex];
|
|
4812
|
-
const updatedActivity = addBookmarkToActivity(event, activity, isCurrentUser);
|
|
4813
|
-
return updateActivityInState(updatedActivity, activities, true);
|
|
4814
|
-
};
|
|
4815
|
-
function handleBookmarkAdded(event) {
|
|
4816
|
-
const currentActivities = this.currentState.activities;
|
|
4817
|
-
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
4818
|
-
const isCurrentUser = event.bookmark.user.id === connectedUser?.id;
|
|
4819
|
-
const result = addBookmarkToActivities(event, currentActivities, isCurrentUser);
|
|
4820
|
-
if (result.changed) {
|
|
4821
|
-
this.state.partialNext({ activities: result.activities });
|
|
5019
|
+
const eventBelongsToCurrentUser = typeof connectedUser !== 'undefined' &&
|
|
5020
|
+
event.reaction.user.id === connectedUser.id;
|
|
5021
|
+
const [result1, result2] = [
|
|
5022
|
+
addReactionToActivities(event, currentActivities, eventBelongsToCurrentUser),
|
|
5023
|
+
addReactionToPinnedActivities(event, currentPinnedActivities, eventBelongsToCurrentUser),
|
|
5024
|
+
];
|
|
5025
|
+
if (result1.changed || result2.changed) {
|
|
5026
|
+
this.state.partialNext({
|
|
5027
|
+
activities: result1.entities,
|
|
5028
|
+
pinned_activities: result2.entities,
|
|
5029
|
+
});
|
|
4822
5030
|
}
|
|
4823
5031
|
}
|
|
4824
5032
|
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
bookmark1.folder?.id === bookmark2.folder?.id);
|
|
4831
|
-
};
|
|
4832
|
-
const removeBookmarkFromActivities = (event, activities, isCurrentUser) => {
|
|
4833
|
-
if (!activities) {
|
|
4834
|
-
return { changed: false, activities: [] };
|
|
4835
|
-
}
|
|
4836
|
-
const activityIndex = activities.findIndex((a) => a.id === event.bookmark.activity.id);
|
|
4837
|
-
if (activityIndex === -1) {
|
|
4838
|
-
return { changed: false, activities };
|
|
5033
|
+
const sharedUpdateActivity = ({ currentActivity, event, eventBelongsToCurrentUser, }) => {
|
|
5034
|
+
let newOwnReactions = currentActivity.own_reactions;
|
|
5035
|
+
if (eventBelongsToCurrentUser) {
|
|
5036
|
+
newOwnReactions = currentActivity.own_reactions.filter((reaction) => !(reaction.type === event.reaction.type &&
|
|
5037
|
+
reaction.user.id === event.reaction.user.id));
|
|
4839
5038
|
}
|
|
4840
|
-
const activity = activities[activityIndex];
|
|
4841
|
-
const updatedActivity = removeBookmarkFromActivity(event, activity, isCurrentUser);
|
|
4842
|
-
return updateActivityInState(updatedActivity, activities, true);
|
|
4843
|
-
};
|
|
4844
|
-
const removeBookmarkFromActivity = (event, activity, isCurrentUser) => {
|
|
4845
|
-
// Update own_bookmarks if the bookmark is from the current user
|
|
4846
|
-
const ownBookmarks = isCurrentUser
|
|
4847
|
-
? (activity.own_bookmarks || []).filter((bookmark) => !isSameBookmark(bookmark, event.bookmark))
|
|
4848
|
-
: activity.own_bookmarks;
|
|
4849
5039
|
return {
|
|
4850
|
-
...activity,
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
};
|
|
4854
|
-
};
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
}
|
|
4863
|
-
}
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
5040
|
+
...event.activity,
|
|
5041
|
+
own_reactions: newOwnReactions,
|
|
5042
|
+
own_bookmarks: currentActivity.own_bookmarks,
|
|
5043
|
+
};
|
|
5044
|
+
};
|
|
5045
|
+
const removeReactionFromActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
5046
|
+
entities: activities,
|
|
5047
|
+
matcher: (activity) => activity.id === event.activity.id,
|
|
5048
|
+
updater: (matchedActivity) => sharedUpdateActivity({
|
|
5049
|
+
currentActivity: matchedActivity,
|
|
5050
|
+
event,
|
|
5051
|
+
eventBelongsToCurrentUser,
|
|
5052
|
+
}),
|
|
5053
|
+
});
|
|
5054
|
+
const removeReactionFromPinnedActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
5055
|
+
entities: activities,
|
|
5056
|
+
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.activity.id,
|
|
5057
|
+
updater: (matchedPinnedActivity) => {
|
|
5058
|
+
const newActivity = sharedUpdateActivity({
|
|
5059
|
+
currentActivity: matchedPinnedActivity.activity,
|
|
5060
|
+
event,
|
|
5061
|
+
eventBelongsToCurrentUser,
|
|
5062
|
+
});
|
|
5063
|
+
if (newActivity === matchedPinnedActivity.activity) {
|
|
5064
|
+
return matchedPinnedActivity;
|
|
4873
5065
|
}
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
const
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
const
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
const currentActivities = this.currentState.activities;
|
|
4895
|
-
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
4896
|
-
const isCurrentUser = event.bookmark.user.id === connectedUser?.id;
|
|
4897
|
-
const result = updateBookmarkInActivities(event, currentActivities, isCurrentUser);
|
|
4898
|
-
if (result.changed) {
|
|
4899
|
-
this.state.partialNext({ activities: result.activities });
|
|
5066
|
+
return {
|
|
5067
|
+
...matchedPinnedActivity,
|
|
5068
|
+
activity: newActivity,
|
|
5069
|
+
};
|
|
5070
|
+
},
|
|
5071
|
+
});
|
|
5072
|
+
function handleActivityReactionDeleted(event) {
|
|
5073
|
+
const { activities: currentActivities, pinned_activities: currentPinnedActivities, } = this.currentState;
|
|
5074
|
+
const connectedUser = this.client.state.getLatestValue().connected_user;
|
|
5075
|
+
const eventBelongsToCurrentUser = typeof connectedUser !== 'undefined' &&
|
|
5076
|
+
event.reaction.user.id === connectedUser.id;
|
|
5077
|
+
const [result1, result2] = [
|
|
5078
|
+
removeReactionFromActivities(event, currentActivities, eventBelongsToCurrentUser),
|
|
5079
|
+
removeReactionFromPinnedActivities(event, currentPinnedActivities, eventBelongsToCurrentUser),
|
|
5080
|
+
];
|
|
5081
|
+
if (result1.changed || result2.changed) {
|
|
5082
|
+
this.state.partialNext({
|
|
5083
|
+
activities: result1.entities,
|
|
5084
|
+
pinned_activities: result2.entities,
|
|
5085
|
+
});
|
|
4900
5086
|
}
|
|
4901
5087
|
}
|
|
4902
5088
|
|
|
@@ -4909,6 +5095,14 @@ function handleNotificationFeedUpdated(event) {
|
|
|
4909
5095
|
// TODO: handle notification feed updates
|
|
4910
5096
|
}
|
|
4911
5097
|
|
|
5098
|
+
function handleWatchStarted() {
|
|
5099
|
+
this.state.partialNext({ watch: true });
|
|
5100
|
+
}
|
|
5101
|
+
|
|
5102
|
+
function handleWatchStopped() {
|
|
5103
|
+
this.state.partialNext({ watch: false });
|
|
5104
|
+
}
|
|
5105
|
+
|
|
4912
5106
|
class Feed extends FeedApi {
|
|
4913
5107
|
constructor(client, groupId, id, data, watch = false) {
|
|
4914
5108
|
super(client, groupId, id);
|
|
@@ -4969,7 +5163,7 @@ class Feed extends FeedApi {
|
|
|
4969
5163
|
this.on = this.eventDispatcher.on;
|
|
4970
5164
|
this.off = this.eventDispatcher.off;
|
|
4971
5165
|
this.state = new StateStore({
|
|
4972
|
-
|
|
5166
|
+
feed: `${groupId}:${id}`,
|
|
4973
5167
|
group_id: groupId,
|
|
4974
5168
|
id,
|
|
4975
5169
|
...(data ?? {}),
|
|
@@ -4980,7 +5174,7 @@ class Feed extends FeedApi {
|
|
|
4980
5174
|
});
|
|
4981
5175
|
this.client = client;
|
|
4982
5176
|
}
|
|
4983
|
-
get
|
|
5177
|
+
get feed() {
|
|
4984
5178
|
return `${this.group}:${this.id}`;
|
|
4985
5179
|
}
|
|
4986
5180
|
get currentState() {
|
|
@@ -5055,22 +5249,6 @@ class Feed extends FeedApi {
|
|
|
5055
5249
|
});
|
|
5056
5250
|
}
|
|
5057
5251
|
}
|
|
5058
|
-
/**
|
|
5059
|
-
* @internal
|
|
5060
|
-
*/
|
|
5061
|
-
handleWatchStopped() {
|
|
5062
|
-
this.state.partialNext({
|
|
5063
|
-
watch: false,
|
|
5064
|
-
});
|
|
5065
|
-
}
|
|
5066
|
-
/**
|
|
5067
|
-
* @internal
|
|
5068
|
-
*/
|
|
5069
|
-
handleWatchStarted() {
|
|
5070
|
-
this.state.partialNext({
|
|
5071
|
-
watch: true,
|
|
5072
|
-
});
|
|
5073
|
-
}
|
|
5074
5252
|
/**
|
|
5075
5253
|
* Returns index of the provided comment object.
|
|
5076
5254
|
*/
|
|
@@ -5230,7 +5408,7 @@ class Feed extends FeedApi {
|
|
|
5230
5408
|
entityId: comment.id,
|
|
5231
5409
|
base: () => this.client.getCommentReplies({
|
|
5232
5410
|
...request,
|
|
5233
|
-
|
|
5411
|
+
id: comment.id,
|
|
5234
5412
|
// use known sort first (prevents broken pagination)
|
|
5235
5413
|
sort,
|
|
5236
5414
|
next: currentNextCursor,
|
|
@@ -5270,7 +5448,7 @@ class Feed extends FeedApi {
|
|
|
5270
5448
|
...currentState,
|
|
5271
5449
|
[type]: currentState[type] === undefined
|
|
5272
5450
|
? follows
|
|
5273
|
-
: uniqueArrayMerge(currentState[type], follows, (follow) => `${follow.source_feed.
|
|
5451
|
+
: uniqueArrayMerge(currentState[type], follows, (follow) => `${follow.source_feed.feed}-${follow.target_feed.feed}`),
|
|
5274
5452
|
[paginationKey]: {
|
|
5275
5453
|
...currentState[paginationKey],
|
|
5276
5454
|
next: newNextCursor,
|
|
@@ -5363,7 +5541,7 @@ class Feed extends FeedApi {
|
|
|
5363
5541
|
*/
|
|
5364
5542
|
async queryFollowers(request) {
|
|
5365
5543
|
const filter = {
|
|
5366
|
-
target_feed: this.
|
|
5544
|
+
target_feed: this.feed,
|
|
5367
5545
|
};
|
|
5368
5546
|
const response = await this.client.queryFollows({
|
|
5369
5547
|
filter,
|
|
@@ -5378,7 +5556,7 @@ class Feed extends FeedApi {
|
|
|
5378
5556
|
*/
|
|
5379
5557
|
async queryFollowing(request) {
|
|
5380
5558
|
const filter = {
|
|
5381
|
-
source_feed: this.
|
|
5559
|
+
source_feed: this.feed,
|
|
5382
5560
|
};
|
|
5383
5561
|
const response = await this.client.queryFollows({
|
|
5384
5562
|
filter,
|
|
@@ -5387,18 +5565,18 @@ class Feed extends FeedApi {
|
|
|
5387
5565
|
return response;
|
|
5388
5566
|
}
|
|
5389
5567
|
async follow(feedOrFid, options) {
|
|
5390
|
-
const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.
|
|
5568
|
+
const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.feed;
|
|
5391
5569
|
const response = await this.client.follow({
|
|
5392
5570
|
...options,
|
|
5393
|
-
source: this.
|
|
5571
|
+
source: this.feed,
|
|
5394
5572
|
target: fid,
|
|
5395
5573
|
});
|
|
5396
5574
|
return response;
|
|
5397
5575
|
}
|
|
5398
5576
|
async unfollow(feedOrFid) {
|
|
5399
|
-
const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.
|
|
5577
|
+
const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.feed;
|
|
5400
5578
|
const response = await this.client.unfollow({
|
|
5401
|
-
source: this.
|
|
5579
|
+
source: this.feed,
|
|
5402
5580
|
target: fid,
|
|
5403
5581
|
});
|
|
5404
5582
|
return response;
|
|
@@ -5422,7 +5600,7 @@ class Feed extends FeedApi {
|
|
|
5422
5600
|
addActivity(request) {
|
|
5423
5601
|
return this.feedsApi.addActivity({
|
|
5424
5602
|
...request,
|
|
5425
|
-
|
|
5603
|
+
feeds: [this.feed],
|
|
5426
5604
|
});
|
|
5427
5605
|
}
|
|
5428
5606
|
handleWSEvent(event) {
|
|
@@ -5440,6 +5618,24 @@ class Feed extends FeedApi {
|
|
|
5440
5618
|
}
|
|
5441
5619
|
Feed.noop = () => { };
|
|
5442
5620
|
|
|
5621
|
+
function handleUserUpdated(event) {
|
|
5622
|
+
this.state.next((currentState) => {
|
|
5623
|
+
let newState;
|
|
5624
|
+
const { connected_user } = currentState;
|
|
5625
|
+
if (connected_user && connected_user.id === event.user.id) {
|
|
5626
|
+
newState ?? (newState = {
|
|
5627
|
+
...currentState,
|
|
5628
|
+
});
|
|
5629
|
+
newState.connected_user = {
|
|
5630
|
+
...connected_user,
|
|
5631
|
+
...event.user,
|
|
5632
|
+
};
|
|
5633
|
+
}
|
|
5634
|
+
// TODO: update other users in user map (if/once applicable)
|
|
5635
|
+
return newState ?? currentState;
|
|
5636
|
+
});
|
|
5637
|
+
}
|
|
5638
|
+
|
|
5443
5639
|
class FeedsClient extends FeedsApi {
|
|
5444
5640
|
constructor(apiKey, options) {
|
|
5445
5641
|
const tokenManager = new TokenManager();
|
|
@@ -5547,7 +5743,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5547
5743
|
if (this.activeFeeds[fid]) {
|
|
5548
5744
|
const feed = this.activeFeeds[fid];
|
|
5549
5745
|
if (watch && !feed.currentState.watch) {
|
|
5550
|
-
|
|
5746
|
+
handleWatchStarted.bind(feed)();
|
|
5551
5747
|
}
|
|
5552
5748
|
return feed;
|
|
5553
5749
|
}
|
|
@@ -5583,7 +5779,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5583
5779
|
}
|
|
5584
5780
|
else {
|
|
5585
5781
|
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
5586
|
-
|
|
5782
|
+
handleWatchStopped.bind(activeFeed)();
|
|
5587
5783
|
}
|
|
5588
5784
|
}
|
|
5589
5785
|
break;
|
|
@@ -5663,6 +5859,10 @@ class FeedsClient extends FeedsApi {
|
|
|
5663
5859
|
feeds.forEach((f) => f.handleWSEvent(event));
|
|
5664
5860
|
break;
|
|
5665
5861
|
}
|
|
5862
|
+
case 'user.updated': {
|
|
5863
|
+
handleUserUpdated.call(this, event);
|
|
5864
|
+
break;
|
|
5865
|
+
}
|
|
5666
5866
|
default: {
|
|
5667
5867
|
feed?.handleWSEvent(event);
|
|
5668
5868
|
}
|
|
@@ -5688,7 +5888,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5688
5888
|
}
|
|
5689
5889
|
}
|
|
5690
5890
|
async queryFeeds(request) {
|
|
5691
|
-
const response = await this.
|
|
5891
|
+
const response = await this._queryFeeds(request);
|
|
5692
5892
|
const feeds = response.feeds.map((f) => this.getOrCreateActiveFeed(f.group_id, f.id, f, request?.watch));
|
|
5693
5893
|
return {
|
|
5694
5894
|
feeds,
|
|
@@ -5700,7 +5900,10 @@ class FeedsClient extends FeedsApi {
|
|
|
5700
5900
|
}
|
|
5701
5901
|
async updateFollow(request) {
|
|
5702
5902
|
const response = await super.updateFollow(request);
|
|
5703
|
-
[
|
|
5903
|
+
[
|
|
5904
|
+
response.follow.source_feed.feed,
|
|
5905
|
+
response.follow.target_feed.feed,
|
|
5906
|
+
].forEach((fid) => {
|
|
5704
5907
|
const feed = this.activeFeeds[fid];
|
|
5705
5908
|
if (feed) {
|
|
5706
5909
|
handleFollowUpdated.bind(feed)(response);
|
|
@@ -5711,7 +5914,10 @@ class FeedsClient extends FeedsApi {
|
|
|
5711
5914
|
// For follow API endpoints we update the state after HTTP response to allow queryFeeds with watch: false
|
|
5712
5915
|
async follow(request) {
|
|
5713
5916
|
const response = await super.follow(request);
|
|
5714
|
-
[
|
|
5917
|
+
[
|
|
5918
|
+
response.follow.source_feed.feed,
|
|
5919
|
+
response.follow.target_feed.feed,
|
|
5920
|
+
].forEach((fid) => {
|
|
5715
5921
|
const feed = this.activeFeeds[fid];
|
|
5716
5922
|
if (feed) {
|
|
5717
5923
|
handleFollowCreated.bind(feed)(response);
|
|
@@ -5722,7 +5928,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5722
5928
|
async followBatch(request) {
|
|
5723
5929
|
const response = await super.followBatch(request);
|
|
5724
5930
|
response.follows.forEach((follow) => {
|
|
5725
|
-
const feed = this.activeFeeds[follow.source_feed.
|
|
5931
|
+
const feed = this.activeFeeds[follow.source_feed.feed];
|
|
5726
5932
|
if (feed) {
|
|
5727
5933
|
handleFollowCreated.bind(feed)({ follow });
|
|
5728
5934
|
}
|
|
@@ -5747,7 +5953,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5747
5953
|
});
|
|
5748
5954
|
const feed = this.activeFeeds[`${request.feed_group_id}:${request.feed_id}`];
|
|
5749
5955
|
if (feed) {
|
|
5750
|
-
|
|
5956
|
+
handleWatchStopped.bind(feed)();
|
|
5751
5957
|
}
|
|
5752
5958
|
return response;
|
|
5753
5959
|
}
|
|
@@ -6164,5 +6370,5 @@ class FeedSearchSource extends BaseSearchSource {
|
|
|
6164
6370
|
}
|
|
6165
6371
|
}
|
|
6166
6372
|
|
|
6167
|
-
export { ActivitySearchSource, BaseSearchSource, ChannelOwnCapability, Constants, Feed, FeedOwnCapability, FeedSearchSource, FeedsClient, MergedStateStore, SearchController, StateStore, StreamApiError, StreamPoll, UserSearchSource, checkHasAnotherPage, getStateUpdateQueueId, isCommentResponse, isFollowResponse, isImageFile, isPatch, isVideoFile, isVoteAnswer, shouldUpdateState, uniqueArrayMerge };
|
|
6373
|
+
export { ActivitySearchSource, BaseSearchSource, ChannelOwnCapability, Constants, Feed, FeedOwnCapability, FeedSearchSource, FeedsClient, MergedStateStore, SearchController, StateStore, StreamApiError, StreamPoll, UserSearchSource, checkHasAnotherPage, getStateUpdateQueueId, isCommentResponse, isFollowResponse, isImageFile, isPatch, isVideoFile, isVoteAnswer, shouldUpdateState, uniqueArrayMerge, updateEntityInArray };
|
|
6168
6374
|
//# sourceMappingURL=index.node.js.map
|