Skip to content

Commit 80d22b5

Browse files
authored
UBERF-7419: Fix various sentry errors (#5931)
1 parent 777eb41 commit 80d22b5

File tree

25 files changed

+76
-44
lines changed

25 files changed

+76
-44
lines changed

packages/core/src/operator.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ function $push (document: Doc, keyval: Record<string, PropertyType>): void {
3838
arr.push(val)
3939
}
4040
} else {
41+
if (doc[key] == null) {
42+
doc[key] = []
43+
}
4144
doc[key].push(val)
4245
}
4346
}
@@ -53,7 +56,7 @@ function $pull (document: Doc, keyval: Record<string, PropertyType>): void {
5356
if (typeof keyval[key] === 'object' && keyval[key] !== null) {
5457
const { $in } = keyval[key] as PullArray<PropertyType>
5558

56-
doc[key] = arr.filter((val) => {
59+
doc[key] = (arr ?? []).filter((val) => {
5760
if ($in !== undefined) {
5861
return !$in.includes(val)
5962
} else {
@@ -67,7 +70,7 @@ function $pull (document: Doc, keyval: Record<string, PropertyType>): void {
6770
}
6871
})
6972
} else {
70-
doc[key] = arr.filter((val) => val !== keyval[key])
73+
doc[key] = (arr ?? []).filter((val) => val !== keyval[key])
7174
}
7275
}
7376
}
@@ -119,7 +122,7 @@ function $move (document: Doc, keyval: Record<string, PropertyType>): void {
119122
}
120123
const arr = doc[key] as Array<any>
121124
const desc = keyval[key]
122-
doc[key] = arr.filter((val) => val !== desc.$value)
125+
doc[key] = (arr ?? []).filter((val) => val !== desc.$value)
123126
doc[key].splice(desc.$position, 0, desc.$value)
124127
}
125128
}
@@ -134,7 +137,7 @@ function $pushMixin (document: Doc, options: any): void {
134137
const keyval = options.values
135138
for (const key in keyval) {
136139
const arr = mixin[key]
137-
if (arr === undefined) {
140+
if (arr == null) {
138141
mixin[key] = [keyval[key]]
139142
} else {
140143
arr.push(keyval[key])

packages/presentation/src/components/DocPopup.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@
7171
created.length > 0 ||
7272
objects.map((it) => getObjectValue(groupBy, it)).filter((it, index, arr) => arr.indexOf(it) === index).length > 1
7373
74-
const checkSelected = (item: Doc): void => {
74+
const checkSelected = (item?: Doc): void => {
75+
if (item === undefined) {
76+
return
77+
}
7578
if (selectedElements.has(item._id)) {
7679
selectedElements.delete(item._id)
7780
} else {

packages/ui/src/colors.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ export function getPlatformColors (darkTheme: boolean): readonly ColorDefinition
304304
}
305305

306306
function hashCode (str: string): number {
307-
return str.split('').reduce((prevHash, currVal) => ((prevHash << 5) - prevHash + currVal.charCodeAt(0)) | 0, 0)
307+
return (str ?? '')
308+
.split('')
309+
.reduce((prevHash, currVal) => ((prevHash << 5) - prevHash + currVal.charCodeAt(0)) | 0, 0)
308310
}
309311

310312
/**

packages/ui/src/components/DropdownLabelsPopup.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
4242
async function handleSelection (evt: Event | undefined, selection: number): Promise<void> {
4343
const item = objects[selection]
44+
if (item == null) {
45+
return
46+
}
4447
if (multiselect && Array.isArray(selected)) {
4548
const index = selected.indexOf(item.id)
4649
if (index !== -1) {

packages/ui/src/components/Separator.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@
208208
209209
const checkSizes = (): void => {
210210
if (sState === SeparatorState.FLOAT) {
211-
if (parentElement) initSize(parentElement, panel)
211+
if (parentElement != null && panel != null) initSize(parentElement, panel)
212212
} else if (sState === SeparatorState.NORMAL) {
213-
if (prevElement) initSize(prevElement, prevElSize)
214-
if (nextElement) initSize(nextElement, nextElSize, true)
213+
if (prevElement != null && prevElSize != null) initSize(prevElement, prevElSize)
214+
if (nextElement != null && nextElSize != null) initSize(nextElement, nextElSize, true)
215215
}
216216
}
217217

plugins/attachment-resources/src/components/AddAttachment.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
name="file"
7070
id="file"
7171
style="display: none"
72+
disabled={inputFile == null}
7273
on:change={fileSelected}
7374
/>
7475
</div>

plugins/attachment-resources/src/components/AttachmentPopup.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
name="file"
108108
id="file"
109109
style="display: none"
110+
disabled={inputFile == null}
110111
on:change={fileSelected}
111112
/>
112113
<div class="flex flex-between flex-grow header clear-mins">

plugins/attachment-resources/src/components/AttachmentRefInput.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@
308308
<div class="no-print" bind:this={refContainer}>
309309
<input
310310
bind:this={inputFile}
311+
disabled={inputFile == null}
311312
multiple
312313
type="file"
313314
name="file"

plugins/attachment-resources/src/components/AttachmentStyleBoxCollabEditor.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243

244244
<input
245245
bind:this={inputFile}
246+
disabled={inputFile == null}
246247
multiple
247248
type="file"
248249
name="file"

plugins/attachment-resources/src/components/Attachments.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@
6565
loading--
6666
}
6767
68-
if (inputFile) {
69-
inputFile.value = ''
70-
}
68+
inputFile.value = ''
7169
7270
dispatch('attached')
7371
}
@@ -103,6 +101,7 @@
103101

104102
<input
105103
bind:this={inputFile}
104+
disabled={inputFile == null}
106105
multiple
107106
type="file"
108107
name="file"

0 commit comments

Comments
 (0)