Skip to content

Commit

Permalink
fix webpage data update
Browse files Browse the repository at this point in the history
  • Loading branch information
soyaine committed Dec 26, 2022
1 parent fcfa022 commit 2483cf4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build/jocker.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
}

.intro-start {
width: 7em;
width: 10em;
padding: 5px 8px;
margin: 24px auto;
cursor: pointer;
Expand Down
50 changes: 6 additions & 44 deletions build/jocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,44 +90,6 @@ function JockerCache() {
this.addApolloData = function (apollo) {
// console.log("apollo", apollo);
this._user_id = apollo["$ROOT_QUERY.profile"]["username"];
let nodes = apollo[`$User:${this._user_id}.feeds({})`]["nodes"];

nodes = nodes.map(function (node) {
const post = apollo[node.id];
const needRenderProps = ["topic", "linkInfo"];
needRenderProps.forEach(function (key) {
if (post[key]) {
post[key] = apollo[post[key]["id"]];
}
});
if (post["pictures"]) {
post["pictures"] = post["pictures"].map(function (pic) {
return apollo[pic["id"]];
});
}
if (post["video"]) {
const pid = post["id"];
const ptype = post["type"];
const query = `$ROOT_QUERY.mediaMetaPlay({"messageId":"${pid}","messageType":"${ptype}"})`
post["video"] = apollo[query]["url"]
}
if (post["target"]) {
const targetPost = apollo[post["target"]["id"]]
if (targetPost["user"] && targetPost["user"]["id"]) {
targetPost["user"] = apollo[targetPost["user"]["id"]]
}
post["target"] = targetPost
}

return post;
});
this.addPosts(nodes);

const pageInfo = apollo[`$User:${this._user_id}.feeds({}).pageInfo`];
const lastId = pageInfo["loadMoreKey"] && pageInfo["loadMoreKey"]["json"] && pageInfo["loadMoreKey"]["json"]["lastId"] || ''

console.log("pageInfo", pageInfo);
this.updatePageInfo(pageInfo["hasNextPage"], lastId);
};

this.updatePageInfo = function (hasNext, lastId) {
Expand All @@ -149,6 +111,11 @@ function JockerCache() {
},
};
};
this.getFirstVariables = function () {
return {
username: this._user_id,
}
}
this.getPostsInTopic = function (topicId) {
let nodes;
if (topicId === "所有动态") {
Expand Down Expand Up @@ -814,12 +781,7 @@ function startJocker(e) {
console.log("jocker.js get chrome storage");
let apollo = data.firstPagePost.props.pageProps.apolloState.data;
jocker.addApolloData(apollo);
if (jocker.hasNextPage) {
fetchPost(jocker.getQueryVariables());
} else {
stopLoading();
reloadTopics();
}
fetchPost(jocker.getFirstVariables());
});
}

Expand Down
2 changes: 1 addition & 1 deletion build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Jocker Extension",
"description": "Jike Web Tool",
"version": "3.0.0",
"version": "3.0.1",
"manifest_version": 3,
"icons": {
"256": "icon256.png"
Expand Down

0 comments on commit 2483cf4

Please sign in to comment.