Skip to content

Commit

Permalink
Properly link existing lists
Browse files Browse the repository at this point in the history
  • Loading branch information
kristojorg committed Jan 13, 2025
1 parent 6395764 commit 87e6ae4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/AtpAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ const setupLists = (
}
const { description, name } = def.locales[0]
const existingList = lists.find((l) => l.name === name)
if (existingList) return
if (existingList) {
const uri = Schema.decodeUnknownSync(AtUriSchema)(existingList.uri)
yield* setList(label, uri)
yield* Effect.log(`Existing list linked for label: ${label}`)
return
}

// create a list if there is none
const record: AppBskyGraphList.Record = {
Expand Down Expand Up @@ -161,7 +166,7 @@ const setupLists = (
"LabelNotFound",
(e) =>
Effect.logWarning(
`Skipping list creation for label: ${e.labelValue}`,
`Label "${e.labelValue}" not found, skipping list creation.`,
),
),
Effect.catchAll((e) => Effect.logError("Failed to create list", e)),
Expand Down
2 changes: 1 addition & 1 deletion src/Cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Cursor extends Effect.Service<Cursor>()("Cursor ", {

const initialValue = yield* fs.readFileString(labelerCursorFilepath).pipe(
Effect.flatMap(decodeCursor),
Effect.tap((cursor) => Effect.log("Loaded cursor from file: ", cursor)),
Effect.tap((cursor) => Effect.log(`Loaded cursor from file: ${cursor}`)),
Effect.catchTag("SystemError", noFileFallback),
)

Expand Down

0 comments on commit 87e6ae4

Please sign in to comment.