Skip to content

Commit

Permalink
#25276 Refactor code for adding the device
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelrojas committed Aug 2, 2023
1 parent 4648d75 commit 4270b42
Showing 1 changed file with 12 additions and 6 deletions.
Expand Up @@ -76,10 +76,6 @@ export class DotPageStateService {
}

this.requestPage(options).subscribe((pageState: DotPageRenderState) => {
if (!pageState.viewAs.device) {
pageState.viewAs.device = options.viewAs?.device;
}

this.setState(pageState);
});
}
Expand Down Expand Up @@ -297,7 +293,12 @@ export class DotPageStateService {
favoritePage: DotCMSContentlet,
experiment: DotExperiment
]) => {
return this.setLocalPageState(page, favoritePage, experiment);
return this.setLocalPageState(
page,
favoritePage,
experiment,
options.viewAs?.device
);
}
)
);
Expand All @@ -312,7 +313,8 @@ export class DotPageStateService {
private setLocalPageState(
page: DotPageRenderParameters,
favoritePage?: DotCMSContentlet,
runningExperiment?: DotExperiment
runningExperiment?: DotExperiment,
device?: DotDevice
): Observable<DotPageRenderState> {
const pageState = new DotPageRenderState(
this.getCurrentUser(),
Expand All @@ -321,6 +323,10 @@ export class DotPageStateService {
runningExperiment
);

if (!pageState.viewAs?.device && device) {
pageState.viewAs.device = device;
}

this.setCurrentState(pageState);

return of(pageState);
Expand Down

0 comments on commit 4270b42

Please sign in to comment.