Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/extensions/scratch3_mesh_v2/gql-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const JOIN_GROUP = gql`
name
groupId
domain
expiresAt
heartbeatIntervalSeconds
}
}
Expand Down
40 changes: 40 additions & 0 deletions src/extensions/scratch3_mesh_v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ class Scratch3MeshV2Blocks {
return !!(this.meshService && this.meshService.groupId);
}

formatExpiresAt (expiresAt) {
if (!expiresAt) return '';
const date = new Date(expiresAt);
const h = String(date.getHours()).padStart(2, '0');
const m = String(date.getMinutes()).padStart(2, '0');
return `${h}:${m}`;
}

/* istanbul ignore next */
connectedMessage () {
if (this.meshService && this.meshService.groupId) {
Expand Down Expand Up @@ -326,6 +334,38 @@ class Scratch3MeshV2Blocks {
});
}

/* istanbul ignore next */
menuMessage () {
if (this.meshService && this.meshService.groupId) {
const meshIdLabel = this.makeMeshIdLabel(this.meshService.groupName);
const expiresAt = this.formatExpiresAt(this.meshService.expiresAt);

if (this.meshService.isHost) {
return formatMessage({
id: 'mesh.registeredHostMenu',
default: '{ MESH_ID } ({ EXPIRES_AT })',
description: 'concise label for registered Host Mesh in menu bar'
}, {
MESH_ID: meshIdLabel,
EXPIRES_AT: expiresAt
});
}
return formatMessage({
id: 'mesh.joinedMeshMenu',
default: '{ MESH_ID } ({ EXPIRES_AT })',
description: 'concise label for joined Mesh in menu bar'
}, {
MESH_ID: meshIdLabel,
EXPIRES_AT: expiresAt
});
}
return formatMessage({
id: 'mesh.notConnectedMenu',
default: 'Not connected',
description: 'concise label for not connected in menu bar'
});
}

// HOC logic
/* istanbul ignore next */
setOpcodeFunctionHOC () {
Expand Down
Loading