os-js / osjs-widgets

OS.js Widgets Module
https://manual.os-js.org/v3/
2 stars 4 forks source link

rendering tick bug #3

Closed msjavan closed 4 years ago

msjavan commented 4 years ago

In the custom widget example, fps event keep working, even after removing the widget, until the next desktop reload.

andersevenrud commented 4 years ago

Looking at the code it seems like this is the case. The animator needs to have a condition to abort when widget destroy method is called.

andersevenrud commented 4 years ago

Fix incoming: https://github.com/os-js/osjs-widgets/pull/4

andersevenrud commented 4 years ago

I've just published @osjs/widgets@3.0.2 that should fix this issue.

Let me know how it works out and close this issue :)

msjavan commented 4 years ago

I cloned the "3.0.2" > run "npm install" > change the dependency in src/client/index.js but still not solved for existing widgets.

andersevenrud commented 4 years ago

Can you share this setup ?

Also, did you rebuild afterwards ?

I'm also interested in how you reproduce this error.

msjavan commented 4 years ago

My mistake! I forget to change dependency in MyWidget.js too. So I change it to: import {Widget} from '../osjs-widgets/index.js'; now got following error in the client side:

Uncaught TypeError: Class constructor Widget cannot be invoked without 'new' at new MyWidget (MyWidget.js:15) at Object.create (provider.js:82) at Object.onclick (provider.js:130) at Object.onclick [as click] (Menu.js:90) at HTMLDivElement.g (index.js:156)

you can see this by adding chart1 in my deployment

andersevenrud commented 4 years ago

There's something wrong with your import statement most likely.

andersevenrud commented 4 years ago

Also, you can just use the npm version -- you don't need to clone anything.

msjavan commented 4 years ago

This problem still not solved, which one is correct for import:

import Widget from '../osjs-widgets/index.js'; or import {Widget} from '../osjs-widgets/index.js';

the former occurs following error:

TypeError: Super expression must either be null or a function inherits.js:5 _inherits inherits.js:5 MyWidget osjs.js:200 js MyWidget.js:12 Webpack 6 webpack_require js webpack_require checkDeferredModules

but the latter occurs following error: Uncaught TypeError: Class constructor Widget cannot be invoked without 'new' at new MyWidget (MyWidget.js:15) at Object.create (provider.js:82) at Object.onclick (provider.js:130) at Object.onclick [as click] (Menu.js:90) at HTMLDivElement.g (index.js:156)
andersevenrud commented 4 years ago

The correct usage with the official package is import {Widget} from ....

If you maybe could share your files here https://gist.github.com/ ?

msjavan commented 4 years ago

Here it is

https://gist.github.com/msjavan/c872f10687278f99b62c85723d7a9e2a

andersevenrud commented 4 years ago

And the contents of ../osjs-widgets/index.js is the actual osjs-widgets repo ?

msjavan commented 4 years ago

import './index.scss'; import WidgetServiceProvider from './src/provider'; import Widget from './src/widget'; import DigitalClockWidget from './src/items/digitalclock';

export { WidgetServiceProvider, Widget, DigitalClockWidget };

andersevenrud commented 4 years ago

Looks OK. What happens if you remove the index.js part of the path so that it loads the pre-compiled version instead ?

msjavan commented 4 years ago

import Widget from '../osjs-widgets';

. . .

Uncaught TypeError: Class constructor Widget cannot be invoked without 'new' at new MyWidget (MyWidget.js:15) at Object.create (provider.js:82) at Object.onclick (provider.js:130) at Object.onclick [as click] (Menu.js:90) at HTMLDivElement.g (index.js:156)

andersevenrud commented 4 years ago

You have to do import {Widget} from '../osjs-widgets';

The curly braces must be used when export is used (and not export default) .

msjavan commented 4 years ago

sorry, It already was {Widget}, I wrote it above by mistake.

andersevenrud commented 4 years ago

Can you paste the latest error message and update the gist ? Because line numbers no longer match up.

msjavan commented 4 years ago

I update the gist, It seems that its working !

msjavan commented 4 years ago

I think the problem was I didn't rpm run build @ osjs-widget, I did run "npm install" before

msjavan commented 4 years ago

and "rendering tick bug" is resolved !

andersevenrud commented 4 years ago

Great!