forked from owncloud/music
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around file/folder dialogs not working on NC 27.1.0 and 27.1.1
In the mentioned NC versions, the legacy filepicker API doesn't work without passing the dialog type (choose/copy/move/copy-and-move) explicitly while the "choose" has previously been the default type. This is supposed to get fixed in NC 27.1.2. In the meantime, we may pass the type "choose" explicitly. All the access to the OC filepicker API now happens through our own wrapper class. This should make our life easier if the deprecated legacy API gets removed for good at some point. refs owncloud#1091
- Loading branch information
Showing
4 changed files
with
58 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* ownCloud - Music app | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Pauli Järvinen <pauli.jarvinen@gmail.com> | ||
* @copyright Pauli Järvinen 2023 | ||
*/ | ||
|
||
OCA.Music = OCA.Music || {}; | ||
|
||
/** @namespace | ||
* | ||
* Wrapper for dialogs provided by the host cloud. Provide a bit more concise interface | ||
* and hide any differences between the supported cloud versions. | ||
*/ | ||
OCA.Music.Dialogs = class { | ||
|
||
static filePicker(title : string, callback : CallableFunction, mimetype : string|string[], path : string|undefined = undefined) { | ||
// The filepicker interface wants to get the initial path without a trailing slash | ||
if (path?.endsWith('/')) { | ||
path = path.slice(0, -1); | ||
} | ||
|
||
OC.dialogs.filepicker( | ||
title, | ||
(datapath : string, _returnType : any) => callback(datapath), // arg _returnType is passed by NC but not by OC | ||
false, // multiselect | ||
mimetype, | ||
true, // modal | ||
OC.dialogs.FILEPICKER_TYPE_CHOOSE, // type (only on NC) | ||
path // initial folder, only on NC16+ | ||
); | ||
} | ||
|
||
static folderPicker(title : string, callback : CallableFunction, path = '') { | ||
OCA.Music.Dialogs.filePicker( | ||
title, | ||
(selectedPath : string) => { | ||
if (!selectedPath.endsWith('/')) { | ||
selectedPath = selectedPath + '/'; | ||
} | ||
callback(selectedPath); | ||
}, | ||
'httpd/unix-directory', | ||
path // initial folder, only on NC16+ | ||
); | ||
} | ||
}; |