Skip to content

Commit

Permalink
After the star button is clicked, it must be refreshed to display the…
Browse files Browse the repository at this point in the history
… image
  • Loading branch information
Xsy41 committed Sep 20, 2024
1 parent c26a5f7 commit d42d450
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/pages/ContentScripts/features/repo-star-tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,29 @@ const init = async (): Promise<void> => {
// <div data-view-component="true" class="unstarred BtnGroup ml-0 flex-1">
// No matter the repo is starred or not, the two button are always there
// So we need to filter the visible one
const $starButton = $(starButtonSelector).filter(function () {
if ($(this).parent().parent().css('display') !== 'none') {
return true;
} else {
return false;
}

// 选择所有的star按钮,不再进行过滤
const $starButtons = $(starButtonSelector);
// console.log($starButtons);
// const $starButton = $(starButtonSelector).filter(function () {
// if ($(this).parent().parent().css('display') !== 'none') {
// return true;
// } else {
// return false;
// }
// });
// console.log($starButton);
// 为每个按钮渲染 NativePopover
$starButtons.each(function () {
console.log('Rendering popover for button:', $(this));
const placeholderElement = $('<div class="NativePopover" />').appendTo('body')[0];
render(
<NativePopover anchor={$(this)} width={280} arrowPosition="top-middle">
<View stars={stars} meta={meta} />
</NativePopover>,
placeholderElement
);
});
const placeholderElement = $('<div class="NativePopover" />').appendTo('body')[0];
render(
<NativePopover anchor={$starButton} width={280} arrowPosition="top-middle">
<View stars={stars} meta={meta} />
</NativePopover>,
placeholderElement
);
};

const restore = async () => {};
Expand Down

0 comments on commit d42d450

Please sign in to comment.