@overmap-ai/core 1.0.48-activity-history.2 → 1.0.48-activity-history.4
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/README.md +0 -0
- package/dist/overmap-core.js +91 -38
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +91 -38
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/IssueCommentService.d.ts +2 -2
- package/dist/store/slices/issueSlice.d.ts +6 -2
- package/dist/typings/models/issues.d.ts +2 -1
- package/package.json +1 -1
|
@@ -2135,20 +2135,55 @@ var __publicField = (obj, key, value) => {
|
|
|
2135
2135
|
setVisibleUserIds: (state, action) => {
|
|
2136
2136
|
state.visibleUserIds = [...new Set(action.payload)];
|
|
2137
2137
|
},
|
|
2138
|
-
|
|
2138
|
+
// Comments
|
|
2139
|
+
addIssueComment: (state, action) => {
|
|
2140
|
+
if (action.payload.offline_id in state.comments) {
|
|
2141
|
+
throw new Error(
|
|
2142
|
+
`Tried to add issue comment with offline_id: ${action.payload.offline_id} that already exists`
|
|
2143
|
+
);
|
|
2144
|
+
}
|
|
2145
|
+
state.comments[action.payload.offline_id] = action.payload;
|
|
2146
|
+
},
|
|
2147
|
+
addIssueComments: (state, action) => {
|
|
2148
|
+
for (const comment of action.payload) {
|
|
2149
|
+
if (comment.offline_id in state.comments) {
|
|
2150
|
+
throw new Error(
|
|
2151
|
+
`Tried to add issue comment with offline_id: ${comment.offline_id} that already exists`
|
|
2152
|
+
);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2139
2155
|
for (const comment of action.payload) {
|
|
2140
2156
|
state.comments[comment.offline_id] = comment;
|
|
2141
2157
|
}
|
|
2142
2158
|
},
|
|
2159
|
+
setIssueComment: (state, action) => {
|
|
2160
|
+
state.comments[action.payload.offline_id] = action.payload;
|
|
2161
|
+
},
|
|
2162
|
+
setIssueComments: (state, action) => {
|
|
2163
|
+
const newComments = {};
|
|
2164
|
+
for (const comment of action.payload) {
|
|
2165
|
+
newComments[comment.offline_id] = comment;
|
|
2166
|
+
}
|
|
2167
|
+
state.comments = newComments;
|
|
2168
|
+
},
|
|
2143
2169
|
addOrReplaceIssueComment: (state, action) => {
|
|
2144
2170
|
state.comments[action.payload.offline_id] = action.payload;
|
|
2145
2171
|
},
|
|
2146
2172
|
removeIssueComment: (state, action) => {
|
|
2147
|
-
if (action.payload in state.comments) {
|
|
2148
|
-
delete state.comments[action.payload];
|
|
2149
|
-
} else {
|
|
2173
|
+
if (!(action.payload in state.comments)) {
|
|
2150
2174
|
throw new Error(`Failed to remove issue comment because ID doesn't exist: ${action.payload}`);
|
|
2151
2175
|
}
|
|
2176
|
+
delete state.comments[action.payload];
|
|
2177
|
+
},
|
|
2178
|
+
removeIssueComments: (state, action) => {
|
|
2179
|
+
for (const commentId of action.payload) {
|
|
2180
|
+
if (!(commentId in state.comments)) {
|
|
2181
|
+
throw new Error(`Failed to remove issue comment because ID doesn't exist: ${commentId}`);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
for (const commentId of action.payload) {
|
|
2185
|
+
delete state.comments[commentId];
|
|
2186
|
+
}
|
|
2152
2187
|
},
|
|
2153
2188
|
cleanRecentIssues: (state) => {
|
|
2154
2189
|
state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.issues[recentIssue.offlineId]);
|
|
@@ -2187,20 +2222,25 @@ var __publicField = (obj, key, value) => {
|
|
|
2187
2222
|
removeIssueAttachment,
|
|
2188
2223
|
removeAttachmentsOfIssue,
|
|
2189
2224
|
removeIssue,
|
|
2190
|
-
removeIssueComment,
|
|
2191
2225
|
removeIssueUpdate,
|
|
2192
2226
|
removeIssueUpdates,
|
|
2193
2227
|
removeRecentIssue,
|
|
2194
2228
|
resetRecentIssues,
|
|
2195
2229
|
setActiveIssueId,
|
|
2196
2230
|
setIssueAttachments,
|
|
2197
|
-
setIssueComments,
|
|
2198
2231
|
setIssueUpdates,
|
|
2199
2232
|
setIssues,
|
|
2200
2233
|
setVisibleStatuses,
|
|
2201
2234
|
setVisibleUserIds,
|
|
2202
2235
|
updateIssueAttachment,
|
|
2203
|
-
updateIssue
|
|
2236
|
+
updateIssue,
|
|
2237
|
+
// Commments
|
|
2238
|
+
addIssueComment,
|
|
2239
|
+
addIssueComments,
|
|
2240
|
+
setIssueComment,
|
|
2241
|
+
setIssueComments,
|
|
2242
|
+
removeIssueComment,
|
|
2243
|
+
removeIssueComments
|
|
2204
2244
|
} = issueSlice.actions;
|
|
2205
2245
|
const selectIssueMapping = (state) => state.issueReducer.issues;
|
|
2206
2246
|
const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
|
|
@@ -5757,49 +5797,35 @@ var __publicField = (obj, key, value) => {
|
|
|
5757
5797
|
}
|
|
5758
5798
|
}
|
|
5759
5799
|
class IssueCommentService extends BaseApiService {
|
|
5800
|
+
// Omit author and submitted_at since these will always be set internally
|
|
5760
5801
|
add(comment) {
|
|
5761
|
-
const offlinePayload = offline(comment);
|
|
5762
|
-
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5763
5802
|
const { store } = this.client;
|
|
5764
|
-
const offlineComment = {
|
|
5765
|
-
...
|
|
5803
|
+
const offlineComment = offline({
|
|
5804
|
+
...comment,
|
|
5766
5805
|
author: store.getState().userReducer.currentUser.id,
|
|
5767
|
-
|
|
5768
|
-
};
|
|
5769
|
-
store.dispatch(
|
|
5806
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5807
|
+
});
|
|
5808
|
+
store.dispatch(addIssueComment(offlineComment));
|
|
5770
5809
|
const promise = this.enqueueRequest({
|
|
5771
5810
|
description: `${truncate(comment.content, 80)}`,
|
|
5772
5811
|
method: HttpMethod.POST,
|
|
5773
5812
|
url: `/issues/${comment.issue}/comment/`,
|
|
5774
|
-
payload:
|
|
5813
|
+
payload: offlineComment,
|
|
5775
5814
|
blockers: [comment.issue],
|
|
5776
|
-
blocks: [
|
|
5815
|
+
blocks: [offlineComment.offline_id]
|
|
5816
|
+
});
|
|
5817
|
+
promise.catch(() => {
|
|
5818
|
+
store.dispatch(removeIssueComment(offlineComment.offline_id));
|
|
5777
5819
|
});
|
|
5778
5820
|
return [offlineComment, promise];
|
|
5779
5821
|
}
|
|
5780
|
-
|
|
5822
|
+
update(comment) {
|
|
5781
5823
|
const { store } = this.client;
|
|
5782
|
-
const
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
// TODO: Choose between /issues/comments/in-project/${projectId}/ and /projects/${projectId}/issue-comments/
|
|
5786
|
-
url: `/projects/${store.getState().projectReducer.activeProjectId}/comments/`,
|
|
5787
|
-
blockers: [],
|
|
5788
|
-
blocks: []
|
|
5789
|
-
});
|
|
5790
|
-
let filteredResult = result.filter(onlyUniqueOfflineIds);
|
|
5791
|
-
filteredResult = filteredResult.map((comment) => {
|
|
5792
|
-
return { ...comment };
|
|
5793
|
-
});
|
|
5794
|
-
if (result.length !== filteredResult.length) {
|
|
5795
|
-
console.error(
|
|
5796
|
-
`Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
|
|
5797
|
-
);
|
|
5824
|
+
const commentToUpdate = store.getState().issueReducer.comments[comment.offline_id];
|
|
5825
|
+
if (!commentToUpdate) {
|
|
5826
|
+
throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
|
|
5798
5827
|
}
|
|
5799
|
-
store.dispatch(
|
|
5800
|
-
}
|
|
5801
|
-
update(comment) {
|
|
5802
|
-
this.client.store.dispatch(addOrReplaceIssueComment(comment));
|
|
5828
|
+
store.dispatch(setIssueComment(comment));
|
|
5803
5829
|
const promise = this.enqueueRequest({
|
|
5804
5830
|
description: `Edit comment: ${truncate(comment.content, 80)}`,
|
|
5805
5831
|
method: HttpMethod.PATCH,
|
|
@@ -5808,17 +5834,40 @@ var __publicField = (obj, key, value) => {
|
|
|
5808
5834
|
blockers: [comment.issue],
|
|
5809
5835
|
blocks: [comment.offline_id]
|
|
5810
5836
|
});
|
|
5837
|
+
promise.catch(() => {
|
|
5838
|
+
store.dispatch(setIssueComment(commentToUpdate));
|
|
5839
|
+
});
|
|
5811
5840
|
return [comment, promise];
|
|
5812
5841
|
}
|
|
5813
5842
|
remove(offline_id) {
|
|
5843
|
+
const commentToRemove = this.client.store.getState().issueReducer.comments[offline_id];
|
|
5844
|
+
if (!commentToRemove) {
|
|
5845
|
+
throw new Error(`Comment with offline_id ${offline_id} not found in store`);
|
|
5846
|
+
}
|
|
5814
5847
|
this.client.store.dispatch(removeIssueComment(offline_id));
|
|
5815
|
-
|
|
5848
|
+
const promise = this.enqueueRequest({
|
|
5816
5849
|
description: "Delete comment",
|
|
5817
5850
|
method: HttpMethod.DELETE,
|
|
5818
5851
|
url: `/issues/comments/${offline_id}/`,
|
|
5819
5852
|
blockers: [offline_id],
|
|
5820
5853
|
blocks: []
|
|
5821
5854
|
});
|
|
5855
|
+
promise.catch(() => {
|
|
5856
|
+
this.client.store.dispatch(addIssueComment(commentToRemove));
|
|
5857
|
+
});
|
|
5858
|
+
return promise;
|
|
5859
|
+
}
|
|
5860
|
+
async refreshStore() {
|
|
5861
|
+
const { store } = this.client;
|
|
5862
|
+
const result = await this.enqueueRequest({
|
|
5863
|
+
description: "Get comments",
|
|
5864
|
+
method: HttpMethod.GET,
|
|
5865
|
+
// TODO: Choose between /issues/comments/in-project/${projectId}/ and /projects/${projectId}/issue-comments/
|
|
5866
|
+
url: `/projects/${store.getState().projectReducer.activeProjectId}/comments/`,
|
|
5867
|
+
blockers: [],
|
|
5868
|
+
blocks: []
|
|
5869
|
+
});
|
|
5870
|
+
store.dispatch(setIssueComments(result));
|
|
5822
5871
|
}
|
|
5823
5872
|
}
|
|
5824
5873
|
class IssueUpdateService extends BaseApiService {
|
|
@@ -15474,6 +15523,8 @@ var __publicField = (obj, key, value) => {
|
|
|
15474
15523
|
exports2.addIssue = addIssue;
|
|
15475
15524
|
exports2.addIssueAttachment = addIssueAttachment;
|
|
15476
15525
|
exports2.addIssueAttachments = addIssueAttachments;
|
|
15526
|
+
exports2.addIssueComment = addIssueComment;
|
|
15527
|
+
exports2.addIssueComments = addIssueComments;
|
|
15477
15528
|
exports2.addIssueUpdate = addIssueUpdate;
|
|
15478
15529
|
exports2.addIssueUpdates = addIssueUpdates;
|
|
15479
15530
|
exports2.addLicenses = addLicenses;
|
|
@@ -15635,6 +15686,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15635
15686
|
exports2.removeIssue = removeIssue;
|
|
15636
15687
|
exports2.removeIssueAttachment = removeIssueAttachment;
|
|
15637
15688
|
exports2.removeIssueComment = removeIssueComment;
|
|
15689
|
+
exports2.removeIssueComments = removeIssueComments;
|
|
15638
15690
|
exports2.removeIssueUpdate = removeIssueUpdate;
|
|
15639
15691
|
exports2.removeIssueUpdates = removeIssueUpdates;
|
|
15640
15692
|
exports2.removeOrganizationAccess = removeOrganizationAccess;
|
|
@@ -15835,6 +15887,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15835
15887
|
exports2.setIsImportingProjectFile = setIsImportingProjectFile;
|
|
15836
15888
|
exports2.setIsLoading = setIsLoading;
|
|
15837
15889
|
exports2.setIssueAttachments = setIssueAttachments;
|
|
15890
|
+
exports2.setIssueComment = setIssueComment;
|
|
15838
15891
|
exports2.setIssueComments = setIssueComments;
|
|
15839
15892
|
exports2.setIssueUpdates = setIssueUpdates;
|
|
15840
15893
|
exports2.setIssues = setIssues;
|