@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
package/README.md
CHANGED
|
File without changes
|
package/dist/overmap-core.js
CHANGED
|
@@ -2144,20 +2144,55 @@ const issueSlice = createSlice({
|
|
|
2144
2144
|
setVisibleUserIds: (state, action) => {
|
|
2145
2145
|
state.visibleUserIds = [...new Set(action.payload)];
|
|
2146
2146
|
},
|
|
2147
|
-
|
|
2147
|
+
// Comments
|
|
2148
|
+
addIssueComment: (state, action) => {
|
|
2149
|
+
if (action.payload.offline_id in state.comments) {
|
|
2150
|
+
throw new Error(
|
|
2151
|
+
`Tried to add issue comment with offline_id: ${action.payload.offline_id} that already exists`
|
|
2152
|
+
);
|
|
2153
|
+
}
|
|
2154
|
+
state.comments[action.payload.offline_id] = action.payload;
|
|
2155
|
+
},
|
|
2156
|
+
addIssueComments: (state, action) => {
|
|
2157
|
+
for (const comment of action.payload) {
|
|
2158
|
+
if (comment.offline_id in state.comments) {
|
|
2159
|
+
throw new Error(
|
|
2160
|
+
`Tried to add issue comment with offline_id: ${comment.offline_id} that already exists`
|
|
2161
|
+
);
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2148
2164
|
for (const comment of action.payload) {
|
|
2149
2165
|
state.comments[comment.offline_id] = comment;
|
|
2150
2166
|
}
|
|
2151
2167
|
},
|
|
2168
|
+
setIssueComment: (state, action) => {
|
|
2169
|
+
state.comments[action.payload.offline_id] = action.payload;
|
|
2170
|
+
},
|
|
2171
|
+
setIssueComments: (state, action) => {
|
|
2172
|
+
const newComments = {};
|
|
2173
|
+
for (const comment of action.payload) {
|
|
2174
|
+
newComments[comment.offline_id] = comment;
|
|
2175
|
+
}
|
|
2176
|
+
state.comments = newComments;
|
|
2177
|
+
},
|
|
2152
2178
|
addOrReplaceIssueComment: (state, action) => {
|
|
2153
2179
|
state.comments[action.payload.offline_id] = action.payload;
|
|
2154
2180
|
},
|
|
2155
2181
|
removeIssueComment: (state, action) => {
|
|
2156
|
-
if (action.payload in state.comments) {
|
|
2157
|
-
delete state.comments[action.payload];
|
|
2158
|
-
} else {
|
|
2182
|
+
if (!(action.payload in state.comments)) {
|
|
2159
2183
|
throw new Error(`Failed to remove issue comment because ID doesn't exist: ${action.payload}`);
|
|
2160
2184
|
}
|
|
2185
|
+
delete state.comments[action.payload];
|
|
2186
|
+
},
|
|
2187
|
+
removeIssueComments: (state, action) => {
|
|
2188
|
+
for (const commentId of action.payload) {
|
|
2189
|
+
if (!(commentId in state.comments)) {
|
|
2190
|
+
throw new Error(`Failed to remove issue comment because ID doesn't exist: ${commentId}`);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
for (const commentId of action.payload) {
|
|
2194
|
+
delete state.comments[commentId];
|
|
2195
|
+
}
|
|
2161
2196
|
},
|
|
2162
2197
|
cleanRecentIssues: (state) => {
|
|
2163
2198
|
state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.issues[recentIssue.offlineId]);
|
|
@@ -2196,20 +2231,25 @@ const {
|
|
|
2196
2231
|
removeIssueAttachment,
|
|
2197
2232
|
removeAttachmentsOfIssue,
|
|
2198
2233
|
removeIssue,
|
|
2199
|
-
removeIssueComment,
|
|
2200
2234
|
removeIssueUpdate,
|
|
2201
2235
|
removeIssueUpdates,
|
|
2202
2236
|
removeRecentIssue,
|
|
2203
2237
|
resetRecentIssues,
|
|
2204
2238
|
setActiveIssueId,
|
|
2205
2239
|
setIssueAttachments,
|
|
2206
|
-
setIssueComments,
|
|
2207
2240
|
setIssueUpdates,
|
|
2208
2241
|
setIssues,
|
|
2209
2242
|
setVisibleStatuses,
|
|
2210
2243
|
setVisibleUserIds,
|
|
2211
2244
|
updateIssueAttachment,
|
|
2212
|
-
updateIssue
|
|
2245
|
+
updateIssue,
|
|
2246
|
+
// Commments
|
|
2247
|
+
addIssueComment,
|
|
2248
|
+
addIssueComments,
|
|
2249
|
+
setIssueComment,
|
|
2250
|
+
setIssueComments,
|
|
2251
|
+
removeIssueComment,
|
|
2252
|
+
removeIssueComments
|
|
2213
2253
|
} = issueSlice.actions;
|
|
2214
2254
|
const selectIssueMapping = (state) => state.issueReducer.issues;
|
|
2215
2255
|
const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
|
|
@@ -5766,49 +5806,35 @@ class ComponentTypeService extends BaseApiService {
|
|
|
5766
5806
|
}
|
|
5767
5807
|
}
|
|
5768
5808
|
class IssueCommentService extends BaseApiService {
|
|
5809
|
+
// Omit author and submitted_at since these will always be set internally
|
|
5769
5810
|
add(comment) {
|
|
5770
|
-
const offlinePayload = offline(comment);
|
|
5771
|
-
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5772
5811
|
const { store } = this.client;
|
|
5773
|
-
const offlineComment = {
|
|
5774
|
-
...
|
|
5812
|
+
const offlineComment = offline({
|
|
5813
|
+
...comment,
|
|
5775
5814
|
author: store.getState().userReducer.currentUser.id,
|
|
5776
|
-
|
|
5777
|
-
};
|
|
5778
|
-
store.dispatch(
|
|
5815
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5816
|
+
});
|
|
5817
|
+
store.dispatch(addIssueComment(offlineComment));
|
|
5779
5818
|
const promise = this.enqueueRequest({
|
|
5780
5819
|
description: `${truncate(comment.content, 80)}`,
|
|
5781
5820
|
method: HttpMethod.POST,
|
|
5782
5821
|
url: `/issues/${comment.issue}/comment/`,
|
|
5783
|
-
payload:
|
|
5822
|
+
payload: offlineComment,
|
|
5784
5823
|
blockers: [comment.issue],
|
|
5785
|
-
blocks: [
|
|
5824
|
+
blocks: [offlineComment.offline_id]
|
|
5825
|
+
});
|
|
5826
|
+
promise.catch(() => {
|
|
5827
|
+
store.dispatch(removeIssueComment(offlineComment.offline_id));
|
|
5786
5828
|
});
|
|
5787
5829
|
return [offlineComment, promise];
|
|
5788
5830
|
}
|
|
5789
|
-
|
|
5831
|
+
update(comment) {
|
|
5790
5832
|
const { store } = this.client;
|
|
5791
|
-
const
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
// TODO: Choose between /issues/comments/in-project/${projectId}/ and /projects/${projectId}/issue-comments/
|
|
5795
|
-
url: `/projects/${store.getState().projectReducer.activeProjectId}/comments/`,
|
|
5796
|
-
blockers: [],
|
|
5797
|
-
blocks: []
|
|
5798
|
-
});
|
|
5799
|
-
let filteredResult = result.filter(onlyUniqueOfflineIds);
|
|
5800
|
-
filteredResult = filteredResult.map((comment) => {
|
|
5801
|
-
return { ...comment };
|
|
5802
|
-
});
|
|
5803
|
-
if (result.length !== filteredResult.length) {
|
|
5804
|
-
console.error(
|
|
5805
|
-
`Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
|
|
5806
|
-
);
|
|
5833
|
+
const commentToUpdate = store.getState().issueReducer.comments[comment.offline_id];
|
|
5834
|
+
if (!commentToUpdate) {
|
|
5835
|
+
throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
|
|
5807
5836
|
}
|
|
5808
|
-
store.dispatch(
|
|
5809
|
-
}
|
|
5810
|
-
update(comment) {
|
|
5811
|
-
this.client.store.dispatch(addOrReplaceIssueComment(comment));
|
|
5837
|
+
store.dispatch(setIssueComment(comment));
|
|
5812
5838
|
const promise = this.enqueueRequest({
|
|
5813
5839
|
description: `Edit comment: ${truncate(comment.content, 80)}`,
|
|
5814
5840
|
method: HttpMethod.PATCH,
|
|
@@ -5817,17 +5843,40 @@ class IssueCommentService extends BaseApiService {
|
|
|
5817
5843
|
blockers: [comment.issue],
|
|
5818
5844
|
blocks: [comment.offline_id]
|
|
5819
5845
|
});
|
|
5846
|
+
promise.catch(() => {
|
|
5847
|
+
store.dispatch(setIssueComment(commentToUpdate));
|
|
5848
|
+
});
|
|
5820
5849
|
return [comment, promise];
|
|
5821
5850
|
}
|
|
5822
5851
|
remove(offline_id) {
|
|
5852
|
+
const commentToRemove = this.client.store.getState().issueReducer.comments[offline_id];
|
|
5853
|
+
if (!commentToRemove) {
|
|
5854
|
+
throw new Error(`Comment with offline_id ${offline_id} not found in store`);
|
|
5855
|
+
}
|
|
5823
5856
|
this.client.store.dispatch(removeIssueComment(offline_id));
|
|
5824
|
-
|
|
5857
|
+
const promise = this.enqueueRequest({
|
|
5825
5858
|
description: "Delete comment",
|
|
5826
5859
|
method: HttpMethod.DELETE,
|
|
5827
5860
|
url: `/issues/comments/${offline_id}/`,
|
|
5828
5861
|
blockers: [offline_id],
|
|
5829
5862
|
blocks: []
|
|
5830
5863
|
});
|
|
5864
|
+
promise.catch(() => {
|
|
5865
|
+
this.client.store.dispatch(addIssueComment(commentToRemove));
|
|
5866
|
+
});
|
|
5867
|
+
return promise;
|
|
5868
|
+
}
|
|
5869
|
+
async refreshStore() {
|
|
5870
|
+
const { store } = this.client;
|
|
5871
|
+
const result = await this.enqueueRequest({
|
|
5872
|
+
description: "Get comments",
|
|
5873
|
+
method: HttpMethod.GET,
|
|
5874
|
+
// TODO: Choose between /issues/comments/in-project/${projectId}/ and /projects/${projectId}/issue-comments/
|
|
5875
|
+
url: `/projects/${store.getState().projectReducer.activeProjectId}/comments/`,
|
|
5876
|
+
blockers: [],
|
|
5877
|
+
blocks: []
|
|
5878
|
+
});
|
|
5879
|
+
store.dispatch(setIssueComments(result));
|
|
5831
5880
|
}
|
|
5832
5881
|
}
|
|
5833
5882
|
class IssueUpdateService extends BaseApiService {
|
|
@@ -15484,6 +15533,8 @@ export {
|
|
|
15484
15533
|
addIssue,
|
|
15485
15534
|
addIssueAttachment,
|
|
15486
15535
|
addIssueAttachments,
|
|
15536
|
+
addIssueComment,
|
|
15537
|
+
addIssueComments,
|
|
15487
15538
|
addIssueUpdate,
|
|
15488
15539
|
addIssueUpdates,
|
|
15489
15540
|
addLicenses,
|
|
@@ -15645,6 +15696,7 @@ export {
|
|
|
15645
15696
|
removeIssue,
|
|
15646
15697
|
removeIssueAttachment,
|
|
15647
15698
|
removeIssueComment,
|
|
15699
|
+
removeIssueComments,
|
|
15648
15700
|
removeIssueUpdate,
|
|
15649
15701
|
removeIssueUpdates,
|
|
15650
15702
|
removeOrganizationAccess,
|
|
@@ -15845,6 +15897,7 @@ export {
|
|
|
15845
15897
|
setIsImportingProjectFile,
|
|
15846
15898
|
setIsLoading,
|
|
15847
15899
|
setIssueAttachments,
|
|
15900
|
+
setIssueComment,
|
|
15848
15901
|
setIssueComments,
|
|
15849
15902
|
setIssueUpdates,
|
|
15850
15903
|
setIssues,
|