Skip to content

Commit

Permalink
Refactor app platform to use BrowserView instead of webview tags (str…
Browse files Browse the repository at this point in the history
…eam-labs#1353)

* feat:use forked electron release

* add instruction on how to update electron fork version

* udpate yarn.lock

* tmp commit

* making progress with working partition and guest API, lots of hacks

* working resizing of browserviews

* working for non-persistent pages

* intermediate cleanup

* more cleanup

* fix chat, more cleanup/refactoring

* working display, still some bugs to find

* fix some bugs

* prevent app navigation

* dev tools for beta apps

* refactoring to load/unload/refresh and enable production apps

* minor fixes for production apps

* remove outdated comment

* TODO Comments

* only start up containers for enabled apps

* fix app reload issues

* remove console.log

* code review
  • Loading branch information
avacreeth authored Feb 12, 2019
1 parent fd5765b commit fa631cc
Show file tree
Hide file tree
Showing 34 changed files with 765 additions and 575 deletions.
6 changes: 3 additions & 3 deletions app/components/AppPlatformDeveloperSettings.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ export default class AppPlatformDeveloperSettings extends Vue {
if (!this.appTokenValue) return;

if (this.currentlyLoadedUnpackedApp) {
this.platformAppsService.unloadApps();
this.platformAppsService.unloadApp(this.currentlyLoadedUnpackedApp);
}

this.loading = true;

try {
this.error = await this.platformAppsService.installUnpackedApp(
this.error = await this.platformAppsService.loadUnpackedApp(
this.appPathValue,
this.appTokenValue,
);
Expand All @@ -70,7 +70,7 @@ export default class AppPlatformDeveloperSettings extends Vue {
this.error = '';

try {
this.error = await this.platformAppsService.reloadApp(this.currentlyLoadedUnpackedApp.id);
this.error = await this.platformAppsService.refreshApp(this.currentlyLoadedUnpackedApp.id);
} catch (e) {
this.error =
'There was an error loading this app, please try again ' +
Expand Down
6 changes: 3 additions & 3 deletions app/components/AppsNav.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class AppsNav extends Vue {

isSelectedApp(appId: string) {
return (
this.page === 'PlatformAppContainer' && this.navigationService.state.params.appId === appId
this.page === 'PlatformAppMainPage' && this.navigationService.state.params.appId === appId
);
}

Expand All @@ -58,15 +58,15 @@ export default class AppsNav extends Vue {
}

refreshApp(appId: string) {
this.platformAppsService.reloadApp(appId);
this.platformAppsService.refreshApp(appId);
}

get page() {
return this.navigationService.state.currentPage;
}

navigateApp(appId: string) {
this.navigationService.navigate('PlatformAppContainer', { appId });
this.navigationService.navigate('PlatformAppMainPage', { appId });
}

scrollLeft() {
Expand Down
2 changes: 1 addition & 1 deletion app/components/InstalledApps.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class InstalledApps extends Vue {
}

reload(appId: string) {
this.platformAppsService.reloadApp(appId);
this.platformAppsService.refreshApp(appId);
}

toggleEnable(app: ILoadedApp) {
Expand Down
9 changes: 3 additions & 6 deletions app/components/LiveDock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,11 @@
<div class="live-dock-chat" v-if="isTwitch || isMixer || (isYoutube && isStreaming) || isFacebook">
<!-- v-if is required because left-side chat will not properly load on application startup -->
<chat v-if="!applicationLoading" :style="defaultChatStyles" ref="chat" />
<PlatformAppWebview
v-for="app in chatApps"
v-if="(app.id === selectedChat) || isAppPersistent(app.id)"
:key="app.id"
<PlatformAppPageView
v-if="selectedChat !== 'default' && !collapsed"
class="live-dock-platform-app-webview"
:appId="app.id"
:appId="selectedChat"
:pageSlot="slot"
:visible="isAppVisible(app.id)"
/>
</div>
<div class="flex flex--center flex--column live-dock-chat--offline" v-else >
Expand Down
14 changes: 3 additions & 11 deletions app/components/LiveDock.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import electron from 'electron';
import { getPlatformService } from 'services/platforms';
import { YoutubeService } from 'services/platforms/youtube';
import { $t } from 'services/i18n';
import PlatformAppWebview from 'components/PlatformAppWebview.vue';
import PlatformAppPageView from 'components/PlatformAppPageView.vue';
import { PlatformAppsService, EAppPageSlot, ILoadedApp } from 'services/platform-apps';
import ListInput from 'components/shared/inputs/ListInput.vue';
import { metadata as metadataHelper } from 'components/widgets/inputs';
Expand All @@ -21,7 +21,7 @@ import { AppService } from 'services/app';
components: {
Chat,
ListInput,
PlatformAppWebview,
PlatformAppPageView,
ResizeBar,
},
})
Expand Down Expand Up @@ -186,7 +186,7 @@ export default class LiveDock extends Vue {

refreshChat() {
if (!this.showDefaultPlatformChat) {
this.platformAppsService.reloadApp(this.selectedChat);
this.platformAppsService.refreshApp(this.selectedChat);
return;
}
this.$refs.chat.refresh();
Expand Down Expand Up @@ -243,14 +243,6 @@ export default class LiveDock extends Vue {
this.selectedChat = 'default';
}

isAppPersistent(appId: string) {
return this.platformAppsService.isAppSlotPersistent(appId, EAppPageSlot.Chat);
}

isAppVisible(appId: string) {
return this.selectedChat === appId;
}

get defaultChatStyles() {
if (this.selectedChat === 'default') {
return {};
Expand Down
16 changes: 16 additions & 0 deletions app/components/PlatformAppPageView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div
class="platform-app-container"
ref="appContainer" />
</template>

<script lang="ts" src="./PlatformAppPageView.vue.ts"></script>
<style lang="less" scoped>
@import "../styles/index";
.platform-app-container {
display: flex;
flex-direction: column;
width: 100%;
}
</style>
88 changes: 88 additions & 0 deletions app/components/PlatformAppPageView.vue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { PlatformAppsService, EAppPageSlot } from 'services/platform-apps';
import { Inject } from 'util/injector';
import electron from 'electron';
import Utils from 'services/utils';
import { Subscription } from 'rxjs';

@Component({})
export default class PlatformAppPageView extends Vue {
@Inject() platformAppsService: PlatformAppsService;
@Prop() appId: string;
@Prop() pageSlot: EAppPageSlot;

$refs: {
appContainer: HTMLDivElement;
};

resizeInterval: number;
containerId: number;
loadSub: Subscription;
currentPosition: IVec2;
currentSize: IVec2;

mounted() {
this.mountContainer();

this.resizeInterval = window.setInterval(() => {
this.checkResize();
}, 100);

this.loadSub = this.platformAppsService.appLoad.subscribe(app => {
if (this.appId === app.id) {
this.unmountContainer();
this.mountContainer();
}
});
}

mountContainer() {
this.containerId = this.platformAppsService.mountContainer(
this.appId,
this.pageSlot,
electron.remote.getCurrentWindow().id,
Utils.getWindowId(),
);
this.checkResize();
}

unmountContainer() {
this.currentPosition = null;
this.currentSize = null;
this.platformAppsService.unmountContainer(
this.containerId,
electron.remote.getCurrentWindow().id,
);
}

destroyed() {
if (this.resizeInterval) clearInterval(this.resizeInterval);
this.loadSub.unsubscribe();
this.unmountContainer();
}

checkResize() {
const rect = this.$refs.appContainer.getBoundingClientRect();

if (this.currentPosition == null || this.currentSize == null || this.rectChanged(rect)) {
this.currentPosition = { x: rect.left, y: rect.top };
this.currentSize = { x: rect.width, y: rect.height };

this.platformAppsService.setContainerBounds(
this.containerId,
this.currentPosition,
this.currentSize,
);
}
}

private rectChanged(rect: ClientRect) {
return (
rect.left !== this.currentPosition.x ||
rect.top !== this.currentPosition.y ||
rect.width !== this.currentSize.x ||
rect.height !== this.currentSize.y
);
}
}
36 changes: 0 additions & 36 deletions app/components/PlatformAppWebview.vue

This file was deleted.

Loading

0 comments on commit fa631cc

Please sign in to comment.