New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@knocklabs/client

Package Overview
Dependencies
Maintainers
2
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@knocklabs/client - npm Package Compare versions

Comparing version 0.4.5-rc.1 to 0.4.5-rc.2

72

dist/cjs/clients/feed/feed.js

@@ -210,2 +210,9 @@ "use strict";

}()
/*
Marking one or more items as archived should:
- Decrement the badge count for any unread / unseen items
- Remove the item from the feed list, when the include_archived flag is not true)
TODO: how do we handle rollbacks?
*/
}, {

@@ -215,3 +222,4 @@ key: "markAsArchived",

var _markAsArchived = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(itemOrItems) {
var now;
var _this$store, getState, setState, state, shouldRemoveItems, normalizedItems, itemIds, unseenCount, unreadCount, meta, entries;
return _regenerator["default"].wrap(function _callee5$(_context5) {

@@ -221,9 +229,47 @@ while (1) {

case 0:
now = new Date().toISOString();
this.optimisticallyPerformStatusUpdate(itemOrItems, "archived", {
archived_at: now
});
_this$store = this.store, getState = _this$store.getState, setState = _this$store.setState;
state = getState();
shouldRemoveItems = this.defaultOptions.include_archived !== true;
normalizedItems = Array.isArray(itemOrItems) ? itemOrItems : [itemOrItems];
itemIds = normalizedItems.map(function (item) {
return item.id;
}); // If any of the items are unseen or unread, then capture as we'll want to decrement
// the counts for these in the metadata we have
unseenCount = normalizedItems.filter(function (i) {
return !i.seen_at;
}).length;
unreadCount = normalizedItems.filter(function (i) {
return !i.read_at;
}).length; // Build the new metadata
meta = _objectSpread(_objectSpread({}, state.metadata), {}, {
unseen_count: state.metadata.unseen_count - unseenCount,
unread_count: state.metadata.unread_count - unreadCount
}); // Perform optimistic updates on the items in the feed
if (shouldRemoveItems) {
// Filter the items out of the list
entries = state.items.filter(function (item) {
return !itemIds.includes(item.id);
});
setState(function (state) {
return state.setResult({
entries: entries,
meta: meta,
page_info: state.pageInfo
});
});
} else {
setState(function (state) {
state.setMetadata(meta);
state.setItemAttrs(itemIds, {
archived_at: new Date().toISOString()
});
});
}
return _context5.abrupt("return", this.makeStatusUpdate(itemOrItems, "archived"));
case 3:
case 10:
case "end":

@@ -276,3 +322,3 @@ return _context5.stop();

var options,
_this$store,
_this$store2,
setState,

@@ -294,3 +340,3 @@ getState,

options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
_this$store = this.store, setState = _this$store.setState, getState = _this$store.getState;
_this$store2 = this.store, setState = _this$store2.setState, getState = _this$store2.getState;
_getState = getState(), networkStatus = _getState.networkStatus; // If there's an existing request in flight, then do nothing

@@ -437,3 +483,3 @@

var _onNewMessageReceived = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(_ref) {
var metadata, _this$store2, getState, setState, currentHead;
var metadata, _this$store3, getState, setState, currentHead;

@@ -446,3 +492,3 @@ return _regenerator["default"].wrap(function _callee9$(_context9) {

// Handle the new message coming in
_this$store2 = this.store, getState = _this$store2.getState, setState = _this$store2.setState;
_this$store3 = this.store, getState = _this$store3.getState, setState = _this$store3.setState;
currentHead = getState().items[0]; // Optimistically set the badge counts

@@ -480,5 +526,5 @@

value: function optimisticallyPerformStatusUpdate(itemOrItems, type, attrs, badgeCountAttr) {
var _this$store3 = this.store,
getState = _this$store3.getState,
setState = _this$store3.setState;
var _this$store4 = this.store,
getState = _this$store4.getState,
setState = _this$store4.setState;
var itemIds = Array.isArray(itemOrItems) ? itemOrItems.map(function (item) {

@@ -485,0 +531,0 @@ return item.id;

@@ -130,3 +130,10 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";

}
/*
Marking one or more items as archived should:
- Decrement the badge count for any unread / unseen items
- Remove the item from the feed list, when the include_archived flag is not true)
TODO: how do we handle rollbacks?
*/
markAsArchived(itemOrItems) {

@@ -136,8 +143,38 @@ var _this5 = this;

return _asyncToGenerator(function* () {
var now = new Date().toISOString();
var {
getState,
setState
} = _this5.store;
var state = getState();
var shouldRemoveItems = _this5.defaultOptions.include_archived !== true;
var normalizedItems = Array.isArray(itemOrItems) ? itemOrItems : [itemOrItems];
var itemIds = normalizedItems.map(item => item.id); // If any of the items are unseen or unread, then capture as we'll want to decrement
// the counts for these in the metadata we have
_this5.optimisticallyPerformStatusUpdate(itemOrItems, "archived", {
archived_at: now
});
var unseenCount = normalizedItems.filter(i => !i.seen_at).length;
var unreadCount = normalizedItems.filter(i => !i.read_at).length; // Build the new metadata
var meta = _objectSpread(_objectSpread({}, state.metadata), {}, {
unseen_count: state.metadata.unseen_count - unseenCount,
unread_count: state.metadata.unread_count - unreadCount
}); // Perform optimistic updates on the items in the feed
if (shouldRemoveItems) {
// Filter the items out of the list
var entries = state.items.filter(item => !itemIds.includes(item.id));
setState(state => state.setResult({
entries,
meta,
page_info: state.pageInfo
}));
} else {
setState(state => {
state.setMetadata(meta);
state.setItemAttrs(itemIds, {
archived_at: new Date().toISOString()
});
});
}
return _this5.makeStatusUpdate(itemOrItems, "archived");

@@ -144,0 +181,0 @@ })();

2

package.json
{
"name": "@knocklabs/client",
"version": "0.4.5-rc.1",
"version": "0.4.5-rc.2",
"description": "The clientside library for interacting with Knock",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/knocklabs/knock-client-js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc