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

Convert starredProjects to star #346

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 9 additions & 6 deletions apps/new/widget/components/project/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,18 @@ const ProjectCard = ({ data, showEditProjectAction }) => {
location,
} = data;

const item = {
type: "social",
path: `${accountId}/project/${projectID}`,
};

return (
<Link
href={href({
widgetSrc: `${config_account}/widget/Index`,
params: {
page: "project",
id: `${accountId}/project/${projectID}`,
id: item.path,
tab: "overview",
},
})}
Expand Down Expand Up @@ -167,7 +172,7 @@ const ProjectCard = ({ data, showEditProjectAction }) => {
params: {
page: "projects",
tab: "editor",
id: `${accountId}/project/${projectID}`,
id: item.path,
},
})}
type="icon"
Expand All @@ -181,10 +186,8 @@ const ProjectCard = ({ data, showEditProjectAction }) => {
src="${config_account}/widget/components.project.StarProject"
loading=""
props={{
item: {
type: "social",
path: `${accountId}/project/${projectID}`,
},
item: item,
notifyAccountId: accountId,
}}
/>
</div>
Expand Down
15 changes: 9 additions & 6 deletions apps/new/widget/components/project/ListCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,18 @@ const ListCard = ({ data, showEditProjectAction }) => {
location,
} = data;

const item = {
type: "social",
path: `${accountId}/project/${projectID}`,
};

return (
<Link
href={href({
widgetSrc: `${config_account}/widget/Index`,
params: {
page: "project",
id: `${accountId}/project/${projectID}`,
id: item.path,
tab: "overview",
},
})}
Expand Down Expand Up @@ -178,7 +183,7 @@ const ListCard = ({ data, showEditProjectAction }) => {
params: {
page: "projects",
tab: "editor",
id: `${accountId}/project/${projectID}`,
id: item.path,
},
})}
type="icon"
Expand All @@ -192,10 +197,8 @@ const ListCard = ({ data, showEditProjectAction }) => {
src="${config_account}/widget/components.project.StarProject"
loading=""
props={{
item: {
type: "social",
path: `${accountId}/project/${projectID}`,
},
item: item,
notifyAccountId: accountId,
}}
/>
</div>
Expand Down
8 changes: 4 additions & 4 deletions apps/new/widget/components/project/StarProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ useEffect(() => {
State.update({ hasStar: null });
}, [item]);

const stars = Social.index("starredProjects", item);
const stars = Social.index("star", item);
const dataLoading = stars === null;

const starsByUsers = {};
Expand Down Expand Up @@ -48,7 +48,7 @@ const starClick = (event) => {
const type = hasStar ? "unstar" : "star";
const data = {
index: {
starredProjects: JSON.stringify({
star: JSON.stringify({
key: item,
value: {
type,
Expand All @@ -61,9 +61,9 @@ const starClick = (event) => {
const keys = item.path.split("/");
if (keys.length > 0) {
data.graph = {
starredProjects: {},
star: {},
};
let root = data.graph.starredProjects;
let root = data.graph.star;
keys.slice(0, -1).forEach((key) => {
root = root[key] = {};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/new/widget/page/projects/Watchlist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (!fetchProjects) {
return "";
}
const stars = Social.getr(
`${context.accountId}/graph/starredProjects`,
`${context.accountId}/graph/star/*/project`,
"final",
{
withBlockHeight: true,
Expand Down
Loading