Skip to content

Commit 8a88b0b

Browse files
authored
fix: fix wrong api call usage of list resources by tags APIs (#89)
Signed-off-by: Aavash Shrestha <[email protected]>
1 parent 4650178 commit 8a88b0b

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

packages/services/src/lib/browser/browser.svelte.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,21 @@ export class BrowserService {
416416
try {
417417
this.log.debug('Preparing new note view')
418418

419-
const existingResources = await this.resourceManager.listResourcesByTags([
420-
SearchResourceTags.Deleted(false),
421-
SearchResourceTags.ResourceType(ResourceTypes.DOCUMENT_SPACE_NOTE),
422-
SearchResourceTags.PreloadedResource(true)
423-
])
419+
const existingResources = await this.resourceManager.listResourcesByTags(
420+
[
421+
SearchResourceTags.Deleted(false),
422+
SearchResourceTags.ResourceType(ResourceTypes.DOCUMENT_SPACE_NOTE),
423+
SearchResourceTags.PreloadedResource(true)
424+
],
425+
{ limit: 1 }
426+
)
424427

425428
this.log.debug('Found existing preloaded resources:', existingResources)
426429

427430
let resource: ResourceNote | null = null
428431

429-
if (existingResources.length > 0) {
430-
resource = existingResources[0] as ResourceNote
432+
if (existingResources?.items.length > 0) {
433+
resource = existingResources.items[0] as ResourceNote
431434
} else {
432435
resource = await this.resourceManager.createResourceNote(
433436
'',

packages/services/src/lib/notebooks/notebookManager.svelte.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { onMount, tick } from 'svelte'
2-
import { derived, get, writable, type Readable, type Writable } from 'svelte/store'
2+
import { get, writable, type Writable } from 'svelte/store'
33

44
import {
5-
conditionalArrayItem,
65
isDev,
76
useLogScope,
87
EventEmitterBase,
@@ -769,19 +768,16 @@ export class NotebookManager extends EventEmitterBase<NotebookManagerEventHandle
769768
await tick()
770769

771770
const excludeAnnotations = !get(this.config.settings).show_annotations_in_oasis
772-
// const selectedFilterType = get(this.selectedFilterType)
773771

774772
this.log.debug('loading everything', { excludeAnnotations })
775-
const resources = await this.resourceManager.listResourcesByTags(
773+
const resources = await this.resourceManager.listAllResourcesByTags(
776774
[
777775
...SearchResourceTags.NonHiddenDefaultTags({
778776
excludeAnnotations: excludeAnnotations
779777
})
780-
// ...conditionalArrayItem(selectedFilterType !== null, selectedFilterType?.tags ?? []),
781778
],
782779
{
783780
includeAnnotations: true
784-
//excludeWithinSpaces: get(this.selectedNotebook) === 'inbox'
785781
}
786782
)
787783

packages/services/src/lib/resources/resources.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ export class ResourceManager extends EventEmitterBase<ResourceManagerEventHandle
996996
const result = await this.sffs.listResourceIDsByTags(tags, paginationParams, opts?.spaceId)
997997
// TODO: is this the right behavior?
998998
if (!result) {
999-
return []
999+
throw new Error('failed to list resources by tags')
10001000
}
10011001
this.log.debug('found resource ids', result.items)
10021002
const resources = (await Promise.all(

0 commit comments

Comments
 (0)