-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
fix(admin): Fixed updating plugins #6705
Conversation
admin/src/pages/HomePage.tsx
Outdated
@@ -111,6 +111,7 @@ export const HomePage = () => { | |||
|
|||
// check for updates every 5mins | |||
const interval = setInterval(() => { | |||
console.log("Checking for updates") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for Debugging, right? Maybe remove?
admin/src/pages/HomePage.tsx
Outdated
@@ -159,6 +160,9 @@ export const HomePage = () => { | |||
}) | |||
}, 500, [searchTerm]) | |||
|
|||
|
|||
console.log("Installed plugins", installedPlugins) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same Here. Only for Debugging?
import {IconButton} from "../components/IconButton.tsx"; | ||
import {determineSorting} from "../utils/sorting.ts"; | ||
|
||
|
||
export const HomePage = () => { | ||
const pluginsSocket = useStore(state=>state.pluginsSocket) | ||
const [plugins,setPlugins] = useState<PluginDef[]>([]) | ||
const [installedPlugins, setInstalledPlugins] = useState<InstalledPlugin[]>([]) | ||
const installedPlugins = useStore(state=>state.installedPlugins) | ||
const setInstalledPlugins = useStore(state=>state.setInstalledPlugins) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you know what you do here, but can you explain why it is needed to have installedPlugins and setInstalledPlugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. So I had it fixed that the plugins are updated but somehow everytime I visited the page it showed for an instant the list of installed plugins and then it disappeared. The problem is that the useEffect does not contain the installedPlugins in its dependency array. That way the useEffect always contained an empty list of installed plugins. You could fix that by adding installedPlugins into the dependency array but that would cause a circle. The installedPlugins will be updated but the installedPlugins cause another rerender. Later in the code there is this useStore().getState() call which extracts the current installedPlugins from the store. This does not cause a rerender because we simply call a function that returns a value. That way I broke the cycle and the installedPlugins are correctly displayed with their updatable state.
2e6743e
to
f1f17b8
Compare
This pull request addresses the issue that plugins can't be updated. This is because at first the setInterval function is not triggered resulting in nothing happening. You'd have to wait 60 minutes until the update button is shown.