From d6cf863db12cf58dc02a9d11509b371eb51371ed Mon Sep 17 00:00:00 2001 From: tobias <thinkdifferent055@gmail.com> Date: Thu, 12 Oct 2023 22:41:16 +0200 Subject: [PATCH] #195 - Fetch current page on initial connection --- main.js | 4 +++- receive/current_page_request.js | 11 +++++++++++ receive/project_update.js | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 receive/current_page_request.js diff --git a/main.js b/main.js index 6d65601..349c1bc 100644 --- a/main.js +++ b/main.js @@ -8,6 +8,7 @@ const Project = require("./project"); const PadNameUpdate = require("./receive/pad_name_update"); const PadStatusUpdate = require("./receive/pad_status_update"); const CurrentPageUpdate = require("./receive/current_page_update"); +const CurrentPageRequest = require("./receive/current_page_request"); const uuid = require('uuid'); const presets = require('./presets'); @@ -20,7 +21,8 @@ class ModuleInstance extends InstanceBase { 'project-current': new ProjectUpdate(), 'pad-name-changed': new PadNameUpdate(), 'pad-status-changed': new PadStatusUpdate(), - 'current-page-changed': new CurrentPageUpdate() + 'current-page-changed': new CurrentPageUpdate(), + 'current-page-request': new CurrentPageRequest() }; currentProject = new Project({}); diff --git a/receive/current_page_request.js b/receive/current_page_request.js new file mode 100644 index 0000000..e8a3a58 --- /dev/null +++ b/receive/current_page_request.js @@ -0,0 +1,11 @@ +const MessageExecutable = require("./message_executable"); + +module.exports = class CurrentPageRequest extends MessageExecutable { + + handleMessage(plugin, message) { + plugin.currentProject.updateCurrentPage(message.page); + plugin.checkFeedbacks(); + + plugin.updateVariablesForCurrentPage(); + } +} \ No newline at end of file diff --git a/receive/project_update.js b/receive/project_update.js index 18518f6..167f605 100644 --- a/receive/project_update.js +++ b/receive/project_update.js @@ -5,6 +5,8 @@ module.exports = class ProjectUpdate extends MessageExecutable { handleMessage(plugin, message) { plugin.currentProject = new Project(message) + plugin.sendToWebSocket('current-page-request', {}); + plugin.checkFeedbacks(); plugin.updateVariables() -- GitLab