Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,28 @@ export function useConnectionPreviewData( connection: Connection ) {

return useMemo( () => {
const useRendered = templatesEnabled && typeof rendered === 'string';
const baseMessage = isPerNetworkMode
? ( connection.message ?? globalMessage ).trim()
: globalMessage.trim();
const hasConnectionMessage = connection.message !== undefined && connection.message !== '';
let baseMessage: string;
if ( isPerNetworkMode ) {
if ( hasConnectionMessage ) {
baseMessage = connection.message ?? '';
} else if ( templatesEnabled && connection.template ) {
baseMessage = connection.template;
} else {
baseMessage = globalMessage;
}
} else {
baseMessage = globalMessage;
}

return {
...postData,
message: useRendered ? rendered : baseMessage,
message: useRendered ? rendered : baseMessage.trim(),
media,
};
}, [
connection.message,
connection.template,
globalMessage,
isPerNetworkMode,
media,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,20 @@ export function usePerNetworkCustomization() {
featuredImageMime,
} );

customizeConnectionById( connection.connection_id, {
message: postMeta.shareMessage || '',
/*
* Skip writing `message` when the connection has its own template — leaving
* `connection.message` undefined lets the editor and preview fall back to the
* connection template instead of overwriting it with the global share message.
*/
const updates: Parameters< typeof customizeConnectionById >[ 1 ] = {
attached_media: attachedMedia,
media_source: effectiveSource,
} );
};
if ( ! connection.template ) {
updates.message = postMeta.shareMessage || '';
}

customizeConnectionById( connection.connection_id, updates );
}
} );
}, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ export function useRenderMessageItems(): RenderItem[] {

const items = useMemo< RenderItem[] >( () => {
return connections.map( connection => {
const message = ( connection.message ?? globalMessage ?? '' ).trim();
const hasConnectionMessage = connection.message !== undefined && connection.message !== '';
let raw: string;
if ( hasConnectionMessage ) {
raw = connection.message ?? '';
} else if ( ctx.isPerNetworkMode ) {
raw = connection.template ?? globalMessage ?? '';
} else {
raw = globalMessage ?? '';
}
return {
id: connection.connection_id,
network: connection.service_name ?? '',
message,
message: raw.trim(),
is_social_post: connectionHasMedia( connection, ctx ),
};
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Social: honor per-connection message templates in the per-network preview pipeline and stop overwriting them when toggling per-network mode.
Loading