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

[3851] - Implement move, connect, disconnect, value-update, delete changes #3960

Merged
merged 40 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
72097b8
fixes #3913
walterbender Jun 23, 2024
200dddb
fix:resolves grid position on hamburger opening(#3914) (#3924)
BeNikk Jun 28, 2024
71fe874
Merge branch 'master' into collaboration
apsinghdev Jul 1, 2024
423b467
Fix input boxes (#3927)
apsinghdev Jul 2, 2024
0d082eb
bump version
walterbender Jul 2, 2024
eb7c23a
enhancement: scale on hover (#3926)
Anas-2357 Jul 2, 2024
6354fa8
calculate frequencies from ratio
walterbender Jul 2, 2024
474f811
Merge branch 'master' of github.com:sugarlabs/musicblocks
walterbender Jul 2, 2024
ad292d9
Merge branch 'master' into collaboration
apsinghdev Jul 3, 2024
5848e62
Add close button to extended-menu pie menu (fixes #3933) (#3934)
BeNikk Jul 3, 2024
10ab05e
Bump braces and gulp (#3903)
dependabot[bot] Jul 3, 2024
5e27904
add support for solfege accidentals in phrasemaker
walterbender Jul 4, 2024
3c57c4b
Merge branch 'master' of github.com:sugarlabs/musicblocks
walterbender Jul 4, 2024
530f330
Merge branch 'collaboration' of https://github.com/sugarlabs/musicblo…
apsinghdev Jul 4, 2024
f73597e
Merge branch 'master' into collaboration
apsinghdev Jul 4, 2024
5022721
Merge branch 'collaboration' of https://github.com/sugarlabs/musicblo…
apsinghdev Jul 7, 2024
55570e8
Add support for cents (#3937)
walterbender Jul 7, 2024
f88955e
Ratio transpose and Ratio interval (#3936)
walterbender Jul 7, 2024
97e811a
fix note convert
walterbender Jul 7, 2024
cba02d3
remove extra comma throwing off indexing
walterbender Jul 7, 2024
306888e
Merge branch 'master' into collaboration
apsinghdev Jul 9, 2024
2d99514
Merge branch 'collaboration' of https://github.com/sugarlabs/musicblo…
apsinghdev Jul 10, 2024
944bc2e
Hyperscore link update (#3939) (#3947)
therealharshit Jul 12, 2024
aaf0f6e
Update Hyperscore example link in guide.html (#3944)
GeetenParab Jul 12, 2024
c41d9f5
Update README.md (#3943)
akilesh1706 Jul 12, 2024
69f8ee8
left_and_back_images (#3950)
khadar1020 Jul 15, 2024
472ec5c
Updated Dockerfile (#3949)
akilesh1706 Jul 15, 2024
cc0b986
Merge branch 'master' into collaboration
apsinghdev Jul 16, 2024
08787e1
remove yjs and socket.io dependecies
apsinghdev Jul 16, 2024
8776750
Fixed #3956 Auto increasing and decreasing input block (#3957)
therealharshit Jul 25, 2024
6436c2f
fixes #3941
walterbender Jul 26, 2024
3b63768
Merge branch 'master' of github.com:sugarlabs/musicblocks
walterbender Jul 26, 2024
c415d53
fixes #3958
walterbender Jul 26, 2024
cc4bcef
Merge branch 'master' into collaboration
apsinghdev Jul 27, 2024
3acc0b5
Merge branch 'collaboration' of https://github.com/sugarlabs/musicblo…
apsinghdev Jul 27, 2024
a61123d
Add connect, disconnect, move, delete, update functionality
apsinghdev Jul 27, 2024
07f9707
Fixes collapsed state of note block (#3961)
therealharshit Jul 28, 2024
fd39015
Merge branch 'master' into collaboration
apsinghdev Jul 28, 2024
1d583cf
Merge branch 'collaboration' into Feat/Add-all-changes
apsinghdev Jul 28, 2024
7b338e7
Define constants for emit events
apsinghdev Jul 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions js/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ const PIEMENUS = [
"wrapmode"
];

// Event for updating the value of a block
const EMIT_BLOCK_VALUE_UPDATED = "block-value-updated";

/**
* Async function to create bitmap from SVG data.
* @param {string} data - SVG data.
Expand Down Expand Up @@ -4070,6 +4073,13 @@ class Block {
focused = true;
}, 100);
}
setTimeout(() => {
if (this.activity.collaboration.hasCollaborationStarted) {
if (this.blocks.isLocalUpdate) {
this.blocks.emitChanges(EMIT_BLOCK_VALUE_UPDATED);
};
};
}, 3000);
}

/**
Expand Down
38 changes: 32 additions & 6 deletions js/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,21 @@ class Blocks {

this.selectedBlocks = [];

// Flag to know if the block added is local
this.isLocalUpdate = false;

// Event for adding a new block
const EMIT_NEW_BLOCK_ADDED = "new-block-added";

// Event for moving connecting and disconnecting a block
const EMIT_BLOCK_MOVED_CONNECTED_DISCONNECTED = "block-moved/connected/disconnected";

// Event for deleting a new block
const EMIT_NEW_BLOCK_DELETED = "new-block-deleted";

// Flag to avoid emitting move changes if a block is added
this.hasEmittedBlockAddition = false;

/**
* We stage deletion of prototype action blocks on the palette so
* as to avoid palette refresh race conditions.
Expand Down Expand Up @@ -2146,6 +2159,12 @@ class Blocks {
this.isBlockMoving = false;
this.adjustExpandableClampBlock();
this.activity.refreshCanvas();

if (this.activity.collaboration.hasCollaborationStarted) {
if (!this.hasEmittedBlockAddition) {
this.emitChanges(EMIT_BLOCK_MOVED_CONNECTED_DISCONNECTED);
}
}
};

/**
Expand Down Expand Up @@ -3068,12 +3087,13 @@ class Blocks {
this.visible = true;
};

// Emit a message when a new block is created
this.emitAddedBlock = () => {
if (this.activity.collaboration.hasCollaborationStarted) {
const update = this.activity.collaboration.convertBlockListToHtml();
this.activity.collaboration.socket.emit("new-block-added", update);
// Emit a message when there is a change in the blocks of the project
this.emitChanges = (emitMsg) => {
if (emitMsg == EMIT_NEW_BLOCK_ADDED) {
this.hasEmittedBlockAddition = true;
}
const update = this.activity.collaboration.convertBlockListToHtml();
this.activity.collaboration.socket.emit(emitMsg, update);
};

/**
Expand Down Expand Up @@ -3183,7 +3203,8 @@ class Blocks {
if (this.activity.collaboration.hasCollaborationStarted) {
if (this.isLocalUpdate) {
setTimeout(() => {
this.emitAddedBlock();
this.emitChanges(EMIT_NEW_BLOCK_ADDED);
this.hasEmittedBlockAddition = false;
}, 200);
};
};
Expand Down Expand Up @@ -6938,6 +6959,11 @@ class Blocks {
this.activity.refreshCanvas();
this.activity.trashcan.stopHighlightAnimation();
document.getElementById("hideContents").click();

// Emit an event indicating a block a deleted
if (this.activity.collaboration.hasCollaborationStarted) {
this.emitChanges(EMIT_NEW_BLOCK_DELETED);
};
};

/***
Expand Down
14 changes: 14 additions & 0 deletions js/collaboration/collaboration.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ class Collaboration {
setTimeout(this.activity.hideMsgs, 10000);
this.activity.renderProjectFromData(update);
});

socket.on("new-block-deleted", (update) => {
this.activity.textMsg("New block deleted. rendering...");
setTimeout(this.activity.hideMsgs, 10000);
this.activity.renderProjectFromData(update);
});

socket.on("block-moved/connected/disconnected", (update) => {
this.activity.renderProjectFromData(update);
});

socket.on("block-value-updated", (update) => {
this.activity.renderProjectFromData(update);
});
};

// Start the collaboration
Expand Down
2 changes: 1 addition & 1 deletion js/protoblocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ProtoBlock {
if (this.fontsize) {
svg.setFontSize(this.fontsize);
}
svg.setExpand(30 + this.extraWidth, 0, 0, 0);
svg.setExpand(10 + this.extraWidth, 0, 0, 0);
return [
svg.basicBlock(),
svg.docks,
Expand Down