Add photos version check

old-stable24
Varun Patil 2022-10-27 13:45:03 -07:00
parent a0d757adfc
commit 1af61db512
7 changed files with 48 additions and 19 deletions

View File

@ -825,13 +825,7 @@ class ApiController extends Controller
*/ */
private function albumsIsEnabled(): bool private function albumsIsEnabled(): bool
{ {
if (!$this->appManager->isEnabledForUser('photos')) { return \OCA\Memories\Util::albumsIsEnabled($this->appManager);
return false;
}
$v = $this->appManager->getAppInfo('photos')['version'];
return version_compare($v, '1.7.0', '>=');
} }
/** /**
@ -839,7 +833,7 @@ class ApiController extends Controller
*/ */
private function tagsIsEnabled(): bool 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 private function recognizeIsEnabled(): bool
{ {
if (!$this->appManager->isEnabledForUser('recognize')) { return \OCA\Memories\Util::recognizeIsEnabled($this->appManager);
return false;
}
$v = $this->appManager->getAppInfo('recognize')['version'];
return version_compare($v, '3.0.0-alpha', '>=');
} }
} }

View File

@ -86,8 +86,11 @@ class PageController extends Controller
// Apps enabled // Apps enabled
$this->initialState->provideInitialState('systemtags', true === $this->appManager->isEnabledForUser('systemtags')); $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('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']); $this->initialState->provideInitialState('version', $this->appManager->getAppInfo('memories')['version']);
$policy = new ContentSecurityPolicy(); $policy = new ContentSecurityPolicy();

View File

@ -26,4 +26,40 @@ class Util
return $p; 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', '>=');
}
} }

View File

@ -130,7 +130,7 @@ export default class App extends Mixins(GlobalMixin, UserConfig) {
} }
get showAlbums() { get showAlbums() {
return this.ncVersion >= 25; // todo: and photos enabled return this.config_albumsEnabled;
} }
get removeOuterGap() { get removeOuterGap() {

View File

@ -141,6 +141,7 @@ export default class SelectionHandler extends Mixins(GlobalMixin, UserConfig) {
name: t('memories', 'Add to album'), name: t('memories', 'Add to album'),
icon: AlbumsIcon, icon: AlbumsIcon,
callback: this.addToAlbum.bind(this), callback: this.addToAlbum.bind(this),
if: (self: any) => self.config_albumsEnabled,
}, },
{ {
name: t('memories', 'Move to another person'), name: t('memories', 'Move to another person'),
@ -171,7 +172,7 @@ export default class SelectionHandler extends Mixins(GlobalMixin, UserConfig) {
/** Get the actions list */ /** Get the actions list */
private getActions(): ISelectionAction[] { 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 */ /** Clear all selected photos */

View File

@ -38,6 +38,7 @@ export default class UserConfig extends Vue {
config_tagsEnabled = Boolean(loadState('memories', 'systemtags')); config_tagsEnabled = Boolean(loadState('memories', 'systemtags'));
config_recognizeEnabled = Boolean(loadState('memories', 'recognize')); config_recognizeEnabled = Boolean(loadState('memories', 'recognize'));
config_mapsEnabled = Boolean(loadState('memories', 'maps')); config_mapsEnabled = Boolean(loadState('memories', 'maps'));
config_albumsEnabled = Boolean(loadState('memories', 'albums'));
config_squareThumbs = localStorage.getItem('memories_squareThumbs') === '1'; config_squareThumbs = localStorage.getItem('memories_squareThumbs') === '1';
config_showFaceRect = localStorage.getItem('memories_showFaceRect') === '1'; config_showFaceRect = localStorage.getItem('memories_showFaceRect') === '1';

View File

@ -197,5 +197,5 @@ export type ISelectionAction = {
/** Action to perform */ /** Action to perform */
callback: (selection: Map<number, IPhoto>) => Promise<void>; callback: (selection: Map<number, IPhoto>) => Promise<void>;
/** Condition to check for including */ /** Condition to check for including */
if?: () => boolean; if?: (self?: any) => boolean;
} }