@overmap-ai/core 1.0.48-activity-history.2 → 1.0.48-activity-history.3
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 +92 -38
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +92 -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 +3 -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,36 @@ 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
|
-
|
|
5806
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5807
|
+
resolved: false
|
|
5808
|
+
});
|
|
5809
|
+
store.dispatch(addIssueComment(offlineComment));
|
|
5770
5810
|
const promise = this.enqueueRequest({
|
|
5771
5811
|
description: `${truncate(comment.content, 80)}`,
|
|
5772
5812
|
method: HttpMethod.POST,
|
|
5773
5813
|
url: `/issues/${comment.issue}/comment/`,
|
|
5774
|
-
payload:
|
|
5814
|
+
payload: offlineComment,
|
|
5775
5815
|
blockers: [comment.issue],
|
|
5776
|
-
blocks: [
|
|
5816
|
+
blocks: [offlineComment.offline_id]
|
|
5817
|
+
});
|
|
5818
|
+
promise.catch(() => {
|
|
5819
|
+
store.dispatch(removeIssueComment(offlineComment.offline_id));
|
|
5777
5820
|
});
|
|
5778
5821
|
return [offlineComment, promise];
|
|
5779
5822
|
}
|
|
5780
|
-
|
|
5823
|
+
update(comment) {
|
|
5781
5824
|
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
|
-
);
|
|
5825
|
+
const commentToUpdate = store.getState().issueReducer.comments[comment.offline_id];
|
|
5826
|
+
if (!commentToUpdate) {
|
|
5827
|
+
throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
|
|
5798
5828
|
}
|
|
5799
|
-
store.dispatch(
|
|
5800
|
-
}
|
|
5801
|
-
update(comment) {
|
|
5802
|
-
this.client.store.dispatch(addOrReplaceIssueComment(comment));
|
|
5829
|
+
store.dispatch(setIssueComment(comment));
|
|
5803
5830
|
const promise = this.enqueueRequest({
|
|
5804
5831
|
description: `Edit comment: ${truncate(comment.content, 80)}`,
|
|
5805
5832
|
method: HttpMethod.PATCH,
|
|
@@ -5808,17 +5835,40 @@ var __publicField = (obj, key, value) => {
|
|
|
5808
5835
|
blockers: [comment.issue],
|
|
5809
5836
|
blocks: [comment.offline_id]
|
|
5810
5837
|
});
|
|
5838
|
+
promise.catch(() => {
|
|
5839
|
+
store.dispatch(setIssueComment(commentToUpdate));
|
|
5840
|
+
});
|
|
5811
5841
|
return [comment, promise];
|
|
5812
5842
|
}
|
|
5813
5843
|
remove(offline_id) {
|
|
5844
|
+
const commentToRemove = this.client.store.getState().issueReducer.comments[offline_id];
|
|
5845
|
+
if (!commentToRemove) {
|
|
5846
|
+
throw new Error(`Comment with offline_id ${offline_id} not found in store`);
|
|
5847
|
+
}
|
|
5814
5848
|
this.client.store.dispatch(removeIssueComment(offline_id));
|
|
5815
|
-
|
|
5849
|
+
const promise = this.enqueueRequest({
|
|
5816
5850
|
description: "Delete comment",
|
|
5817
5851
|
method: HttpMethod.DELETE,
|
|
5818
5852
|
url: `/issues/comments/${offline_id}/`,
|
|
5819
5853
|
blockers: [offline_id],
|
|
5820
5854
|
blocks: []
|
|
5821
5855
|
});
|
|
5856
|
+
promise.catch(() => {
|
|
5857
|
+
this.client.store.dispatch(addIssueComment(commentToRemove));
|
|
5858
|
+
});
|
|
5859
|
+
return promise;
|
|
5860
|
+
}
|
|
5861
|
+
async refreshStore() {
|
|
5862
|
+
const { store } = this.client;
|
|
5863
|
+
const result = await this.enqueueRequest({
|
|
5864
|
+
description: "Get comments",
|
|
5865
|
+
method: HttpMethod.GET,
|
|
5866
|
+
// TODO: Choose between /issues/comments/in-project/${projectId}/ and /projects/${projectId}/issue-comments/
|
|
5867
|
+
url: `/projects/${store.getState().projectReducer.activeProjectId}/comments/`,
|
|
5868
|
+
blockers: [],
|
|
5869
|
+
blocks: []
|
|
5870
|
+
});
|
|
5871
|
+
store.dispatch(setIssueComments(result));
|
|
5822
5872
|
}
|
|
5823
5873
|
}
|
|
5824
5874
|
class IssueUpdateService extends BaseApiService {
|
|
@@ -15474,6 +15524,8 @@ var __publicField = (obj, key, value) => {
|
|
|
15474
15524
|
exports2.addIssue = addIssue;
|
|
15475
15525
|
exports2.addIssueAttachment = addIssueAttachment;
|
|
15476
15526
|
exports2.addIssueAttachments = addIssueAttachments;
|
|
15527
|
+
exports2.addIssueComment = addIssueComment;
|
|
15528
|
+
exports2.addIssueComments = addIssueComments;
|
|
15477
15529
|
exports2.addIssueUpdate = addIssueUpdate;
|
|
15478
15530
|
exports2.addIssueUpdates = addIssueUpdates;
|
|
15479
15531
|
exports2.addLicenses = addLicenses;
|
|
@@ -15635,6 +15687,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15635
15687
|
exports2.removeIssue = removeIssue;
|
|
15636
15688
|
exports2.removeIssueAttachment = removeIssueAttachment;
|
|
15637
15689
|
exports2.removeIssueComment = removeIssueComment;
|
|
15690
|
+
exports2.removeIssueComments = removeIssueComments;
|
|
15638
15691
|
exports2.removeIssueUpdate = removeIssueUpdate;
|
|
15639
15692
|
exports2.removeIssueUpdates = removeIssueUpdates;
|
|
15640
15693
|
exports2.removeOrganizationAccess = removeOrganizationAccess;
|
|
@@ -15835,6 +15888,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15835
15888
|
exports2.setIsImportingProjectFile = setIsImportingProjectFile;
|
|
15836
15889
|
exports2.setIsLoading = setIsLoading;
|
|
15837
15890
|
exports2.setIssueAttachments = setIssueAttachments;
|
|
15891
|
+
exports2.setIssueComment = setIssueComment;
|
|
15838
15892
|
exports2.setIssueComments = setIssueComments;
|
|
15839
15893
|
exports2.setIssueUpdates = setIssueUpdates;
|
|
15840
15894
|
exports2.setIssues = setIssues;
|