@plusscommunities/pluss-circles-web-groups 1.5.7-beta.0 → 1.5.7-beta.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/dist/index.cjs.js +164 -51
- package/dist/index.esm.js +164 -51
- package/dist/index.umd.js +164 -51
- package/package.json +1 -1
- package/src/apis/circleActions.js +10 -0
- package/src/screens/Circle.js +9 -0
- package/src/screens/Circles.js +47 -0
package/dist/index.umd.js
CHANGED
|
@@ -44,30 +44,30 @@
|
|
|
44
44
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
45
45
|
|
|
46
46
|
var values = {
|
|
47
|
-
featureKey: '
|
|
48
|
-
entityKey: '
|
|
49
|
-
entityName: '
|
|
50
|
-
serviceKey: '
|
|
51
|
-
permission: '
|
|
52
|
-
menuIcon: '
|
|
47
|
+
featureKey: 'groups',
|
|
48
|
+
entityKey: 'group',
|
|
49
|
+
entityName: 'group',
|
|
50
|
+
serviceKey: 'groups',
|
|
51
|
+
permission: 'groups',
|
|
52
|
+
menuIcon: 'comments',
|
|
53
53
|
isFontAwesome: true,
|
|
54
|
-
reducerKey: '
|
|
55
|
-
actionCircleKey: '
|
|
56
|
-
textFeatureTitle: '
|
|
57
|
-
textAddMenuTitle: '
|
|
58
|
-
textEmptyGroups: "You aren't in any
|
|
54
|
+
reducerKey: 'groups',
|
|
55
|
+
actionCircleKey: 'GROUP',
|
|
56
|
+
textFeatureTitle: 'Groups',
|
|
57
|
+
textAddMenuTitle: 'Group',
|
|
58
|
+
textEmptyGroups: "You aren't in any Groups",
|
|
59
59
|
textEmptyPeople: 'Contacts will show here',
|
|
60
|
-
componentCircles: '
|
|
61
|
-
componentAddCircle: '
|
|
62
|
-
componentCircle: '
|
|
63
|
-
inviteKey: '
|
|
64
|
-
messageKey: '
|
|
65
|
-
chatRoute: '
|
|
66
|
-
updateKeyUserCircles: '
|
|
67
|
-
allowPublicKey: '
|
|
68
|
-
allowPublicKeyDefault:
|
|
60
|
+
componentCircles: 'Groups',
|
|
61
|
+
componentAddCircle: 'AddGroup',
|
|
62
|
+
componentCircle: 'Group',
|
|
63
|
+
inviteKey: 'groupInvite',
|
|
64
|
+
messageKey: 'groupMessage',
|
|
65
|
+
chatRoute: 'groupChat',
|
|
66
|
+
updateKeyUserCircles: 'userGroups',
|
|
67
|
+
allowPublicKey: 'groupAllowPublicGroups',
|
|
68
|
+
allowPublicKeyDefault: true,
|
|
69
69
|
settings: {
|
|
70
|
-
allowAnyCreate:
|
|
70
|
+
allowAnyCreate: true
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
|
|
@@ -356,6 +356,35 @@
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
return deleteMessage;
|
|
359
|
+
}(),
|
|
360
|
+
markAsRead: function () {
|
|
361
|
+
var _markAsRead = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(circleId, userId) {
|
|
362
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
363
|
+
while (1) {
|
|
364
|
+
switch (_context4.prev = _context4.next) {
|
|
365
|
+
case 0:
|
|
366
|
+
return _context4.abrupt("return", Session$4.authedFunction({
|
|
367
|
+
method: 'post',
|
|
368
|
+
url: Helper$3.getUrl('notifications', 'resetunread'),
|
|
369
|
+
data: {
|
|
370
|
+
groupID: circleId,
|
|
371
|
+
userID: userId
|
|
372
|
+
}
|
|
373
|
+
}));
|
|
374
|
+
|
|
375
|
+
case 1:
|
|
376
|
+
case "end":
|
|
377
|
+
return _context4.stop();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}, _callee4);
|
|
381
|
+
}));
|
|
382
|
+
|
|
383
|
+
function markAsRead(_x9, _x10) {
|
|
384
|
+
return _markAsRead.apply(this, arguments);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return markAsRead;
|
|
359
388
|
}()
|
|
360
389
|
};
|
|
361
390
|
|
|
@@ -427,6 +456,12 @@
|
|
|
427
456
|
})));
|
|
428
457
|
});
|
|
429
458
|
|
|
459
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "selectUnreadFilter", function (showUnreadOnly) {
|
|
460
|
+
_this.setState({
|
|
461
|
+
showUnreadOnly: showUnreadOnly
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
|
|
430
465
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "canAddNew", function () {
|
|
431
466
|
var auth = _this.props.auth;
|
|
432
467
|
return Session$3.validateAccess(auth.site, values.permission, auth);
|
|
@@ -539,7 +574,9 @@
|
|
|
539
574
|
|
|
540
575
|
_this.state = {
|
|
541
576
|
userSearch: "",
|
|
542
|
-
sortBy: "newest"
|
|
577
|
+
sortBy: "newest",
|
|
578
|
+
showUnreadOnly: false,
|
|
579
|
+
pollingInterval: null
|
|
543
580
|
};
|
|
544
581
|
return _this;
|
|
545
582
|
}
|
|
@@ -547,25 +584,60 @@
|
|
|
547
584
|
_createClass__default['default'](Circles, [{
|
|
548
585
|
key: "componentDidMount",
|
|
549
586
|
value: function componentDidMount() {
|
|
550
|
-
this
|
|
587
|
+
var _this2 = this;
|
|
588
|
+
|
|
589
|
+
this.getData(); // Poll for updates every 10 seconds
|
|
590
|
+
|
|
591
|
+
this.pollingInterval = setInterval(function () {
|
|
592
|
+
_this2.getData();
|
|
593
|
+
}, 10000);
|
|
594
|
+
}
|
|
595
|
+
}, {
|
|
596
|
+
key: "componentWillUnmount",
|
|
597
|
+
value: function componentWillUnmount() {
|
|
598
|
+
if (this.pollingInterval) {
|
|
599
|
+
clearInterval(this.pollingInterval);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}, {
|
|
603
|
+
key: "isCircleUnread",
|
|
604
|
+
value: function isCircleUnread(circle) {
|
|
605
|
+
var userId = this.props.user.Id;
|
|
606
|
+
|
|
607
|
+
if (!circle.Unread || !circle.Unread[userId]) {
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
return circle.Unread[userId] > 0;
|
|
612
|
+
}
|
|
613
|
+
}, {
|
|
614
|
+
key: "getUnreadCount",
|
|
615
|
+
value: function getUnreadCount(circle) {
|
|
616
|
+
var userId = this.props.user.Id;
|
|
617
|
+
|
|
618
|
+
if (!circle.Unread || !circle.Unread[userId]) {
|
|
619
|
+
return 0;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
return circle.Unread[userId];
|
|
551
623
|
}
|
|
552
624
|
}, {
|
|
553
625
|
key: "getCircles",
|
|
554
626
|
value: function getCircles() {
|
|
555
|
-
var
|
|
627
|
+
var _this3 = this;
|
|
556
628
|
|
|
557
629
|
var result = this.props.circles;
|
|
558
630
|
|
|
559
631
|
if (this.state.selectedTypeFilter) {
|
|
560
632
|
result = ___default['default'].filter(result, function (circle) {
|
|
561
|
-
return
|
|
633
|
+
return _this3.state.selectedTypeFilter === "circle" ? !circle.IsPrivate : circle.IsPrivate;
|
|
562
634
|
});
|
|
563
635
|
}
|
|
564
636
|
|
|
565
637
|
if (this.state.selectedUserFilter) {
|
|
566
638
|
result = ___default['default'].filter(result, function (circle) {
|
|
567
639
|
return ___default['default'].some(circle.Audience, function (user) {
|
|
568
|
-
return user.userId ===
|
|
640
|
+
return user.userId === _this3.state.selectedUserFilter.userId;
|
|
569
641
|
});
|
|
570
642
|
});
|
|
571
643
|
} // Apply sorting
|
|
@@ -577,6 +649,12 @@
|
|
|
577
649
|
|
|
578
650
|
if (this.state.sortBy === "newest") {
|
|
579
651
|
result.reverse();
|
|
652
|
+
|
|
653
|
+
if (this.state.showUnreadOnly) {
|
|
654
|
+
result = ___default['default'].filter(result, function (circle) {
|
|
655
|
+
return _this3.isCircleUnread(circle);
|
|
656
|
+
});
|
|
657
|
+
}
|
|
580
658
|
}
|
|
581
659
|
|
|
582
660
|
return result;
|
|
@@ -584,7 +662,7 @@
|
|
|
584
662
|
}, {
|
|
585
663
|
key: "getUsers",
|
|
586
664
|
value: function getUsers() {
|
|
587
|
-
var
|
|
665
|
+
var _this4 = this;
|
|
588
666
|
|
|
589
667
|
var users = [];
|
|
590
668
|
this.props.circles.forEach(function (circle) {
|
|
@@ -596,8 +674,8 @@
|
|
|
596
674
|
return user.userId;
|
|
597
675
|
}), "displayName");
|
|
598
676
|
return ___default['default'].filter(users, function (u) {
|
|
599
|
-
if (!___default['default'].isEmpty(
|
|
600
|
-
return (u.displayName || "").toLowerCase().indexOf(
|
|
677
|
+
if (!___default['default'].isEmpty(_this4.state.userSearch)) {
|
|
678
|
+
return (u.displayName || "").toLowerCase().indexOf(_this4.state.userSearch.toLowerCase()) > -1;
|
|
601
679
|
}
|
|
602
680
|
|
|
603
681
|
return true;
|
|
@@ -606,7 +684,7 @@
|
|
|
606
684
|
}, {
|
|
607
685
|
key: "validateCircleAdmin",
|
|
608
686
|
value: function validateCircleAdmin(circle, onlyCreator) {
|
|
609
|
-
var
|
|
687
|
+
var _this5 = this;
|
|
610
688
|
|
|
611
689
|
if (Session$3.validateAccess(this.props.auth.site, values.permission, this.props.auth)) {
|
|
612
690
|
return true;
|
|
@@ -617,13 +695,13 @@
|
|
|
617
695
|
}
|
|
618
696
|
|
|
619
697
|
return ___default['default'].some(circle.Audience, function (user) {
|
|
620
|
-
return user.userId ===
|
|
698
|
+
return user.userId === _this5.props.user.Id && user.isAdmin;
|
|
621
699
|
});
|
|
622
700
|
}
|
|
623
701
|
}, {
|
|
624
702
|
key: "renderRow",
|
|
625
703
|
value: function renderRow(circle) {
|
|
626
|
-
var
|
|
704
|
+
var _this6 = this;
|
|
627
705
|
|
|
628
706
|
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
629
707
|
key: circle.Id
|
|
@@ -657,7 +735,7 @@
|
|
|
657
735
|
name: "pencil"
|
|
658
736
|
})), this.validateCircleAdmin(circle, true) && !circle.IsPrivate && /*#__PURE__*/React__default['default'].createElement("a", {
|
|
659
737
|
onClick: function onClick() {
|
|
660
|
-
|
|
738
|
+
_this6.removeCircle(circle);
|
|
661
739
|
}
|
|
662
740
|
}, /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
663
741
|
style: {
|
|
@@ -672,13 +750,21 @@
|
|
|
672
750
|
}, {
|
|
673
751
|
key: "renderFilters",
|
|
674
752
|
value: function renderFilters() {
|
|
675
|
-
var
|
|
753
|
+
var _this7 = this;
|
|
676
754
|
|
|
677
755
|
var userFilter = /*#__PURE__*/React__default['default'].createElement(Components$4.Tag, {
|
|
678
756
|
className: "marginRight-10",
|
|
679
757
|
onClick: this.openUserFilter,
|
|
680
758
|
text: "User"
|
|
681
759
|
});
|
|
760
|
+
var unreadFilter = /*#__PURE__*/React__default['default'].createElement(Components$4.Tag, {
|
|
761
|
+
className: "marginRight-10",
|
|
762
|
+
onClick: function onClick() {
|
|
763
|
+
return _this7.selectUnreadFilter(!_this7.state.showUnreadOnly);
|
|
764
|
+
},
|
|
765
|
+
leftIcon: this.state.showUnreadOnly ? "check" : null,
|
|
766
|
+
text: "Unread Only"
|
|
767
|
+
});
|
|
682
768
|
var typeFilter = /*#__PURE__*/React__default['default'].createElement(Components$4.Tag, {
|
|
683
769
|
className: "marginRight-10",
|
|
684
770
|
onClick: this.openTypeFilter,
|
|
@@ -713,19 +799,19 @@
|
|
|
713
799
|
}, /*#__PURE__*/React__default['default'].createElement(Components$4.Text, {
|
|
714
800
|
type: "h5",
|
|
715
801
|
className: "marginRight-20"
|
|
716
|
-
}, "Filter by"), userFilter, typeFilter, /*#__PURE__*/React__default['default'].createElement(Components$4.Text, {
|
|
802
|
+
}, "Filter by"), userFilter, unreadFilter, typeFilter, /*#__PURE__*/React__default['default'].createElement(Components$4.Text, {
|
|
717
803
|
type: "h5",
|
|
718
804
|
className: "marginRight-20 marginLeft-20"
|
|
719
805
|
}, "Sort by:"), /*#__PURE__*/React__default['default'].createElement(Components$4.Tag, {
|
|
720
806
|
className: "marginRight-10",
|
|
721
807
|
onClick: function onClick() {
|
|
722
|
-
return
|
|
808
|
+
return _this7.selectSort("newest");
|
|
723
809
|
},
|
|
724
810
|
leftIcon: this.state.sortBy === "newest" ? "check" : null,
|
|
725
811
|
text: "Newest first"
|
|
726
812
|
}), /*#__PURE__*/React__default['default'].createElement(Components$4.Tag, {
|
|
727
813
|
onClick: function onClick() {
|
|
728
|
-
return
|
|
814
|
+
return _this7.selectSort("oldest");
|
|
729
815
|
},
|
|
730
816
|
leftIcon: this.state.sortBy === "oldest" ? "check" : null,
|
|
731
817
|
text: "Oldest first"
|
|
@@ -734,7 +820,7 @@
|
|
|
734
820
|
}, {
|
|
735
821
|
key: "renderUserFilterPopup",
|
|
736
822
|
value: function renderUserFilterPopup() {
|
|
737
|
-
var
|
|
823
|
+
var _this8 = this;
|
|
738
824
|
|
|
739
825
|
if (!this.state.userFilterOpen) {
|
|
740
826
|
return null;
|
|
@@ -754,7 +840,7 @@
|
|
|
754
840
|
placeholder: "Enter name",
|
|
755
841
|
value: this.state.userSearch,
|
|
756
842
|
onChange: function onChange(e) {
|
|
757
|
-
return
|
|
843
|
+
return _this8.onHandleChange(e);
|
|
758
844
|
},
|
|
759
845
|
alwaysShowLabel: true
|
|
760
846
|
}), this.getUsers().map(function (user) {
|
|
@@ -762,7 +848,7 @@
|
|
|
762
848
|
key: user.userId,
|
|
763
849
|
user: user,
|
|
764
850
|
onClick: function onClick() {
|
|
765
|
-
|
|
851
|
+
_this8.selectUserFilter(user);
|
|
766
852
|
}
|
|
767
853
|
});
|
|
768
854
|
}));
|
|
@@ -770,7 +856,7 @@
|
|
|
770
856
|
}, {
|
|
771
857
|
key: "renderTypeFilterPopup",
|
|
772
858
|
value: function renderTypeFilterPopup() {
|
|
773
|
-
var
|
|
859
|
+
var _this9 = this;
|
|
774
860
|
|
|
775
861
|
if (!this.state.typeFilterOpen) {
|
|
776
862
|
return null;
|
|
@@ -784,13 +870,13 @@
|
|
|
784
870
|
onClose: this.closeTypeFilter
|
|
785
871
|
}, /*#__PURE__*/React__default['default'].createElement(Components$4.Tag, {
|
|
786
872
|
onClick: function onClick() {
|
|
787
|
-
|
|
873
|
+
_this9.selectTypeFilter("circle");
|
|
788
874
|
},
|
|
789
875
|
text: ___default['default'].capitalize(values.entityName),
|
|
790
876
|
className: "marginRight-10"
|
|
791
877
|
}), /*#__PURE__*/React__default['default'].createElement(Components$4.Tag, {
|
|
792
878
|
onClick: function onClick() {
|
|
793
|
-
|
|
879
|
+
_this9.selectTypeFilter("private");
|
|
794
880
|
},
|
|
795
881
|
text: "Private Message"
|
|
796
882
|
}));
|
|
@@ -798,7 +884,7 @@
|
|
|
798
884
|
}, {
|
|
799
885
|
key: "render",
|
|
800
886
|
value: function render() {
|
|
801
|
-
var
|
|
887
|
+
var _this10 = this;
|
|
802
888
|
|
|
803
889
|
return /*#__PURE__*/React__default['default'].createElement("div", null, this.renderTypeFilterPopup(), this.renderUserFilterPopup(), /*#__PURE__*/React__default['default'].createElement(Components$4.Header, null, this.canAddNew() && /*#__PURE__*/React__default['default'].createElement(Components$4.AddButton, {
|
|
804
890
|
onClick: this.onAddNew,
|
|
@@ -822,7 +908,7 @@
|
|
|
822
908
|
width: 50
|
|
823
909
|
}
|
|
824
910
|
}))), /*#__PURE__*/React__default['default'].createElement("tbody", null, this.getCircles().map(function (circle) {
|
|
825
|
-
return
|
|
911
|
+
return _this10.renderRow(circle);
|
|
826
912
|
})))));
|
|
827
913
|
}
|
|
828
914
|
}]);
|
|
@@ -1786,6 +1872,32 @@
|
|
|
1786
1872
|
});
|
|
1787
1873
|
});
|
|
1788
1874
|
|
|
1875
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "markCircleAsRead", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
1876
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
1877
|
+
while (1) {
|
|
1878
|
+
switch (_context5.prev = _context5.next) {
|
|
1879
|
+
case 0:
|
|
1880
|
+
_context5.prev = 0;
|
|
1881
|
+
_context5.next = 3;
|
|
1882
|
+
return circleActions.markAsRead(_this.state.circleId, _this.props.user.Id);
|
|
1883
|
+
|
|
1884
|
+
case 3:
|
|
1885
|
+
_context5.next = 8;
|
|
1886
|
+
break;
|
|
1887
|
+
|
|
1888
|
+
case 5:
|
|
1889
|
+
_context5.prev = 5;
|
|
1890
|
+
_context5.t0 = _context5["catch"](0);
|
|
1891
|
+
console.error("Failed to mark circle as read:", _context5.t0);
|
|
1892
|
+
|
|
1893
|
+
case 8:
|
|
1894
|
+
case "end":
|
|
1895
|
+
return _context5.stop();
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
}, _callee5, null, [[0, 5]]);
|
|
1899
|
+
})));
|
|
1900
|
+
|
|
1789
1901
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "sendMessage", function () {
|
|
1790
1902
|
var message = {
|
|
1791
1903
|
_id: Helper.randomString(),
|
|
@@ -1870,6 +1982,7 @@
|
|
|
1870
1982
|
_createClass__default['default'](Circle, [{
|
|
1871
1983
|
key: "componentDidMount",
|
|
1872
1984
|
value: function componentDidMount() {
|
|
1985
|
+
this.markCircleAsRead();
|
|
1873
1986
|
this.checkGetData();
|
|
1874
1987
|
this.connect();
|
|
1875
1988
|
this.props.setNavData({
|
|
@@ -2006,8 +2119,8 @@
|
|
|
2006
2119
|
display: this.state.imageInputShowing ? "block" : "none"
|
|
2007
2120
|
}
|
|
2008
2121
|
}, /*#__PURE__*/React__default['default'].createElement(Components$2.ImageInput, {
|
|
2009
|
-
ref: function ref(
|
|
2010
|
-
_this5.imageInput =
|
|
2122
|
+
ref: function ref(_ref6) {
|
|
2123
|
+
_this5.imageInput = _ref6;
|
|
2011
2124
|
},
|
|
2012
2125
|
multiple: true,
|
|
2013
2126
|
limit: 10,
|
|
@@ -2021,8 +2134,8 @@
|
|
|
2021
2134
|
display: this.state.fileInputShowing ? "block" : "none"
|
|
2022
2135
|
}
|
|
2023
2136
|
}, /*#__PURE__*/React__default['default'].createElement(Components$2.FileInput, {
|
|
2024
|
-
ref: function ref(
|
|
2025
|
-
_this5.fileInput =
|
|
2137
|
+
ref: function ref(_ref7) {
|
|
2138
|
+
_this5.fileInput = _ref7;
|
|
2026
2139
|
},
|
|
2027
2140
|
multiple: true,
|
|
2028
2141
|
limit: 10,
|
|
@@ -2316,8 +2429,8 @@
|
|
|
2316
2429
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2317
2430
|
className: "chat_newMessage"
|
|
2318
2431
|
}, this.renderChatInput()), this.renderReplyTo(), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2319
|
-
ref: function ref(
|
|
2320
|
-
return _this8.chat =
|
|
2432
|
+
ref: function ref(_ref8) {
|
|
2433
|
+
return _this8.chat = _ref8;
|
|
2321
2434
|
},
|
|
2322
2435
|
className: "chat_messages"
|
|
2323
2436
|
}, ___default['default'].isEmpty(this.state.messages) && !___default['default'].isEmpty(this.state.messageDate) && this.renderEmptyDate(), this.state.messages.map(function (m) {
|
package/package.json
CHANGED
|
@@ -113,4 +113,14 @@ export const circleActions = {
|
|
|
113
113
|
},
|
|
114
114
|
});
|
|
115
115
|
},
|
|
116
|
+
markAsRead: async (circleId, userId) => {
|
|
117
|
+
return Session.authedFunction({
|
|
118
|
+
method: 'post',
|
|
119
|
+
url: Helper.getUrl('notifications', 'resetunread'),
|
|
120
|
+
data: {
|
|
121
|
+
groupID: circleId,
|
|
122
|
+
userID: userId,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
},
|
|
116
126
|
};
|
package/src/screens/Circle.js
CHANGED
|
@@ -37,6 +37,7 @@ class Circle extends Component {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
componentDidMount() {
|
|
40
|
+
this.markCircleAsRead();
|
|
40
41
|
this.checkGetData();
|
|
41
42
|
this.connect();
|
|
42
43
|
this.props.setNavData({ hideSideMenu: true });
|
|
@@ -332,6 +333,14 @@ class Circle extends Component {
|
|
|
332
333
|
});
|
|
333
334
|
};
|
|
334
335
|
|
|
336
|
+
|
|
337
|
+
markCircleAsRead = async () => {
|
|
338
|
+
try {
|
|
339
|
+
await circleActions.markAsRead(this.state.circleId, this.props.user.Id);
|
|
340
|
+
} catch (error) {
|
|
341
|
+
console.error("Failed to mark circle as read:", error);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
335
344
|
sendMessage = () => {
|
|
336
345
|
const message = {
|
|
337
346
|
_id: Helper.randomString(),
|
package/src/screens/Circles.js
CHANGED
|
@@ -18,11 +18,17 @@ class Circles extends Component {
|
|
|
18
18
|
this.state = {
|
|
19
19
|
userSearch: "",
|
|
20
20
|
sortBy: "newest",
|
|
21
|
+
showUnreadOnly: false,
|
|
22
|
+
pollingInterval: null,
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
componentDidMount() {
|
|
25
27
|
this.getData();
|
|
28
|
+
// Poll for updates every 10 seconds
|
|
29
|
+
this.pollingInterval = setInterval(() => {
|
|
30
|
+
this.getData();
|
|
31
|
+
}, 10000);
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
getData = () => {
|
|
@@ -40,6 +46,31 @@ class Circles extends Component {
|
|
|
40
46
|
});
|
|
41
47
|
};
|
|
42
48
|
|
|
49
|
+
componentWillUnmount() {
|
|
50
|
+
if (this.pollingInterval) {
|
|
51
|
+
clearInterval(this.pollingInterval);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
isCircleUnread(circle) {
|
|
56
|
+
const userId = this.props.user.Id;
|
|
57
|
+
if (!circle.Unread || !circle.Unread[userId]) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return circle.Unread[userId] > 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getUnreadCount(circle) {
|
|
64
|
+
const userId = this.props.user.Id;
|
|
65
|
+
if (!circle.Unread || !circle.Unread[userId]) {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
return circle.Unread[userId];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
selectUnreadFilter = (showUnreadOnly) => {
|
|
72
|
+
this.setState({ showUnreadOnly });
|
|
73
|
+
};
|
|
43
74
|
getCircles() {
|
|
44
75
|
let result = this.props.circles;
|
|
45
76
|
if (this.state.selectedTypeFilter) {
|
|
@@ -62,6 +93,11 @@ class Circles extends Component {
|
|
|
62
93
|
});
|
|
63
94
|
if (this.state.sortBy === "newest") {
|
|
64
95
|
result.reverse();
|
|
96
|
+
if (this.state.showUnreadOnly) {
|
|
97
|
+
result = _.filter(result, (circle) => {
|
|
98
|
+
return this.isCircleUnread(circle);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
65
101
|
}
|
|
66
102
|
return result;
|
|
67
103
|
}
|
|
@@ -289,6 +325,16 @@ class Circles extends Component {
|
|
|
289
325
|
text="User"
|
|
290
326
|
/>
|
|
291
327
|
);
|
|
328
|
+
|
|
329
|
+
let unreadFilter = (
|
|
330
|
+
<Components.Tag
|
|
331
|
+
className="marginRight-10"
|
|
332
|
+
onClick={() => this.selectUnreadFilter(!this.state.showUnreadOnly)}
|
|
333
|
+
leftIcon={this.state.showUnreadOnly ? "check" : null}
|
|
334
|
+
text="Unread Only"
|
|
335
|
+
/>
|
|
336
|
+
);
|
|
337
|
+
|
|
292
338
|
let typeFilter = (
|
|
293
339
|
<Components.Tag
|
|
294
340
|
className="marginRight-10"
|
|
@@ -330,6 +376,7 @@ class Circles extends Component {
|
|
|
330
376
|
Filter by
|
|
331
377
|
</Components.Text>
|
|
332
378
|
{userFilter}
|
|
379
|
+
{unreadFilter}
|
|
333
380
|
{typeFilter}
|
|
334
381
|
<Components.Text type="h5" className="marginRight-20 marginLeft-20">
|
|
335
382
|
Sort by:
|