Implement on_document_changed action
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'event_action'
|
||||
require_relative 'on_document_changed'
|
||||
require_relative '../load_sketchup_model'
|
||||
require_relative '../collect_preferences'
|
||||
|
||||
@@ -25,7 +26,8 @@ module SpeckleConnector
|
||||
# Action to let UI to render itself with new preferences state
|
||||
# TODO: Later UI should be updated if any stream is invalid after
|
||||
# we collected speckle_entities appropriately
|
||||
CollectPreferences.update_state(new_state, {})
|
||||
# new_state = CollectPreferences.update_state(new_state, nil, {})
|
||||
OnDocumentChanged.update_state(new_state)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SpeckleConnector
|
||||
module Actions
|
||||
# Triggers whenever document has changed.
|
||||
class OnDocumentChanged < Action
|
||||
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
|
||||
# @return [States::State] the new updated state object
|
||||
def self.update_state(state)
|
||||
document_info = {
|
||||
location: state.sketchup_state.sketchup_model.path,
|
||||
name: state.sketchup_state.sketchup_model.name,
|
||||
id: state.sketchup_state.sketchup_model.guid
|
||||
}
|
||||
js_command = "baseBinding.emit('documentChanged', #{JSON.unparse(document_info.to_json)})"
|
||||
state.with_add_queue_js_command('getDocumentInfo', js_command)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user