fix: favorite mutation on quick actions (#6741)
* fix: fav mutation on quick actions * fix: user favorite fetch * fix: exist validation --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
This commit is contained in:
parent
3d14c9d9fe
commit
d2b81ad2da
2 changed files with 19 additions and 1 deletions
|
|
@ -111,11 +111,12 @@ export class FavoriteStore implements IFavoriteStore {
|
|||
* @returns Promise<IFavorite>
|
||||
*/
|
||||
addFavorite = async (workspaceSlug: string, data: Partial<IFavorite>) => {
|
||||
const id = uuidv4();
|
||||
data = { ...data, parent: null, is_folder: data.entity_type === "folder" };
|
||||
|
||||
if (data.entity_identifier && this.entityMap[data.entity_identifier]) return this.entityMap[data.entity_identifier];
|
||||
try {
|
||||
// optimistic addition
|
||||
const id = uuidv4();
|
||||
runInAction(() => {
|
||||
set(this.favoriteMap, [id], data);
|
||||
data.entity_identifier && set(this.entityMap, [data.entity_identifier], data);
|
||||
|
|
@ -271,6 +272,7 @@ export class FavoriteStore implements IFavoriteStore {
|
|||
* @returns Promise<void>
|
||||
*/
|
||||
deleteFavorite = async (workspaceSlug: string, favoriteId: string) => {
|
||||
if (!this.favoriteMap[favoriteId]) return;
|
||||
const parent = this.favoriteMap[favoriteId].parent;
|
||||
const children = this.groupedFavorites[favoriteId].children;
|
||||
const entity_identifier = this.favoriteMap[favoriteId].entity_identifier;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue