Skip to content

Commit

Permalink
add initialstate provider
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <[email protected]>
  • Loading branch information
szaimen committed Nov 15, 2023
1 parent 03256ad commit 29dfbb4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
29 changes: 28 additions & 1 deletion lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
use OCA\FirstRunWizard\Notification\AppHint;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\BackgroundJob\IJobList;
use OCP\Defaults;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Util;
Expand All @@ -55,16 +57,26 @@ class BeforeTemplateRenderedListener implements IEventListener {
*/
private $jobList;

/** @var IInitialState */
protected $initialState;

/** @var Defaults */
protected $theming;

public function __construct(
IConfig $config,
IUserSession $userSession,
IJobList $jobList,
AppHint $appHint
AppHint $appHint,
IInitialState $initialState,
Defaults $theming,
) {
$this->userSession = $userSession;
$this->config = $config;
$this->appHint = $appHint;
$this->jobList = $jobList;
$this->initialState = $initialState;
$this->theming = $theming;
}

public function handle(Event $event): void {
Expand All @@ -88,5 +100,20 @@ public function handle(Event $event): void {
}

Util::addScript(Application::APP_ID, 'about');

$this->initialState->provideInitialState(
'desktop',
$this->config->getSystemValue('customclient_desktop', $this->theming->getSyncClientUrl())
);

$this->initialState->provideInitialState(
'android',
$this->config->getSystemValue('customclient_android', $this->theming->getSyncClientUrl())
);

$this->initialState->provideInitialState(
'ios',
$this->config->getSystemValue('customclient_ios', $this->theming->getSyncClientUrl())
);
}
}
15 changes: 13 additions & 2 deletions src/components/AppStoreBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@

<script>
import { imagePath } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'

const android = loadState('firstrunwizard', 'android')
const ios = loadState('firstrunwizard', 'ios')

export default {
name: 'AppStoreBadge',

data() {
return {
android,
ios,
}
},

props: {

Check warning on line 50 in src/components/AppStoreBadge.vue

View workflow job for this annotation

GitHub Actions / eslint

The "props" property should be above the "data" property on line 43
type: {
type: String,
Expand All @@ -60,9 +71,9 @@ export default {

href() {
if (this.type === 'ios') {
return 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'
return this.ios
} else if (this.type === 'android') {
return 'https://play.google.com/store/apps/details?id=com.nextcloud.client'
return this.android
}
return undefined
},
Expand Down
6 changes: 5 additions & 1 deletion src/components/Page2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="page__content">
<AppStoreBadge type="android" />
<AppStoreBadge type="ios" />
<Card href="https://nextcloud.com/install/#install-clients"
<Card :href="desktop"
:title="t('firstrunwizard', 'Desktop app ↗')"
:subtitle="t('firstrunwizard', 'Download For Windows, Mac OS and Linux.')" />
<Card :href="syncClientsUrl"
Expand All @@ -58,6 +58,9 @@ import AppStoreBadge from './AppStoreBadge.vue'
import ArrowRight from 'vue-material-design-icons/ArrowRight.vue'
import { NcButton } from '@nextcloud/vue'
import { generateUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'

const desktop = loadState('firstrunwizard', 'desktop')

export default {
name: 'Page2',
Expand All @@ -73,6 +76,7 @@ export default {
return {
subtitleText: t('firstrunwizard', 'Sync your files across your devices with the desktop and mobile apps, and connect your calendar and contacts.'),
syncClientsUrl: generateUrl('settings/user/sync-clients'),
desktop,
}
},

Expand Down

0 comments on commit 29dfbb4

Please sign in to comment.