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

fix(admin): Fixed updating plugins #6705

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Conversation

SamTV12345
Copy link
Member

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.

@@ -111,6 +111,7 @@ export const HomePage = () => {

// check for updates every 5mins
const interval = setInterval(() => {
console.log("Checking for updates")
Copy link
Member

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?

@@ -159,6 +160,9 @@ export const HomePage = () => {
})
}, 500, [searchTerm])


console.log("Installed plugins", installedPlugins)
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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.

@SamTV12345 SamTV12345 merged commit 0b26405 into develop Oct 10, 2024
33 of 36 checks passed
@SamTV12345 SamTV12345 deleted the fix/updating-plugins branch October 10, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants