-
-
Notifications
You must be signed in to change notification settings - Fork 398
ui fixes #1064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
ui fixes #1064
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,11 @@ | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| namespace App\SiteTypes; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| use App\DTOs\SocketEventDTO; | ||||||||||||||||||||||||
| use App\Events\SocketEvent; | ||||||||||||||||||||||||
| use App\Exceptions\FailedToDeployGitKey; | ||||||||||||||||||||||||
| use App\Exceptions\SSHError; | ||||||||||||||||||||||||
| use App\Http\Resources\SiteResource; | ||||||||||||||||||||||||
| use App\Models\Service; | ||||||||||||||||||||||||
| use App\Models\Site; | ||||||||||||||||||||||||
| use App\Services\PHP\PHP; | ||||||||||||||||||||||||
|
|
@@ -64,6 +67,12 @@ protected function progress(int $percentage): void | |||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| $this->site->progress = $percentage; | ||||||||||||||||||||||||
| $this->site->save(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| SocketEvent::dispatch(new SocketEventDTO( | ||||||||||||||||||||||||
| projectId: $this->site->server->project_id, | ||||||||||||||||||||||||
| type: 'site.updated', | ||||||||||||||||||||||||
| data: new SiteResource($this->site), | ||||||||||||||||||||||||
|
Comment on lines
+71
to
+74
|
||||||||||||||||||||||||
| SocketEvent::dispatch(new SocketEventDTO( | |
| projectId: $this->site->server->project_id, | |
| type: 'site.updated', | |
| data: new SiteResource($this->site), | |
| $sanitizedSite = clone $this->site; | |
| $sanitizedSite->setAttribute('type_data', null); | |
| SocketEvent::dispatch(new SocketEventDTO( | |
| projectId: $this->site->server->project_id, | |
| type: 'site.updated', | |
| data: new SiteResource($sanitizedSite), |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,6 +160,34 @@ export function useSocketListener(callback: (data: SocketEventData) => void): vo | |
| }, []); | ||
| } | ||
|
|
||
| /** | ||
| * Keeps a single resource in sync with socket events. | ||
| * | ||
| * Returns the live resource (initially from Inertia props, updated via socket). | ||
| * Pass `null` to skip listening (safe to call unconditionally). | ||
| */ | ||
|
Comment on lines
+163
to
+168
|
||
| export function useRealtimeRecord<T extends { id: number }>(initial: T | null | undefined, eventPrefix: string): T | null { | ||
| const [record, setRecord] = useState<T | null>(initial ?? null); | ||
|
|
||
| useEffect(() => { | ||
| setRecord(initial ?? null); | ||
| }, [initial]); | ||
|
|
||
| useSocketListener( | ||
| useCallback( | ||
| (event) => { | ||
| if (!initial) return; | ||
| if (event.type === `${eventPrefix}.updated` && event.data && 'id' in event.data && event.data.id === initial.id) { | ||
| setRecord(event.data as unknown as T); | ||
| } | ||
| }, | ||
| [eventPrefix, initial?.id], | ||
| ), | ||
| ); | ||
|
|
||
| return record; | ||
| } | ||
|
|
||
| /** | ||
| * Manages paginated Inertia data with realtime socket updates. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
progress()now dispatches a fullServerResourceon every progress tick.ServerResource::toArray()performs aservices()->pluck(...)query, so frequent progress updates can add avoidable DB load during installation. Consider emitting a lightweight progress payload (id/status/status_color/progress/progress_step) or adjustServerResourceto avoid querying services when not needed / use already-loaded relations.