@liveblocks/react
Advanced tools
Comparing version 0.7.1 to 0.7.3
@@ -136,2 +136,3 @@ import { Client, RecordData, Others, Presence, Record, InitialStorageFactory, Room } from "@liveblocks/client"; | ||
deleteItem: Room["deleteItem"]; | ||
deleteItemById: Room["deleteItemById"]; | ||
pushItem: Room["pushItem"]; | ||
@@ -138,0 +139,0 @@ }; |
@@ -277,3 +277,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
if (targetIndex < 0) { | ||
throw new Error("targetIndex cannont be less than 0"); | ||
throw new Error("targetIndex cannot be less than 0"); | ||
} | ||
@@ -284,3 +284,3 @@ if (targetIndex >= items.length) { | ||
if (index < 0) { | ||
throw new Error("index cannont be less than 0"); | ||
throw new Error("index cannot be less than 0"); | ||
} | ||
@@ -325,3 +325,3 @@ if (index >= items.length) { | ||
const items = sortedListItems(getListItems(this._cache, id)); | ||
const [position, item] = items[index]; | ||
const [, item] = items[index]; | ||
return this.dispatch({ | ||
@@ -333,2 +333,27 @@ type: OpType.ListRemove, | ||
} | ||
deleteItemById(id, itemId) { | ||
const list = this.getChild(id); | ||
if (list == null) { | ||
throw new Error(`List with id "${id}" does not exist`); | ||
} | ||
if (list.$$type !== LIST) { | ||
throw new Error(`Node with id "${id}" is not a list`); | ||
} | ||
const itemsMap = getListItems(this._cache, id); | ||
let item = null; | ||
for (const [, crdt] of itemsMap) { | ||
if (crdt.id === itemId) { | ||
item = crdt; | ||
break; | ||
} | ||
} | ||
if (item == null) { | ||
throw new Error(`List with id "${id}" does not have an item with id "${itemId}"`); | ||
} | ||
return this.dispatch({ | ||
type: OpType.ListRemove, | ||
id: list.id, | ||
itemId: item.id, | ||
}, true); | ||
} | ||
} | ||
@@ -814,8 +839,12 @@ function getAllLinks(id, rootId, links) { | ||
} | ||
updateUsers(); | ||
updateUsers({ | ||
type: "update", | ||
updates: message.data, | ||
user: state.users[message.actor], | ||
}); | ||
} | ||
function updateUsers() { | ||
function updateUsers(event) { | ||
state.others = makeOthers(state.users); | ||
for (const listener of state.listeners["others"]) { | ||
listener(state.others); | ||
listener(state.others, event); | ||
} | ||
@@ -825,4 +854,7 @@ } | ||
const userLeftMessage = message; | ||
delete state.users[userLeftMessage.actor]; | ||
updateUsers(); | ||
const user = state.users[userLeftMessage.actor]; | ||
if (user) { | ||
delete state.users[userLeftMessage.actor]; | ||
updateUsers({ type: "leave", user }); | ||
} | ||
} | ||
@@ -841,3 +873,3 @@ function onRoomStateMessage(message) { | ||
state.users = newUsers; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
} | ||
@@ -860,3 +892,3 @@ function onNavigatorOnline() { | ||
}; | ||
updateUsers(); | ||
updateUsers({ type: "enter", user: state.users[message.actor] }); | ||
if (state.me) { | ||
@@ -928,3 +960,3 @@ // Send current presence to new user | ||
state.users = {}; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
if (event.code >= 4000 && event.code <= 4100) { | ||
@@ -1059,3 +1091,3 @@ updateConnection({ state: "failed" }); | ||
state.users = {}; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
clearListeners(); | ||
@@ -1158,2 +1190,5 @@ } | ||
} | ||
function deleteItemById(list, itemId) { | ||
updateDoc(state.doc.deleteItemById(list.id, itemId)); | ||
} | ||
function moveItem(list, index, targetIndex) { | ||
@@ -1187,2 +1222,3 @@ updateDoc(state.doc.moveItem(list.id, index, targetIndex)); | ||
deleteItem, | ||
deleteItemById, | ||
moveItem, | ||
@@ -1265,2 +1301,3 @@ selectors: { | ||
deleteItem: machine.deleteItem, | ||
deleteItemById: machine.deleteItemById, | ||
moveItem: machine.moveItem, | ||
@@ -1579,2 +1616,5 @@ ////////////// | ||
} | ||
function deleteItemById(list, itemId) { | ||
return room.deleteItemById(list, itemId); | ||
} | ||
function pushItem(list, item) { | ||
@@ -1589,2 +1629,3 @@ return room.pushItem(list, item); | ||
deleteItem: deleteItem, | ||
deleteItemById: deleteItemById, | ||
pushItem: pushItem, | ||
@@ -1591,0 +1632,0 @@ }; |
{ | ||
"name": "@liveblocks/react", | ||
"version": "0.7.1", | ||
"version": "0.7.3", | ||
"description": "", | ||
@@ -14,5 +14,5 @@ "main": "./lib/index.js", | ||
}, | ||
"license": "MIT", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/client": "0.7.1" | ||
"@liveblocks/client": "0.7.3" | ||
}, | ||
@@ -19,0 +19,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
175999
1764
+ Added@liveblocks/client@0.7.3(transitive)
- Removed@liveblocks/client@0.7.1(transitive)
Updated@liveblocks/client@0.7.3