Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions apps/web/core/services/sticky.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class StickyService extends APIService {
}

async getSticky(workspaceSlug: string, id: string) {
return this.get(`/api/workspaces/${workspaceSlug}/stickies/${id}`)
return this.get(`/api/workspaces/${workspaceSlug}/stickies/${id}/`)
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
Expand All @@ -59,7 +59,7 @@ export class StickyService extends APIService {
}

async deleteSticky(workspaceSlug: string, id: string) {
return await this.delete(`/api/workspaces/${workspaceSlug}/stickies/${id}`)
return await this.delete(`/api/workspaces/${workspaceSlug}/stickies/${id}/`)
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
Expand Down
12 changes: 9 additions & 3 deletions apps/web/core/store/sticky/sticky.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,16 @@ export class StickyStore implements IStickyStore {
} catch (error) {
console.error("Error in updating sticky:", error);
this.stickies[id] = sticky;
throw new Error();
throw error;
}
};

deleteSticky = async (workspaceSlug: string, id: string) => {
const sticky = this.stickies[id];
if (!sticky) return;
const previousWorkspaceStickies = [...(this.workspaceStickies[workspaceSlug] || [])];
const previousActiveStickyId = this.activeStickyId;
const previousRecentStickyId = this.recentStickyId;
try {
this.workspaceStickies[workspaceSlug] = this.workspaceStickies[workspaceSlug].filter(
(stickyId) => stickyId !== id
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Expand All @@ -220,9 +223,12 @@ export class StickyStore implements IStickyStore {
delete this.stickies[id];
this.recentStickyId = this.workspaceStickies[workspaceSlug][0];
await this.stickyService.deleteSticky(workspaceSlug, id);
} catch (e) {
console.log(e);
} catch (error) {
this.stickies[id] = sticky;
this.workspaceStickies[workspaceSlug] = previousWorkspaceStickies;
this.activeStickyId = previousActiveStickyId;
this.recentStickyId = previousRecentStickyId;
throw error;
}
};

Expand Down