all: make OCA dep optional

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/653/head
Varun Patil 2023-05-02 15:40:36 -07:00
parent 38fa33fdba
commit 45743b8918
4 changed files with 42 additions and 44 deletions

View File

@ -212,10 +212,8 @@ export default defineComponent({
root.style.setProperty('--plyr-color-main', colorPrimary); root.style.setProperty('--plyr-color-main', colorPrimary);
// Register sidebar metadata tab // Register sidebar metadata tab
const OCA = globalThis.OCA; globalThis.OCA?.Files?.Sidebar?.registerTab(
if (OCA.Files && OCA.Files.Sidebar) { new globalThis.OCA.Files.Sidebar.Tab({
OCA.Files.Sidebar.registerTab(
new OCA.Files.Sidebar.Tab({
id: 'memories-metadata', id: 'memories-metadata',
name: this.t('memories', 'Info'), name: this.t('memories', 'Info'),
icon: 'icon-details', icon: 'icon-details',
@ -235,7 +233,6 @@ export default defineComponent({
}, },
}) })
); );
}
}, },
async beforeMount() { async beforeMount() {

View File

@ -51,6 +51,27 @@ export default defineComponent({
}, },
}, },
created() {
if (globalThis.OCA) {
globalThis.OCA.Files ??= {};
// TODO: remove when we have a proper fileinfo standalone library
// original scripts are loaded from
// https://github.com/nextcloud/server/blob/5bf3d1bb384da56adbf205752be8f840aac3b0c5/lib/private/legacy/template.php#L120-L122
Object.assign(
globalThis.OCA.Files,
{
App: {
fileList: {
filesClient: (<any>globalThis.OC.Files).getClient(),
},
},
},
globalThis.OCA.Files
);
}
},
mounted() { mounted() {
subscribe('files:sidebar:opened', this.handleNativeOpen); subscribe('files:sidebar:opened', this.handleNativeOpen);
subscribe('files:sidebar:closed', this.handleNativeClose); subscribe('files:sidebar:closed', this.handleNativeClose);

View File

@ -361,7 +361,7 @@ export default defineComponent({
this.originalTitle = document.title; this.originalTitle = document.title;
} }
if (photo) { if (photo) {
document.title = `${photo.basename} - ${globalThis.OCA.Theming?.name}`; document.title = `${photo.basename} - ${globalThis.OCA?.Theming?.name}`;
} else { } else {
document.title = this.originalTitle; document.title = this.originalTitle;
this.originalTitle = null; this.originalTitle = null;

View File

@ -77,26 +77,6 @@ Vue.mixin(GlobalMixin as any);
Vue.use(VueVirtualScroller); Vue.use(VueVirtualScroller);
Vue.component('XImg', XImg); Vue.component('XImg', XImg);
// https://github.com/nextcloud/photos/blob/156f280c0476c483cb9ce81769ccb0c1c6500a4e/src/main.js
// TODO: remove when we have a proper fileinfo standalone library
// original scripts are loaded from
// https://github.com/nextcloud/server/blob/5bf3d1bb384da56adbf205752be8f840aac3b0c5/lib/private/legacy/template.php#L120-L122
window.addEventListener('DOMContentLoaded', () => {
if (!globalThis.OCA.Files) {
globalThis.OCA.Files = {};
}
// register unused client for the sidebar to have access to its parser methods
Object.assign(
globalThis.OCA.Files,
{
App: {
fileList: { filesClient: (<any>globalThis.OC.Files).getClient() },
},
},
globalThis.OCA.Files
);
});
let app = null; let app = null;
const adminSection = document.getElementById('memories-admin-content'); const adminSection = document.getElementById('memories-admin-content');