mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Smaller aircraft photos, one-row-per-item detail cards, push diagnostics
- Aircraft photos get 192px and 960x432 copies made on upload; the header, share page and Fleet cards use them (and the offline copies), instead of the full original. - Flight, engine data, component and major record details show one label and value per row on phones (wide items no longer add grid columns). - Profile re-records this device's push subscription on every visit, and says why if it can't; Send test delivers now and lists each device's result; Google's other push hosts are accepted; turning notifications on shows the browser's actual error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f314a13bb
commit
d4b71d17a1
21 files changed
+234
-96
No files matched your search
@@ -6,7 +6,13 @@ class PushSubscriptionsController < ApplicationController
|
||||
record = PushSubscription.find_or_initialize_by(endpoint: sub[:endpoint].to_s)
|
||||
record.assign_attributes(user: current_user, p256dh: sub.dig(:keys, :p256dh), auth: sub.dig(:keys, :auth),
|
||||
user_agent: request.user_agent.to_s.first(250))
|
||||
record.save ? head(:created) : head(:unprocessable_entity)
|
||||
if record.save
|
||||
head :created
|
||||
else
|
||||
render json: { error: t("flash.push_subscriptions.not_saved", host: URI.parse(record.endpoint).host.to_s) }, status: :unprocessable_entity
|
||||
end
|
||||
rescue URI::InvalidURIError
|
||||
render json: { error: t("flash.push_subscriptions.not_saved", host: "?") }, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -14,9 +20,35 @@ class PushSubscriptionsController < ApplicationController
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# A notification to this user's devices, to check they arrive.
|
||||
# A notification to each of this user's devices, sent now so the page can
|
||||
# say which push services took it (and why one didn't).
|
||||
def test
|
||||
PushNotifier.notify(current_user, :test, path: edit_profile_path, tag: "test")
|
||||
head :accepted
|
||||
message = PushNotificationJob.message("test", edit_profile_path, "test")
|
||||
devices = current_user.push_subscriptions.order(:created_at).map do |sub|
|
||||
{ device: device_name(sub.user_agent), error: PushNotificationJob.deliver(sub, message) }
|
||||
end
|
||||
render json: { devices: devices }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# "Chrome on Android" from the browser's description of itself.
|
||||
def device_name(agent)
|
||||
browser = case agent
|
||||
when /Edg\//, /EdgA\// then "Edge"
|
||||
when /SamsungBrowser/ then "Samsung Internet"
|
||||
when /Firefox|FxiOS/ then "Firefox"
|
||||
when /Chrome|CriOS/ then "Chrome"
|
||||
when /Safari/ then "Safari"
|
||||
end
|
||||
system = case agent
|
||||
when /Android/ then "Android"
|
||||
when /iPhone/ then "iPhone"
|
||||
when /iPad/ then "iPad"
|
||||
when /Macintosh/ then "Mac"
|
||||
when /Windows/ then "Windows"
|
||||
when /Linux/ then "Linux"
|
||||
end
|
||||
[ browser, system ].compact.join(" · ").presence || t("flash.push_subscriptions.unknown_device")
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user