Skip to content
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

chore: Add Option to Update Layout Only for Resolution Change in Studio Load Function #136

Merged
merged 3 commits into from
Jan 13, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ log.txt
docs/
.npmrc
renderer/renderer.json
.aider*
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@api.stream/studio-kit",
"version": "3.0.45",
"version": "3.0.46",
"description": "Client SDK for building studio experiences with API.stream",
"license": "MIT",
"private": false,
Expand Down
5 changes: 3 additions & 2 deletions src/core/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const hydrateProject = async (
x: number
y: number
},
updateLayoutOnly?: boolean,
) => {
const metadata = project.metadata || {}

Expand All @@ -140,18 +141,18 @@ export const hydrateProject = async (
}

// handle composition size changing
if (size) {
if (size && !updateLayoutOnly) {
updateRequest.rendering = {
video: {
width: size.x,
height: size.y,
framerate: 30,
},
};

updateRequest.updateMask.push('rendering');
}


if (updateRequest.updateMask.length) {
await CoreContext.clients.LiveApi().project.updateProject(updateRequest);
}
Expand Down
5 changes: 4 additions & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@ const load = async (
x: number
y: number
},
options?: {
updateLayoutOnly?: boolean
}
): Promise<SDK.User> => {
let user = getBaseUser()
if (user) {
Expand All @@ -621,7 +624,7 @@ const load = async (
await client.load(accessToken)

// Load the projects and user data
const result = await CoreContext.Request.loadUser(size)
const result = await CoreContext.Request.loadUser(size, options)

// TODO: Move to UserLoaded event handler
setAppState({
Expand Down
15 changes: 10 additions & 5 deletions src/core/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,15 @@ export const deleteProject = async (request: { projectId: string }) => {
* Load the user data from whatever access token has been registered
* with the API.
*/
export const loadUser = async (size?: {
x: number
y: number
}): Promise<{
export const loadUser = async (
size?: {
x: number
y: number
},
options?: {
updateLayoutOnly?: boolean
}
): Promise<{
user: InternalUser
projects: InternalProject[]
sources: InternalSource[]
Expand Down Expand Up @@ -146,7 +151,7 @@ export const loadUser = async (size?: {
const projects = await Promise.all(
collection.projects
.filter((p) => Boolean(p.metadata?.layoutId))
.map((project) => hydrateProject(project, 'ROLE_HOST' as Role, size)),
.map((project) => hydrateProject(project, 'ROLE_HOST' as Role, size, options?.updateLayoutOnly)),
)

return {
Expand Down
2 changes: 1 addition & 1 deletion src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ export interface Studio {
* ----
* **Emits {@link UserLoaded}**
*/
load: (accessToken: string, size?: { x: number; y: number }) => Promise<User>
load: (accessToken: string, size?: { x: number; y: number }, options?: { updateLayoutOnly?: boolean }) => Promise<User>
/**
* Renders a project into the supplied HTML Element.
*/
Expand Down
Loading