Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-7419: Fix various sentry errors #5931

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/core/src/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function $push (document: Doc, keyval: Record<string, PropertyType>): void {
arr.push(val)
}
} else {
if (doc[key] == null) {
doc[key] = []
}
doc[key].push(val)
}
}
Expand All @@ -53,7 +56,7 @@ function $pull (document: Doc, keyval: Record<string, PropertyType>): void {
if (typeof keyval[key] === 'object' && keyval[key] !== null) {
const { $in } = keyval[key] as PullArray<PropertyType>

doc[key] = arr.filter((val) => {
doc[key] = (arr ?? []).filter((val) => {
if ($in !== undefined) {
return !$in.includes(val)
} else {
Expand All @@ -67,7 +70,7 @@ function $pull (document: Doc, keyval: Record<string, PropertyType>): void {
}
})
} else {
doc[key] = arr.filter((val) => val !== keyval[key])
doc[key] = (arr ?? []).filter((val) => val !== keyval[key])
}
}
}
Expand Down Expand Up @@ -119,7 +122,7 @@ function $move (document: Doc, keyval: Record<string, PropertyType>): void {
}
const arr = doc[key] as Array<any>
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)
}
}
Expand All @@ -134,7 +137,7 @@ function $pushMixin (document: Doc, options: any): void {
const keyval = options.values
for (const key in keyval) {
const arr = mixin[key]
if (arr === undefined) {
if (arr == null) {
mixin[key] = [keyval[key]]
} else {
arr.push(keyval[key])
Expand Down
5 changes: 4 additions & 1 deletion packages/presentation/src/components/DocPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
created.length > 0 ||
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)) {
selectedElements.delete(item._id)
} else {
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ export function getPlatformColors (darkTheme: boolean): readonly ColorDefinition
}

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)
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/DropdownLabelsPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@

async function handleSelection (evt: Event | undefined, selection: number): Promise<void> {
const item = objects[selection]
if (item == null) {
return
}
if (multiselect && Array.isArray(selected)) {
const index = selected.indexOf(item.id)
if (index !== -1) {
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/components/Separator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
name="file"
id="file"
style="display: none"
disabled={inputFile == null}
on:change={fileSelected}
/>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
name="file"
id="file"
style="display: none"
disabled={inputFile == null}
on:change={fileSelected}
/>
<div class="flex flex-between flex-grow header clear-mins">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
<div class="no-print" bind:this={refContainer}>
<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@

<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@
loading--
}

if (inputFile) {
inputFile.value = ''
}
inputFile.value = ''

dispatch('attached')
}
Expand Down Expand Up @@ -103,6 +101,7 @@

<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
1 change: 1 addition & 0 deletions plugins/attachment-resources/src/components/Photos.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
{/if}
<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
38 changes: 21 additions & 17 deletions plugins/client-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,30 @@ function createModelPersistence (workspace: string): TxPersistenceStore | undefi
load: async () => {
const db = await dbPromise
if (db !== undefined) {
const transaction = db.transaction('model', 'readwrite') // (1)
const models = transaction.objectStore('model') // (2)
const model = await new Promise<{ id: string, model: LoadModelResponse } | undefined>((resolve) => {
const storedValue: IDBRequest<{ id: string, model: LoadModelResponse }> = models.get(workspace)
storedValue.onsuccess = function () {
resolve(storedValue.result)
}
storedValue.onerror = function () {
resolve(undefined)
}
})
try {
const transaction = db.transaction('model', 'readwrite') // (1)
const models = transaction.objectStore('model') // (2)
const model = await new Promise<{ id: string, model: LoadModelResponse } | undefined>((resolve) => {
const storedValue: IDBRequest<{ id: string, model: LoadModelResponse }> = models.get(workspace)
storedValue.onsuccess = function () {
resolve(storedValue.result)
}
storedValue.onerror = function () {
resolve(undefined)
}
})

if (model == null) {
return {
full: false,
transactions: [],
hash: ''
if (model == null) {
return {
full: false,
transactions: [],
hash: ''
}
}
return model.model
} catch (err: any) {
// Assume no model is stored.
}
return model.model
}
return {
full: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
{:else}
<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
1 change: 1 addition & 0 deletions plugins/gmail-resources/src/components/NewMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@

<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
1 change: 1 addition & 0 deletions plugins/gmail-resources/src/components/NewMessages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@

<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
4 changes: 2 additions & 2 deletions plugins/guest-resources/src/components/Guest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
.findAllSync<Application>(workbench.class.Application, { hidden: false, _id: { $nin: excludedApps } })

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])
if (app?.locationResolver) {
const resolver = await getResource(app.locationResolver)
Expand Down Expand Up @@ -181,7 +181,7 @@

if (fragment !== currentFragment) {
currentFragment = fragment
if (fragment !== undefined && fragment.trim().length > 0) {
if (fragment != null && fragment.trim().length > 0) {
await setOpenPanelFocus(fragment)
} else {
closePanel()
Expand Down
11 changes: 8 additions & 3 deletions plugins/hr-resources/src/components/ScheduleView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
? getEndDate(currentDate.getFullYear(), 11)
: 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)

const lq = createQuery()
Expand Down Expand Up @@ -79,11 +79,16 @@

function getDescendants (
department: Ref<Department>,
descendants: Map<Ref<Department>, Department[]>
descendants: Map<Ref<Department>, Department[]>,
visited: Set<string>
): Ref<Department>[] {
const res = (descendants.get(department) ?? []).map((p) => p._id)
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
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/love-resources/src/components/Room.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
await tick()
index = participants.findIndex((p) => p._id === participant.identity)
const el = participantElements[index]
if (el !== undefined) {
if (el != null) {
el.appendChild(element)
return
}
Expand Down Expand Up @@ -180,7 +180,7 @@
return
}
const index = participants.findIndex((p) => p._id === participant.identity)
if (index !== -1) {
if (index !== -1 && participantElements[index] != null) {
participantElements[index].setTrackMuted(publication.isMuted)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion plugins/love-resources/src/components/VideoPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
return
}
const index = participants.findIndex((p) => p._id === participant.identity)
if (index !== -1) {
if (index !== -1 && participantElements[index] != null) {
participantElements[index].setTrackMuted(publication.isMuted)
}
} else {
Expand Down
1 change: 1 addition & 0 deletions plugins/love-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ export async function tryConnect (
})
requestsQuery.query(love.class.JoinRequest, { person: (me as PersonAccount).person, _id }, (res) => {
const req = res[0]
if (req === undefined) return
if (req.status === RequestStatus.Pending) return
requestsQuery.unsubscribe()
if (req.status === RequestStatus.Approved) {
Expand Down
1 change: 1 addition & 0 deletions plugins/setting-resources/src/components/EditEnum.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@

<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
1 change: 1 addition & 0 deletions plugins/setting-resources/src/components/EnumValues.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
</div>
<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
11 changes: 6 additions & 5 deletions plugins/tracker-resources/src/components/CreateIssue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@

let currentProject: Project | undefined

let descriptionBox: AttachmentStyledBox | undefined

$: updateIssueStatusId(object, currentProject)
$: updateAssigneeId(object, currentProject)
$: canSave =
descriptionBox != null &&
getTitle(object.title ?? '').length > 0 &&
object.status !== undefined &&
kind !== undefined &&
Expand Down Expand Up @@ -343,8 +346,6 @@
const dispatch = createEventDispatcher()
const spaceQuery = createQuery()

let descriptionBox: AttachmentStyledBox

const key: KeyedAttribute = {
key: 'labels',
attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels')
Expand Down Expand Up @@ -513,7 +514,7 @@
}

await operations.commit()
await descriptionBox.createAttachments(_id)
await descriptionBox?.createAttachments(_id)

const parents: IssueParentInfo[] =
parentIssue != null
Expand Down Expand Up @@ -986,7 +987,7 @@
showPreview
removable
on:remove={(result) => {
if (result.detail !== undefined) descriptionBox.removeAttachmentById(result.detail._id)
if (result.detail !== undefined) descriptionBox?.removeAttachmentById(result.detail._id)
}}
/>
{/each}
Expand All @@ -1000,7 +1001,7 @@
size={'large'}
kind={'ghost'}
on:click={() => {
descriptionBox.handleAttach()
descriptionBox?.handleAttach()
}}
/>
<DocCreateExtComponent manager={docCreateManager} kind={'footer'} space={currentProject} props={extraProps} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<div class="antiNav-subheader">
<input
bind:this={inputFile}
disabled={inputFile == null}
multiple
type="file"
name="file"
Expand Down
4 changes: 2 additions & 2 deletions plugins/workbench-resources/src/components/Workbench.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@

async function resolveShortLink (loc: Location): Promise<ResolvedLocation | undefined> {
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])
if (app?.locationResolver) {
locationResolver = app?.locationResolver
Expand Down Expand Up @@ -391,7 +391,7 @@
currentQuery = loc.query
if (fragment !== currentFragment) {
currentFragment = fragment
if (fragment !== undefined && fragment.trim().length > 0) {
if (fragment != null && fragment.trim().length > 0) {
await setOpenPanelFocus(fragment)
} else {
closePanel()
Expand Down