Skip to content

Commit

Permalink
Merged in task/dspace-cris-2023_02_x/DSC-1745 (pull request DSpace#1816)
Browse files Browse the repository at this point in the history
Task/dspace cris 2023 02 x/DSC-1745

Approved-by: Andrea Barbasso
  • Loading branch information
Simone-Ramundi authored and Andrea Barbasso committed Jun 25, 2024
2 parents bebc88c + b207203 commit 4a24d9b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<ds-themed-root
[shouldShowFullscreenLoader]="(isAuthBlocking$ | async) || (isThemeLoading$ | async)"
[shouldShowRouteLoader]="isRouteLoading$ | async"></ds-themed-root>

<ds-social *ngIf="browserPlatform"></ds-social>
9 changes: 8 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export class AppComponent implements OnInit, AfterViewInit {
*/
idleModalOpen: boolean;


/**
* In order to show sharing component only in csr
*/
browserPlatform = false;

constructor(
@Inject(NativeWindowService) private _window: NativeWindowRef,
@Inject(DOCUMENT) private document: any,
Expand All @@ -78,11 +84,12 @@ export class AppComponent implements OnInit, AfterViewInit {
private datadogRumService: DatadogRumService
) {
this.notificationOptions = environment.notifications;
this.browserPlatform = isPlatformBrowser(this.platformId);

/* Use models object so all decorators are actually called */
this.models = models;

if (isPlatformBrowser(this.platformId)) {
if (this.browserPlatform) {
this.trackIdleModal();
}

Expand Down
10 changes: 6 additions & 4 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { StoreDevModules } from '../config/store/devtools';
import { RootModule } from './root.module';
import { NuMarkdownModule } from '@ng-util/markdown';
import { FooterModule } from './footer/footer.module';
import { SocialModule } from './social/social.module';

export function getConfig() {
return environment;
Expand Down Expand Up @@ -120,10 +121,11 @@ const EXPORTS = [
];

@NgModule({
imports: [
BrowserModule.withServerTransition({ appId: 'dspace-angular' }),
...IMPORTS
],
imports: [
BrowserModule.withServerTransition({appId: 'dspace-angular'}),
...IMPORTS,
SocialModule
],
providers: [
...PROVIDERS
],
Expand Down
1 change: 0 additions & 1 deletion src/app/root/root.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
</div>
</div>

<ds-social *ngIf="browserPlatform"></ds-social>

<ds-notifications-board [options]="notificationOptions">
</ds-notifications-board>
Expand Down
3 changes: 2 additions & 1 deletion src/app/social/social.component.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
:host {
::ng-deep {
div#a2a {
bottom: 0;
right: 0;
z-index: 998;
}
}

16 changes: 15 additions & 1 deletion src/app/social/social.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,21 @@ export class SocialService {
script.type = 'text/javascript';
script.src = environment.addToAnyPlugin.scriptUrl;
script.async = true;
this._document.body.appendChild(script);

// Wait for document to finish grow vertically so that script listener handles properly body height changes
let lastBodyHeight = 0;
const documentBody = this._document.body;

const bodyHeightInterval = setInterval(() => {
const currentBodyHeight = documentBody.getBoundingClientRect().height;

if (currentBodyHeight > lastBodyHeight) {
lastBodyHeight = currentBodyHeight;
} else {
this._document.head.appendChild(script);
clearInterval(bodyHeightInterval);
}
}, 200);
}

/**
Expand Down

0 comments on commit 4a24d9b

Please sign in to comment.