Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement default Photos folder #1189

Merged
merged 1 commit into from
Aug 30, 2022
Merged

Implement default Photos folder #1189

merged 1 commit into from
Aug 30, 2022

Conversation

skjnldsv
Copy link
Member

@skjnldsv skjnldsv commented Aug 30, 2022

image

@skjnldsv skjnldsv self-assigned this Aug 30, 2022
@skjnldsv skjnldsv added enhancement New feature or request 2. developing Work in progress labels Aug 30, 2022
@skjnldsv skjnldsv added this to the Nextcloud 25 milestone Aug 30, 2022
@skjnldsv skjnldsv force-pushed the feat/default-folder branch 3 times, most recently from 47d8cea to 86a39b8 Compare August 30, 2022 09:29
@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 30, 2022
@skjnldsv skjnldsv force-pushed the feat/default-folder branch from 86a39b8 to 34948e3 Compare August 30, 2022 09:31
use OCP\IUserSession;

class UserConfigService {
public const DEFAULT_CONFIGS = [
Copy link
Member Author

@skjnldsv skjnldsv Aug 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could theoritecally be exposed as a capability and used straight away by the

return {
croppedLayout: croppedLayoutLocalStorage !== null
? croppedLayoutLocalStorage === 'true'
: loadState('photos', 'croppedLayout') === 'true',
photosLocation: loadState('photos', 'photosLocation'),
}
instead of having to declare them again in the front :)

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
@skjnldsv skjnldsv force-pushed the feat/default-folder branch from 34948e3 to a07c06f Compare August 30, 2022 09:38
Comment on lines +73 to +86
updatePhotosFolder(path) {
console.debug(`Path '${path}' selected for photos location`)
if (typeof path !== 'string' || path.trim() === '' || !path.startsWith('/')) {
showError(t('photos', 'Invalid location selected'))
return
}

if (path.includes('//')) {
path = path.replace(/\/\//gi, '/')
}

this.photosLocation = path
this.updateSetting('photosLocation')
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or:

Suggested change
updatePhotosFolder(path) {
console.debug(`Path '${path}' selected for photos location`)
if (typeof path !== 'string' || path.trim() === '' || !path.startsWith('/')) {
showError(t('photos', 'Invalid location selected'))
return
}
if (path.includes('//')) {
path = path.replace(/\/\//gi, '/')
}
this.photosLocation = path
this.updateSetting('photosLocation')
},
updatePhotosFolder: debounce(function (path) {
console.debug(`Path '${path}' selected for photos location`)
if (typeof path !== 'string' || path.trim() === '' || !path.startsWith('/')) {
showError(t('photos', 'Invalid location selected'))
return
}
if (path.includes('//')) {
path = path.replace(/\/\//gi, '/')
}
this.photosLocation = path
this.updateSetting('photosLocation')
}),

But works as you coded it so feel free to ignore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debounce requires a function reference, here the function will be created on each call, so it will be different and not debounced properly, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, sometimes you don't need to debounce, like right after picking with the Folder picker for example

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debounce requires a function reference, here the function will be created on each call, so it will be different and not debounced properly, no?

Here, debounce will be called only once at component creation and return a debounced function from the passed one. So the function will stay the same

Comment on lines +69 to +71
debounceUpdatePhotosFolder: debounce(function(...args) {
this.updatePhotosFolder(...args)
}, 300),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not working?

Suggested change
debounceUpdatePhotosFolder: debounce(function(...args) {
this.updatePhotosFolder(...args)
}, 300),
debounceUpdatePhotosFolder: debounce(this.updatePhotosFolder, 300),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me check :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because this is not set there otherwise

@skjnldsv skjnldsv requested a review from artonge August 30, 2022 10:23
@skjnldsv skjnldsv merged commit 58b420c into master Aug 30, 2022
@skjnldsv skjnldsv deleted the feat/default-folder branch August 30, 2022 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants