lib/atome/kernel/universe.rb in atome-0.5.6.5.1 vs lib/atome/kernel/universe.rb in atome-0.5.6.5.4

- old
+ new

@@ -9,22 +9,24 @@ @particle_list = {} @renderer_list = %i[html browser headless server log] @sanitizers = {} @specificities = {} @messages = {} - @increment=0 + @increment = 0 @categories = %w[atome communication effect event geometry hierarchy identity material property security spatial time utility ] @history = {} @users = {} @help = {} @example = {} - @allow_history= false + @allow_history = false + @database_ready = false # @historicize=false class << self - attr_reader :atomes,:atomes_ids, :renderer_list, :atome_list, :particle_list, :classes, :counter, :atomes_specificities - attr_accessor :allow_history + attr_reader :atomes, :atomes_ids, :renderer_list, :atome_list, :particle_list, :classes, :counter, :atomes_specificities + attr_accessor :allow_history, :database_ready + def messages @messages end def eVe(val = nil) @@ -122,15 +124,17 @@ @atomes.each do |id_found, atome_found| collected_id << id_found if atome_found.tag && atome_found.tag[:system] end collected_id end + def generate_uuid - uuid = SecureRandom.uuid.gsub('-','') + uuid = SecureRandom.uuid.gsub('-', '') formatted_time = Time.now.strftime("%Y%m%d%H%M%S") "#{uuid}#{formatted_time}" end + def app_identity # each app hav its own identity, this allow to generate new user identities from the # unique_id = generate_unique_id_with_timestamp @app_identity = generate_uuid # the identity is define as follow : parentsCreatorID_softwareInstanceID_objetID @@ -235,14 +239,19 @@ @history[action_nb][:sync] = true end def historicize(id, operation, element, params) - if @allow_history - operation_timing= Time.now.strftime("%Y%m%d%H%M%S%3N")+@increment.to_s - @increment+=1 - @increment=@increment%100 - JS.global[:localStorage].setItem(operation_timing,"{ #{id} => { #{operation} => { #{element} => #{params} } }, sync: false }") + + if @allow_history && @database_ready + # sync + A.sync({ action: :historicize, data: { table: :user } }) do |_db_state| + # puts "===> #{_db_state}" + end + operation_timing = Time.now.strftime("%Y%m%d%H%M%S%3N") + @increment.to_s + @increment += 1 + @increment = @increment % 100 + JS.global[:localStorage].setItem(operation_timing, "{ #{id} => { #{operation} => { #{element} => #{params} } }, sync: false }") @history[@history.length] = { operation_timing => { id => { operation => { element => params } }, sync: false, time: Time.now } } end end def story(filter)