Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-1907] Fix: favorites #5292

Merged
merged 22 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
790e16e
chore: workspace user favorites
NarayanBavisetti Jul 23, 2024
9d1ce25
chore: added project id in entity type
NarayanBavisetti Jul 25, 2024
827e11f
chore: removed the extra key
NarayanBavisetti Jul 25, 2024
9ee459f
chore: removed the project member filter
NarayanBavisetti Jul 26, 2024
1054263
chore: updated the project permission layer
NarayanBavisetti Jul 26, 2024
d8f13b3
chore: updated the workspace group favorite filter
NarayanBavisetti Jul 26, 2024
9454e4d
fix: project favorite toggle
NarayanBavisetti Jul 29, 2024
4077618
chore: Fav feature
gakshita Jul 29, 2024
4e80865
Merge branch 'preview' of https://github.com/makeplane/plane into cho…
gakshita Jul 29, 2024
db9be42
fix: build errors + added navigation
gakshita Jul 29, 2024
44bcec7
fix: added remove entity icon
gakshita Jul 30, 2024
11dcce2
fix: nomenclature
gakshita Jul 30, 2024
049b96e
chore: hard delete favorites
NarayanBavisetti Jul 31, 2024
d51953f
fix: review changes
gakshita Aug 1, 2024
e1400da
Merge branch 'chore/soft-delete-favorite' of https://github.com/makep…
gakshita Aug 1, 2024
eff77c3
fix: added optimistic addition to the store
gakshita Aug 1, 2024
c4f3f9a
chore: user favorite hard delete
NarayanBavisetti Aug 1, 2024
e700071
fix: linting fixed
gakshita Aug 1, 2024
c26c028
Merge branch 'chore/user-favorites' of https://github.com/makeplane/p…
gakshita Aug 1, 2024
477aeb9
fix: favorite bugs
gakshita Aug 3, 2024
fd12f54
fix: ts bugs
gakshita Aug 3, 2024
e55adca
Merge branch 'preview' of https://github.com/makeplane/plane into fix…
gakshita Aug 3, 2024
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
Prev Previous commit
Next Next commit
fix: added optimistic addition to the store
  • Loading branch information
gakshita committed Aug 1, 2024
commit eff77c3bfe0bbc8bb44cbe317ddf1f88a67ab018
1 change: 1 addition & 0 deletions web/core/store/cycle.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ export class CycleStore implements ICycleStore {
entity_type: "cycle",
entity_identifier: cycleId,
project_id: projectId,
entity_data: { name: this.cycleMap[cycleId].name || "" },
});
return response;
} catch (error) {
Expand Down
20 changes: 18 additions & 2 deletions web/core/store/favorite.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { uniqBy } from "lodash";
import set from "lodash/set";
import { action, observable, makeObservable, runInAction } from "mobx";
import { v4 as uuidv4 } from "uuid";
import { IFavorite } from "@plane/types";
import { FavoriteService } from "@/services/favorite";

Expand Down Expand Up @@ -62,16 +63,31 @@ 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" };

try {
data = { ...data, parent: null, is_folder: data.entity_type === "folder" };
// optimistic addition
runInAction(() => {
set(this.favoriteMap, [id], data);
data.entity_identifier && set(this.entityMap, [data.entity_identifier], data);
this.favoriteIds = [id, ...this.favoriteIds];
});
const response = await this.favoriteService.addFavorite(workspaceSlug, data);

// overwrite the temp id
runInAction(() => {
delete this.favoriteMap[id];
set(this.favoriteMap, [response.id], response);
response.entity_identifier && set(this.entityMap, [response.entity_identifier], response);
this.favoriteIds = [response.id, ...this.favoriteIds];
this.favoriteIds = [response.id, ...this.favoriteIds.filter((favId) => favId !== id)];
});
return response;
} catch (error) {
delete this.favoriteMap[id];
data.entity_identifier && delete this.entityMap[data.entity_identifier];
this.favoriteIds = this.favoriteIds.filter((favId) => favId !== id);

console.error("Failed to create favorite from favorite store");
throw error;
}
Expand Down
1 change: 1 addition & 0 deletions web/core/store/module.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export class ModulesStore implements IModuleStore {
entity_type: "module",
entity_identifier: moduleId,
project_id: projectId,
entity_data: { name: this.moduleMap[moduleId].name || "" },
});
} catch (error) {
console.error("Failed to add module to favorites in module store", error);
Expand Down
1 change: 1 addition & 0 deletions web/core/store/pages/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ export class Page implements IPage {
entity_type: "page",
entity_identifier: this.id,
project_id: projectId,
entity_data: { name: this.name || "" },
})
.catch((error) => {
runInAction(() => {
Expand Down
1 change: 1 addition & 0 deletions web/core/store/project-view.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export class ProjectViewStore implements IProjectViewStore {
entity_type: "view",
entity_identifier: viewId,
project_id: projectId,
entity_data: { name: this.viewMap[viewId].name || "" },
});
} catch (error) {
console.error("Failed to add view to favorites in view store", error);
Expand Down
1 change: 1 addition & 0 deletions web/core/store/project/project.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export class ProjectStore implements IProjectStore {
entity_type: "project",
entity_identifier: projectId,
project_id: projectId,
entity_data: { name: this.projectMap[projectId].name || "" },
});
return response;
} catch (error) {
Expand Down
Loading