UBERF-7419: Fix various sentry errors (#5931)

This commit is contained in:
Andrey Sobolev 2024-06-27 20:27:00 +07:00 committed by GitHub
parent 777eb415aa
commit 80d22b556c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 76 additions and 44 deletions

View File

@ -38,6 +38,9 @@ function $push (document: Doc, keyval: Record<string, PropertyType>): void {
arr.push(val) arr.push(val)
} }
} else { } else {
if (doc[key] == null) {
doc[key] = []
}
doc[key].push(val) doc[key].push(val)
} }
} }
@ -53,7 +56,7 @@ function $pull (document: Doc, keyval: Record<string, PropertyType>): void {
if (typeof keyval[key] === 'object' && keyval[key] !== null) { if (typeof keyval[key] === 'object' && keyval[key] !== null) {
const { $in } = keyval[key] as PullArray<PropertyType> const { $in } = keyval[key] as PullArray<PropertyType>
doc[key] = arr.filter((val) => { doc[key] = (arr ?? []).filter((val) => {
if ($in !== undefined) { if ($in !== undefined) {
return !$in.includes(val) return !$in.includes(val)
} else { } else {
@ -67,7 +70,7 @@ function $pull (document: Doc, keyval: Record<string, PropertyType>): void {
} }
}) })
} else { } else {
doc[key] = arr.filter((val) => val !== keyval[key]) doc[key] = (arr ?? []).filter((val) => val !== keyval[key])
} }
} }
} }
@ -119,7 +122,7 @@ function $move (document: Doc, keyval: Record<string, PropertyType>): void {
} }
const arr = doc[key] as Array<any> const arr = doc[key] as Array<any>
const desc = keyval[key] const desc = keyval[key]
doc[key] = arr.filter((val) => val !== desc.$value) doc[key] = (arr ?? []).filter((val) => val !== desc.$value)
doc[key].splice(desc.$position, 0, desc.$value) doc[key].splice(desc.$position, 0, desc.$value)
} }
} }
@ -134,7 +137,7 @@ function $pushMixin (document: Doc, options: any): void {
const keyval = options.values const keyval = options.values
for (const key in keyval) { for (const key in keyval) {
const arr = mixin[key] const arr = mixin[key]
if (arr === undefined) { if (arr == null) {
mixin[key] = [keyval[key]] mixin[key] = [keyval[key]]
} else { } else {
arr.push(keyval[key]) arr.push(keyval[key])

View File

@ -71,7 +71,10 @@
created.length > 0 || created.length > 0 ||
objects.map((it) => getObjectValue(groupBy, it)).filter((it, index, arr) => arr.indexOf(it) === index).length > 1 objects.map((it) => getObjectValue(groupBy, it)).filter((it, index, arr) => arr.indexOf(it) === index).length > 1
const checkSelected = (item: Doc): void => { const checkSelected = (item?: Doc): void => {
if (item === undefined) {
return
}
if (selectedElements.has(item._id)) { if (selectedElements.has(item._id)) {
selectedElements.delete(item._id) selectedElements.delete(item._id)
} else { } else {

View File

@ -304,7 +304,9 @@ export function getPlatformColors (darkTheme: boolean): readonly ColorDefinition
} }
function hashCode (str: string): number { function hashCode (str: string): number {
return str.split('').reduce((prevHash, currVal) => ((prevHash << 5) - prevHash + currVal.charCodeAt(0)) | 0, 0) return (str ?? '')
.split('')
.reduce((prevHash, currVal) => ((prevHash << 5) - prevHash + currVal.charCodeAt(0)) | 0, 0)
} }
/** /**

View File

@ -41,6 +41,9 @@
async function handleSelection (evt: Event | undefined, selection: number): Promise<void> { async function handleSelection (evt: Event | undefined, selection: number): Promise<void> {
const item = objects[selection] const item = objects[selection]
if (item == null) {
return
}
if (multiselect && Array.isArray(selected)) { if (multiselect && Array.isArray(selected)) {
const index = selected.indexOf(item.id) const index = selected.indexOf(item.id)
if (index !== -1) { if (index !== -1) {

View File

@ -208,10 +208,10 @@
const checkSizes = (): void => { const checkSizes = (): void => {
if (sState === SeparatorState.FLOAT) { if (sState === SeparatorState.FLOAT) {
if (parentElement) initSize(parentElement, panel) if (parentElement != null && panel != null) initSize(parentElement, panel)
} else if (sState === SeparatorState.NORMAL) { } else if (sState === SeparatorState.NORMAL) {
if (prevElement) initSize(prevElement, prevElSize) if (prevElement != null && prevElSize != null) initSize(prevElement, prevElSize)
if (nextElement) initSize(nextElement, nextElSize, true) if (nextElement != null && nextElSize != null) initSize(nextElement, nextElSize, true)
} }
} }

View File

@ -69,6 +69,7 @@
name="file" name="file"
id="file" id="file"
style="display: none" style="display: none"
disabled={inputFile == null}
on:change={fileSelected} on:change={fileSelected}
/> />
</div> </div>

View File

@ -107,6 +107,7 @@
name="file" name="file"
id="file" id="file"
style="display: none" style="display: none"
disabled={inputFile == null}
on:change={fileSelected} on:change={fileSelected}
/> />
<div class="flex flex-between flex-grow header clear-mins"> <div class="flex flex-between flex-grow header clear-mins">

View File

@ -308,6 +308,7 @@
<div class="no-print" bind:this={refContainer}> <div class="no-print" bind:this={refContainer}>
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -243,6 +243,7 @@
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -65,9 +65,7 @@
loading-- loading--
} }
if (inputFile) {
inputFile.value = '' inputFile.value = ''
}
dispatch('attached') dispatch('attached')
} }
@ -103,6 +101,7 @@
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -126,6 +126,7 @@
{/if} {/if}
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -159,6 +159,7 @@ function createModelPersistence (workspace: string): TxPersistenceStore | undefi
load: async () => { load: async () => {
const db = await dbPromise const db = await dbPromise
if (db !== undefined) { if (db !== undefined) {
try {
const transaction = db.transaction('model', 'readwrite') // (1) const transaction = db.transaction('model', 'readwrite') // (1)
const models = transaction.objectStore('model') // (2) const models = transaction.objectStore('model') // (2)
const model = await new Promise<{ id: string, model: LoadModelResponse } | undefined>((resolve) => { const model = await new Promise<{ id: string, model: LoadModelResponse } | undefined>((resolve) => {
@ -179,6 +180,9 @@ function createModelPersistence (workspace: string): TxPersistenceStore | undefi
} }
} }
return model.model return model.model
} catch (err: any) {
// Assume no model is stored.
}
} }
return { return {
full: true, full: true,

View File

@ -107,6 +107,7 @@
{:else} {:else}
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -177,6 +177,7 @@
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -261,6 +261,7 @@
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -76,7 +76,7 @@
.findAllSync<Application>(workbench.class.Application, { hidden: false, _id: { $nin: excludedApps } }) .findAllSync<Application>(workbench.class.Application, { hidden: false, _id: { $nin: excludedApps } })
async function resolveShortLink (loc: Location): Promise<ResolvedLocation | undefined> { async function resolveShortLink (loc: Location): Promise<ResolvedLocation | undefined> {
if (loc.path[2] !== undefined && loc.path[2].trim().length > 0) { if (loc.path[2] != null && loc.path[2].trim().length > 0) {
const app = apps.find((p) => p.alias === loc.path[2]) const app = apps.find((p) => p.alias === loc.path[2])
if (app?.locationResolver) { if (app?.locationResolver) {
const resolver = await getResource(app.locationResolver) const resolver = await getResource(app.locationResolver)
@ -181,7 +181,7 @@
if (fragment !== currentFragment) { if (fragment !== currentFragment) {
currentFragment = fragment currentFragment = fragment
if (fragment !== undefined && fragment.trim().length > 0) { if (fragment != null && fragment.trim().length > 0) {
await setOpenPanelFocus(fragment) await setOpenPanelFocus(fragment)
} else { } else {
closePanel() closePanel()

View File

@ -46,7 +46,7 @@
? getEndDate(currentDate.getFullYear(), 11) ? getEndDate(currentDate.getFullYear(), 11)
: getEndDate(currentDate.getFullYear(), currentDate.getMonth()) : getEndDate(currentDate.getFullYear(), currentDate.getMonth())
$: departments = [department, ...getDescendants(department, descendants)] $: departments = [department, ...getDescendants(department, descendants, new Set())]
$: staffIdsForOpenedDepartments = staff.filter((p) => departments.includes(p.department)).map((p) => p._id) $: staffIdsForOpenedDepartments = staff.filter((p) => departments.includes(p.department)).map((p) => p._id)
const lq = createQuery() const lq = createQuery()
@ -79,11 +79,16 @@
function getDescendants ( function getDescendants (
department: Ref<Department>, department: Ref<Department>,
descendants: Map<Ref<Department>, Department[]> descendants: Map<Ref<Department>, Department[]>,
visited: Set<string>
): Ref<Department>[] { ): Ref<Department>[] {
const res = (descendants.get(department) ?? []).map((p) => p._id) const res = (descendants.get(department) ?? []).map((p) => p._id)
for (const department of res) { for (const department of res) {
res.push(...getDescendants(department, descendants)) const has = visited.has(department)
if (!has) {
visited.add(department)
res.push(...getDescendants(department, descendants, visited))
}
} }
return res return res
} }

View File

@ -135,7 +135,7 @@
await tick() await tick()
index = participants.findIndex((p) => p._id === participant.identity) index = participants.findIndex((p) => p._id === participant.identity)
const el = participantElements[index] const el = participantElements[index]
if (el !== undefined) { if (el != null) {
el.appendChild(element) el.appendChild(element)
return return
} }
@ -180,7 +180,7 @@
return return
} }
const index = participants.findIndex((p) => p._id === participant.identity) const index = participants.findIndex((p) => p._id === participant.identity)
if (index !== -1) { if (index !== -1 && participantElements[index] != null) {
participantElements[index].setTrackMuted(publication.isMuted) participantElements[index].setTrackMuted(publication.isMuted)
} }
} else { } else {

View File

@ -168,7 +168,7 @@
return return
} }
const index = participants.findIndex((p) => p._id === participant.identity) const index = participants.findIndex((p) => p._id === participant.identity)
if (index !== -1) { if (index !== -1 && participantElements[index] != null) {
participantElements[index].setTrackMuted(publication.isMuted) participantElements[index].setTrackMuted(publication.isMuted)
} }
} else { } else {

View File

@ -613,6 +613,7 @@ export async function tryConnect (
}) })
requestsQuery.query(love.class.JoinRequest, { person: (me as PersonAccount).person, _id }, (res) => { requestsQuery.query(love.class.JoinRequest, { person: (me as PersonAccount).person, _id }, (res) => {
const req = res[0] const req = res[0]
if (req === undefined) return
if (req.status === RequestStatus.Pending) return if (req.status === RequestStatus.Pending) return
requestsQuery.unsubscribe() requestsQuery.unsubscribe()
if (req.status === RequestStatus.Approved) { if (req.status === RequestStatus.Approved) {

View File

@ -222,6 +222,7 @@
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -184,6 +184,7 @@
</div> </div>
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -216,9 +216,12 @@
let currentProject: Project | undefined let currentProject: Project | undefined
let descriptionBox: AttachmentStyledBox | undefined
$: updateIssueStatusId(object, currentProject) $: updateIssueStatusId(object, currentProject)
$: updateAssigneeId(object, currentProject) $: updateAssigneeId(object, currentProject)
$: canSave = $: canSave =
descriptionBox != null &&
getTitle(object.title ?? '').length > 0 && getTitle(object.title ?? '').length > 0 &&
object.status !== undefined && object.status !== undefined &&
kind !== undefined && kind !== undefined &&
@ -343,8 +346,6 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const spaceQuery = createQuery() const spaceQuery = createQuery()
let descriptionBox: AttachmentStyledBox
const key: KeyedAttribute = { const key: KeyedAttribute = {
key: 'labels', key: 'labels',
attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels') attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels')
@ -513,7 +514,7 @@
} }
await operations.commit() await operations.commit()
await descriptionBox.createAttachments(_id) await descriptionBox?.createAttachments(_id)
const parents: IssueParentInfo[] = const parents: IssueParentInfo[] =
parentIssue != null parentIssue != null
@ -986,7 +987,7 @@
showPreview showPreview
removable removable
on:remove={(result) => { on:remove={(result) => {
if (result.detail !== undefined) descriptionBox.removeAttachmentById(result.detail._id) if (result.detail !== undefined) descriptionBox?.removeAttachmentById(result.detail._id)
}} }}
/> />
{/each} {/each}
@ -1000,7 +1001,7 @@
size={'large'} size={'large'}
kind={'ghost'} kind={'ghost'}
on:click={() => { on:click={() => {
descriptionBox.handleAttach() descriptionBox?.handleAttach()
}} }}
/> />
<DocCreateExtComponent manager={docCreateManager} kind={'footer'} space={currentProject} props={extraProps} /> <DocCreateExtComponent manager={docCreateManager} kind={'footer'} space={currentProject} props={extraProps} />

View File

@ -100,6 +100,7 @@
<div class="antiNav-subheader"> <div class="antiNav-subheader">
<input <input
bind:this={inputFile} bind:this={inputFile}
disabled={inputFile == null}
multiple multiple
type="file" type="file"
name="file" name="file"

View File

@ -223,7 +223,7 @@
async function resolveShortLink (loc: Location): Promise<ResolvedLocation | undefined> { async function resolveShortLink (loc: Location): Promise<ResolvedLocation | undefined> {
let locationResolver = currentApplication?.locationResolver let locationResolver = currentApplication?.locationResolver
if (loc.path[2] !== undefined && loc.path[2].trim().length > 0) { if (loc.path[2] != null && loc.path[2].trim().length > 0) {
const app = apps.find((p) => p.alias === loc.path[2]) const app = apps.find((p) => p.alias === loc.path[2])
if (app?.locationResolver) { if (app?.locationResolver) {
locationResolver = app?.locationResolver locationResolver = app?.locationResolver
@ -391,7 +391,7 @@
currentQuery = loc.query currentQuery = loc.query
if (fragment !== currentFragment) { if (fragment !== currentFragment) {
currentFragment = fragment currentFragment = fragment
if (fragment !== undefined && fragment.trim().length > 0) { if (fragment != null && fragment.trim().length > 0) {
await setOpenPanelFocus(fragment) await setOpenPanelFocus(fragment)
} else { } else {
closePanel() closePanel()