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

Cannot reset the forfeit of a parent match #129

Closed
Drarig29 opened this issue Mar 31, 2022 · 7 comments
Closed

Cannot reset the forfeit of a parent match #129

Drarig29 opened this issue Mar 31, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@Drarig29
Copy link
Owner

Linked to: #128 (comment)

If we set a forfeit for a parent match directly (not for its child games), for example because we know an opponent forfeited before the beginning of the parent match, we can't reset the parent match results with manager.reset.matchResults().

We get this error:

The parent match is controlled by its child games and its result cannot be reset.

@Drarig29 Drarig29 added the bug Something isn't working label Mar 31, 2022
@yongshun950824
Copy link

yongshun950824 commented Apr 4, 2022

I fetched the latest version with includes this fix, and use npm with webpack to build the js file. I review the whole generated js, but weird that it was generated twice with different version.

Part 1

image

Part 2

image

While I try to reset the match result (match with child match game), it hits the error as the Part 2 (image) and gets the error:

The parent match is controlled by its child games and its result cannot be reset.

I searched the error message in the GitHub repository only and come out this result

  1. reset.ts (Latest change)
  2. update.spec.ts

I tried to uninstall and install again, but still encounter the same issue as above.

I think this "issue" doesn't come from the library but would like to ask to have any clue about it?

@yongshun950824
Copy link

yongshun950824 commented Apr 4, 2022

Okay, after a few time trial & error, I realize that the Part 2 is from bracket-viewer.js

https://github.com/Drarig29/brackets-viewer.js/blob/75d13bb2ded458c86957e9dabcfb283764f6177e/dist/brackets-viewer.min.js

You can search this sentence:

The parent match is controlled by its child games and its result cannot be reset.

from the file link above.

As I import both libraries in a JS file, so both functions conflicted.

import 'brackets-viewer/dist/brackets-viewer.min.js';
import 'brackets-manager/dist/manager';

@Drarig29
Copy link
Owner Author

Drarig29 commented Apr 4, 2022

I'm not sure about it, but it may be because brackets-memory-db has this peerDependency:

https://github.com/Drarig29/brackets-storage/blob/7612bdecbf2771efb131b72cc806ddb533f46d34/brackets-memory-db/package.json#L37-L39

I don't know if:

  1. Webpack bundles peerDependencies (but given your problem, maybe it does)
  2. Webpack always does it or only does it when there is at least a different minor in the version (now, the manager is in the 1.4.x minor, whereas this peerDependency requests the 1.3.x minor)

Could you investigate a bit about this?

@Drarig29
Copy link
Owner Author

Drarig29 commented Apr 4, 2022

As I import both libraries in a JS file, so both functions conflicted.

import 'brackets-viewer/dist/brackets-viewer.min.js';
import 'brackets-manager/dist/manager';

Oh nice! Thanks. I'll update this file, it's weird that it didn't get updated already.

@yongshun950824
Copy link

yongshun950824 commented Apr 4, 2022

Okay thanks for the update. Anyway would like to ask is it safe to use

import 'brackets-viewer/dist/brackets-viewer.min.js';
import 'brackets-manager/dist/manager';

without alias?

Or I should enforce the practice to import library as alias?

But import with alias look like not working as below

First way:

import * as viewer from 'brackets-viewer/dist/brackets-viewer.min.js';

console.log(viewer); // null

Second way:

import { BracketsViewer } from 'brackets-viewer/dist/brackets-viewer.min.js';

console.log(BracketsViewer); // null

@Drarig29
Copy link
Owner Author

Drarig29 commented Apr 4, 2022

Yes it's safe to use without alias and that's actually the only thing you can do until Drarig29/brackets-viewer.js#27 is fixed.

@Drarig29
Copy link
Owner Author

Drarig29 commented Apr 4, 2022

By the way, why do you use import 'brackets-manager/dist/manager'? Can't you use the manager exported by the viewer?

It is accessible via the window object: window.bracketsManager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants