update_last_used.rb 833 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class User::Current::Overview::UpdateLastUsed < BaseMutation
  4. description 'Update the last used information of the current user in their user preferences'
  5. argument :overviews_last_used, [Gql::Types::Input::User::Current::OverviewLastUsedType], description: 'List of overviews and their last used info'
  6. field :success, Boolean, null: false, description: 'Was the save successful?'
  7. def resolve(overviews_last_used:)
  8. value_to_store = overviews_last_used.each_with_object({}) do |olu, value|
  9. value[olu.overview.id.to_s] = olu.last_used_at
  10. end
  11. context.current_user.preferences[:overviews_last_used] = value_to_store
  12. context.current_user.save!
  13. { success: true }
  14. end
  15. end
  16. end