Skip to content

Commit 6ca9221

Browse files
Merge branch 'feat/tag-crud'
2 parents 464baac + 7d435d4 commit 6ca9221

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/cache-manager.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,12 @@ export class CacheManager {
237237
async getTag(id: number, workspaceId: number): Promise<Tag | null> {
238238
const cached = this.getCached(this.tags, id);
239239
if (cached) return cached;
240-
240+
241241
if (!this.api) return null;
242-
243-
try {
244-
const tag = await this.api.getTag(workspaceId, id);
245-
if (tag) {
246-
this.setCached(this.tags, id, tag);
247-
}
248-
return tag;
249-
} catch (error) {
250-
console.error(`Failed to fetch tag ${id}:`, error);
251-
return null;
252-
}
242+
243+
// Fetch all tags for the workspace (populates cache) and find by ID
244+
const tags = await this.getTags(workspaceId);
245+
return tags.find(t => t.id === id) || null;
253246
}
254247

255248
async getTags(workspaceId: number): Promise<Tag[]> {

src/toggl-api.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ export class TogglAPI {
181181
return this.request<Tag[]>('GET', `/workspaces/${workspaceId}/tags`);
182182
}
183183

184-
async getTag(workspaceId: number, tagId: number): Promise<Tag> {
185-
return this.request<Tag>('GET', `/workspaces/${workspaceId}/tags/${tagId}`);
186-
}
187-
188184
async createTag(workspaceId: number, name: string): Promise<Tag> {
189185
return this.request<Tag>('POST', `/workspaces/${workspaceId}/tags`, { name });
190186
}

0 commit comments

Comments
 (0)