PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/desktop-files/rest.php +41 -20 1.0.01.1.10 View file →
@@ -409,8 +409,44 @@
409 409 }
410 410 add_filter( 'openstation_shell_config', 'openstation_files_inject_boot_placements', 20 );
411 411
412 412 /**
413 + * Inline the viewer's visible folder rows into the boot-time shell
414 + * config, the same way the root placements are.
415 + *
416 + * The client keeps a folders map alongside its placements, and
417 + * anything that needs to know a folder's OWNER reads it there —
418 + * notably the "Share folder" title-bar button, which is owner-only
419 + * and has nothing but a window id to work from. Nothing on the
420 + * normal boot path filled that map: placement hydration populates
421 + * placements, and `listFolders()` only ran after a create, a rename
422 + * or an untrash. So a plain reload left every folder ownerless, and
423 + * the owner of a folder lost the one control that manages its
424 + * sharing until something happened to repopulate the map.
425 + *
426 + * Mirrors GET /folders exactly (same visibility resolution — owned
427 + * folders plus accepted shares plus `share_mode='all'` — same
428 + * shape), and the client consumes it one-shot, so any later
429 + * re-hydration still goes through REST for fresh state.
430 + *
431 + * @param array $config Shell config.
432 + * @return array
433 + */
434 +function openstation_files_inject_boot_folders( $config ) {
435 + $user_id = get_current_user_id();
436 + if ( $user_id <= 0 ) {
437 + return $config;
438 + }
439 + $out = array();
440 + foreach ( openstation_files_get_visible_folders( $user_id ) as $row ) {
441 + $out[] = openstation_files_shape_folder( $row );
442 + }
443 + $config['filesBootFolders'] = $out;
444 + return $config;
445 +}
446 +add_filter( 'openstation_shell_config', 'openstation_files_inject_boot_folders', 20 );
447 +
448 +/**
413 449 * GET /placements
414 450 */
415 451 function openstation_files_rest_list_placements( WP_REST_Request $req ) {
416 452 $user_id = get_current_user_id();
@@ -733,28 +769,13 @@
733 769 'shareMode' => (string) $row['share_mode'],
734 770 'shareMeta' => isset( $row['share_meta'] ) ? $row['share_meta'] : null,
735 771 'updatedAtMs' => (int) $row['updated_at_ms'],
736 772 );
737 - if ( function_exists( 'openstation_files_get_folder_shares' ) ) {
738 - $shares = openstation_files_get_folder_shares( (int) $row['id'] );
739 - $accepted_count = 0;
740 - $has_all = 'all' === (string) $row['share_mode'];
741 - foreach ( $shares as $s ) {
742 - if ( 'accepted' === $s['state'] ) {
743 - ++$accepted_count;
744 - }
745 - }
746 - // `shared` is viewer-agnostic — recipients need it for the
747 - // shared-folder badge. The recipient COUNT is owner-internal
748 - // (the dedicated shares endpoint gates the full roster on
749 - // `share_can_manage`), so only managers get the real number;
750 - // every other viewer sees `0`, keeping the wire shape stable.
751 - $can_manage = function_exists( 'openstation_files_share_can_manage' )
752 - && openstation_files_share_can_manage( (int) $row['id'], get_current_user_id() );
753 - $shape['shareSummary'] = array(
754 - 'shared' => $has_all || $accepted_count > 0,
755 - 'recipientCount' => $can_manage ? $accepted_count + ( $has_all ? 1 : 0 ) : 0,
756 - );
773 + // Same summary `OpenStation_Folder_File::serialize()` puts on a
774 + // folder PLACEMENT, so a tile paints identically whichever
775 + // response it came from.
776 + if ( function_exists( 'openstation_files_folder_share_summary' ) ) {
777 + $shape['shareSummary'] = openstation_files_folder_share_summary( $row );
757 778 }
758 779 return $shape;
759 780 }
760 781