Add initial-state
This commit is contained in:
parent
14cd1e9cbb
commit
1eeb718a88
@ -10,14 +10,12 @@ use OCP\AppFramework\App;
|
|||||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||||
use OCP\Server;
|
use OCP\AppFramework\Services\IInitialState;
|
||||||
use OCP\Util;
|
|
||||||
|
|
||||||
class Application extends App implements IBootstrap
|
class Application extends App implements IBootstrap
|
||||||
{
|
{
|
||||||
public const APP_ID = 'repod';
|
public const APP_ID = 'repod';
|
||||||
private const GPODDERSYNC_ID = 'gpoddersync';
|
private const GPODDERSYNC_ID = 'gpoddersync';
|
||||||
private const GPODDERSYNC_MIN_VERSION = '3.8.1';
|
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct(self::APP_ID);
|
parent::__construct(self::APP_ID);
|
||||||
@ -30,6 +28,9 @@ class Application extends App implements IBootstrap
|
|||||||
/** @var IAppManager $appManager */
|
/** @var IAppManager $appManager */
|
||||||
$appManager = $appContainer->get(IAppManager::class);
|
$appManager = $appContainer->get(IAppManager::class);
|
||||||
|
|
||||||
|
/** @var IInitialState $initialState */
|
||||||
|
$initialState = $appContainer->get(IInitialState::class);
|
||||||
|
|
||||||
$gpoddersync = $appManager->isEnabledForUser(self::GPODDERSYNC_ID);
|
$gpoddersync = $appManager->isEnabledForUser(self::GPODDERSYNC_ID);
|
||||||
if (!$gpoddersync) {
|
if (!$gpoddersync) {
|
||||||
try {
|
try {
|
||||||
@ -38,24 +39,9 @@ class Application extends App implements IBootstrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
$gpoddersync = $appManager->isEnabledForUser(self::GPODDERSYNC_ID);
|
||||||
Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig');
|
$initialState->provideInitialState('gpodder', $gpoddersync);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(IRegistrationContext $context): void {}
|
public function register(IRegistrationContext $context): void {}
|
||||||
|
|
||||||
public static function extendJsConfig(array $settings): void {
|
|
||||||
/** @var IAppManager $appManager */
|
|
||||||
$appManager = Server::get(IAppManager::class);
|
|
||||||
|
|
||||||
if (is_array($settings['array']) && array_key_exists('oc_appconfig', $settings['array'])) {
|
|
||||||
/** @var array $appConfig */
|
|
||||||
$appConfig = json_decode((string) $settings['array']['oc_appconfig'], true);
|
|
||||||
$appConfig['repod'] = [
|
|
||||||
'gpodder' => $appManager->isEnabledForUser(self::GPODDERSYNC_ID)
|
|
||||||
&& version_compare($appManager->getAppVersion(self::GPODDERSYNC_ID), self::GPODDERSYNC_MIN_VERSION) >= 0,
|
|
||||||
];
|
|
||||||
$settings['array']['oc_appconfig'] = json_encode($appConfig);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
1
package-lock.json
generated
1
package-lock.json
generated
@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nextcloud/axios": "^2.4.0",
|
"@nextcloud/axios": "^2.4.0",
|
||||||
"@nextcloud/dialogs": "^5.0.3",
|
"@nextcloud/dialogs": "^5.0.3",
|
||||||
|
"@nextcloud/initial-state": "^2.1.0",
|
||||||
"@nextcloud/l10n": "^2.2.0",
|
"@nextcloud/l10n": "^2.2.0",
|
||||||
"@nextcloud/moment": "^1.2.2",
|
"@nextcloud/moment": "^1.2.2",
|
||||||
"@nextcloud/router": "^2.2.0",
|
"@nextcloud/router": "^2.2.0",
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nextcloud/axios": "^2.4.0",
|
"@nextcloud/axios": "^2.4.0",
|
||||||
"@nextcloud/dialogs": "^5.0.3",
|
"@nextcloud/dialogs": "^5.0.3",
|
||||||
|
"@nextcloud/initial-state": "^2.1.0",
|
||||||
"@nextcloud/l10n": "^2.2.0",
|
"@nextcloud/l10n": "^2.2.0",
|
||||||
"@nextcloud/moment": "^1.2.2",
|
"@nextcloud/moment": "^1.2.2",
|
||||||
"@nextcloud/router": "^2.2.0",
|
"@nextcloud/router": "^2.2.0",
|
||||||
|
12
src/App.vue
12
src/App.vue
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<NcContent app-name="repod">
|
<NcContent app-name="repod">
|
||||||
<GPodder v-if="!AppConfig.repod.gpodder" />
|
<GPodder v-if="!gpodder" />
|
||||||
<Subscriptions v-if="AppConfig.repod.gpodder" />
|
<Subscriptions v-if="gpodder" />
|
||||||
<router-view v-if="AppConfig.repod.gpodder" :key="$route.path" />
|
<router-view v-if="gpodder" :key="$route.path" />
|
||||||
<Bar />
|
<Bar />
|
||||||
</NcContent>
|
</NcContent>
|
||||||
</template>
|
</template>
|
||||||
@ -13,6 +13,7 @@ import Bar from './components/Player/Bar.vue'
|
|||||||
import GPodder from './views/GPodder.vue'
|
import GPodder from './views/GPodder.vue'
|
||||||
import { NcContent } from '@nextcloud/vue'
|
import { NcContent } from '@nextcloud/vue'
|
||||||
import Subscriptions from './components/Sidebar/Subscriptions.vue'
|
import Subscriptions from './components/Sidebar/Subscriptions.vue'
|
||||||
|
import { loadState } from '@nextcloud/initial-state'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
@ -22,5 +23,10 @@ export default {
|
|||||||
NcContent,
|
NcContent,
|
||||||
Subscriptions,
|
Subscriptions,
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
gpodder() {
|
||||||
|
return loadState('repod', 'gpodder', false)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -13,8 +13,6 @@ const n = (...args) => translatePlural('repod', ...args)
|
|||||||
|
|
||||||
Vue.mixin({ methods: { t, n } })
|
Vue.mixin({ methods: { t, n } })
|
||||||
|
|
||||||
Vue.prototype.AppConfig = window.oc_appconfig
|
|
||||||
|
|
||||||
Vue.filter('stripHTML', (value) => {
|
Vue.filter('stripHTML', (value) => {
|
||||||
const div = document.createElement('div')
|
const div = document.createElement('div')
|
||||||
div.innerHTML = value
|
div.innerHTML = value
|
||||||
|
Loading…
Reference in New Issue
Block a user