Add photos version check
parent
a0d757adfc
commit
1af61db512
|
@ -825,13 +825,7 @@ class ApiController extends Controller
|
|||
*/
|
||||
private function albumsIsEnabled(): bool
|
||||
{
|
||||
if (!$this->appManager->isEnabledForUser('photos')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$v = $this->appManager->getAppInfo('photos')['version'];
|
||||
|
||||
return version_compare($v, '1.7.0', '>=');
|
||||
return \OCA\Memories\Util::albumsIsEnabled($this->appManager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -839,7 +833,7 @@ class ApiController extends Controller
|
|||
*/
|
||||
private function tagsIsEnabled(): bool
|
||||
{
|
||||
return $this->appManager->isEnabledForUser('systemtags');
|
||||
return \OCA\Memories\Util::tagsIsEnabled($this->appManager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -847,12 +841,6 @@ class ApiController extends Controller
|
|||
*/
|
||||
private function recognizeIsEnabled(): bool
|
||||
{
|
||||
if (!$this->appManager->isEnabledForUser('recognize')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$v = $this->appManager->getAppInfo('recognize')['version'];
|
||||
|
||||
return version_compare($v, '3.0.0-alpha', '>=');
|
||||
return \OCA\Memories\Util::recognizeIsEnabled($this->appManager);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,8 +86,11 @@ class PageController extends Controller
|
|||
|
||||
// Apps enabled
|
||||
$this->initialState->provideInitialState('systemtags', true === $this->appManager->isEnabledForUser('systemtags'));
|
||||
$this->initialState->provideInitialState('recognize', true === $this->appManager->isEnabledForUser('recognize'));
|
||||
$this->initialState->provideInitialState('maps', true === $this->appManager->isEnabledForUser('maps'));
|
||||
$this->initialState->provideInitialState('recognize', \OCA\Memories\Util::recognizeIsEnabled($this->appManager));
|
||||
$this->initialState->provideInitialState('albums', \OCA\Memories\Util::albumsIsEnabled($this->appManager));
|
||||
|
||||
// App version
|
||||
$this->initialState->provideInitialState('version', $this->appManager->getAppInfo('memories')['version']);
|
||||
|
||||
$policy = new ContentSecurityPolicy();
|
||||
|
|
36
lib/Util.php
36
lib/Util.php
|
@ -26,4 +26,40 @@ class Util
|
|||
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if albums are enabled for this user.
|
||||
*/
|
||||
public static function albumsIsEnabled(&$appManager): bool
|
||||
{
|
||||
if (!$appManager->isEnabledForUser('photos')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$v = $appManager->getAppInfo('photos')['version'];
|
||||
|
||||
return version_compare($v, '1.7.0', '>=');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if tags is enabled for this user.
|
||||
*/
|
||||
public static function tagsIsEnabled(&$appManager): bool
|
||||
{
|
||||
return $appManager->isEnabledForUser('systemtags');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if recognize is enabled for this user.
|
||||
*/
|
||||
public static function recognizeIsEnabled(&$appManager): bool
|
||||
{
|
||||
if (!$appManager->isEnabledForUser('recognize')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$v = $appManager->getAppInfo('recognize')['version'];
|
||||
|
||||
return version_compare($v, '3.0.0-alpha', '>=');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ export default class App extends Mixins(GlobalMixin, UserConfig) {
|
|||
}
|
||||
|
||||
get showAlbums() {
|
||||
return this.ncVersion >= 25; // todo: and photos enabled
|
||||
return this.config_albumsEnabled;
|
||||
}
|
||||
|
||||
get removeOuterGap() {
|
||||
|
|
|
@ -141,6 +141,7 @@ export default class SelectionHandler extends Mixins(GlobalMixin, UserConfig) {
|
|||
name: t('memories', 'Add to album'),
|
||||
icon: AlbumsIcon,
|
||||
callback: this.addToAlbum.bind(this),
|
||||
if: (self: any) => self.config_albumsEnabled,
|
||||
},
|
||||
{
|
||||
name: t('memories', 'Move to another person'),
|
||||
|
@ -171,7 +172,7 @@ export default class SelectionHandler extends Mixins(GlobalMixin, UserConfig) {
|
|||
|
||||
/** Get the actions list */
|
||||
private getActions(): ISelectionAction[] {
|
||||
return this.defaultActions.filter(a => !a.if || a.if());
|
||||
return this.defaultActions.filter(a => !a.if || a.if(this));
|
||||
}
|
||||
|
||||
/** Clear all selected photos */
|
||||
|
|
|
@ -38,6 +38,7 @@ export default class UserConfig extends Vue {
|
|||
config_tagsEnabled = Boolean(loadState('memories', 'systemtags'));
|
||||
config_recognizeEnabled = Boolean(loadState('memories', 'recognize'));
|
||||
config_mapsEnabled = Boolean(loadState('memories', 'maps'));
|
||||
config_albumsEnabled = Boolean(loadState('memories', 'albums'));
|
||||
|
||||
config_squareThumbs = localStorage.getItem('memories_squareThumbs') === '1';
|
||||
config_showFaceRect = localStorage.getItem('memories_showFaceRect') === '1';
|
||||
|
|
|
@ -197,5 +197,5 @@ export type ISelectionAction = {
|
|||
/** Action to perform */
|
||||
callback: (selection: Map<number, IPhoto>) => Promise<void>;
|
||||
/** Condition to check for including */
|
||||
if?: () => boolean;
|
||||
if?: (self?: any) => boolean;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue