| @@ -31,10 +31,14 @@ | ||
| 31 | 31 | */ |
| 32 | 32 | const COLUMNS_KEY = 'hidden-columns'; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * Mount: restore the remembered view mode. The client's first | |
| 36 | - * dispatch carries the schema default; the stored preference wins. | |
| 35 | + * Mount: restore the remembered view mode (the client's first dispatch | |
| 36 | + * carries the schema default; the stored preference wins), then land | |
| 37 | + * on the person a `footprint` open-time param names. Deriving that | |
| 38 | + * here is what keeps the first paint honest: a window opened with | |
| 39 | + * params waits for `mount`, so the footprint is the first thing the | |
| 40 | + * body shows — not the folder grid for a beat and a second request. | |
| 37 | 41 | * |
| 38 | 42 | * @param State $state State. |
| 39 | 43 | * @param Os $os Host handle. |
| 40 | 44 | * @return void |
| @@ -41,11 +45,57 @@ | ||
| 41 | 45 | */ |
| 42 | 46 | function mount( State $state, Os $os ) { |
| 43 | 47 | $stored = (string) $os->stored( 'view', 'icons' ); |
| 44 | 48 | $state->set( 'view', in_array( $stored, VIEWS, true ) ? $stored : 'icons' ); |
| 49 | + footprint_from_params( $state, $os ); | |
| 45 | 50 | } |
| 46 | 51 | |
| 47 | 52 | /** |
| 53 | + * `reopen`: the live window was asked to open from another surface | |
| 54 | + * (`wp.os.openWindow( 'my-wordpress', { params } )`). A named person | |
| 55 | + * replaces whatever the body showed; a plain reopen changes nothing. | |
| 56 | + * | |
| 57 | + * @param State $state State. | |
| 58 | + * @param Os $os Host handle. | |
| 59 | + * @return void | |
| 60 | + */ | |
| 61 | +function reopen_action( State $state, Os $os ) { | |
| 62 | + footprint_from_params( $state, $os ); | |
| 63 | +} | |
| 64 | + | |
| 65 | +/** | |
| 66 | + * The footprint the open-time params name — `footprint` (user id) and | |
| 67 | + * `fpName` (breadcrumb placeholder), as the footprint open target | |
| 68 | + * passes them. | |
| 69 | + * | |
| 70 | + * @param State $state State. | |
| 71 | + * @param Os $os Host handle. | |
| 72 | + * @return void | |
| 73 | + */ | |
| 74 | +function footprint_from_params( State $state, Os $os ) { | |
| 75 | + open_footprint( $state, (int) $os->param( 'footprint', 0 ), (string) $os->param( 'fpName', '' ) ); | |
| 76 | +} | |
| 77 | + | |
| 78 | +/** | |
| 79 | + * Put one person's footprint over the body. The id is validated (the | |
| 80 | + * payload route re-checks the viewer); the name is only ever breadcrumb | |
| 81 | + * text, so the entities the sanitiser writes for a `<` are decoded. | |
| 82 | + * | |
| 83 | + * @param State $state State. | |
| 84 | + * @param int $user User id; 0 or unknown opens nothing. | |
| 85 | + * @param string $name Display name, or ''. | |
| 86 | + * @return void | |
| 87 | + */ | |
| 88 | +function open_footprint( State $state, $user, $name ) { | |
| 89 | + if ( $user <= 0 || false === get_userdata( $user ) ) { | |
| 90 | + return; | |
| 91 | + } | |
| 92 | + $state->set( 'footprint', $user ) | |
| 93 | + ->set( 'fpName', openstation_plain_text_title( sanitize_text_field( $name ) ) ) | |
| 94 | + ->set( 'item', 0 )->set( 'into', 0 )->set( 'relation', '' ); | |
| 95 | +} | |
| 96 | + | |
| 97 | +/** | |
| 48 | 98 | * `view`: the mode switch. The bound value already arrived with the |
| 49 | 99 | * state (the client flips locally first, so the switch is instant); |
| 50 | 100 | * this validates it and remembers it for the next window. |
| 51 | 101 | * |
| @@ -222,11 +272,10 @@ | ||
| 222 | 272 | } |
| 223 | 273 | |
| 224 | 274 | /** |
| 225 | 275 | * `footprint`: open a user's activity footprint over the body — the |
| 226 | - * full-width surface WP Explorer answered "open this person" with. | |
| 227 | - * The id is validated (the payload route re-checks the viewer), the | |
| 228 | - * name is only ever a breadcrumb placeholder. | |
| 276 | + * full-width surface WP Explorer answered "open this person" with, | |
| 277 | + * from a dossier action or the shared footprint target. | |
| 229 | 278 | * |
| 230 | 279 | * @param State $state State. |
| 231 | 280 | * @param Os $os Host handle. |
| 232 | 281 | * @param array<string,mixed> $args Trigger args (`user`, `name`). |
| @@ -232,15 +281,9 @@ | ||
| 232 | 281 | * @param array<string,mixed> $args Trigger args (`user`, `name`). |
| 233 | 282 | * @return void |
| 234 | 283 | */ |
| 235 | 284 | function footprint_action( State $state, Os $os, array $args ) { |
| 236 | - $user = (int) ( $args['user'] ?? 0 ); | |
| 237 | - if ( $user <= 0 || false === get_userdata( $user ) ) { | |
| 238 | - return; | |
| 239 | - } | |
| 240 | - $state->set( 'footprint', $user ) | |
| 241 | - ->set( 'fpName', sanitize_text_field( (string) ( $args['name'] ?? '' ) ) ) | |
| 242 | - ->set( 'item', 0 )->set( 'into', 0 )->set( 'relation', '' ); | |
| 285 | + open_footprint( $state, (int) ( $args['user'] ?? 0 ), (string) ( $args['name'] ?? '' ) ); | |
| 243 | 286 | } |
| 244 | 287 | |
| 245 | 288 | /** |
| 246 | 289 | * `sub-open-post`: a recent-posts row in a stats pane → its editor. |