Skip to content

Commit

Permalink
fix compatibility with nc13
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jul 3, 2018
1 parent 6643d13 commit 201a09d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
6 changes: 3 additions & 3 deletions build/bundle.js

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions js/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,23 @@ export class Api {

listFolders(): Thenable<Folder[]> {
return $.getJSON(this.getUrl('folders'))
.then((data:OCSResult<Folder[]>) => data.ocs.data);
.then((data: OCSResult<Folder[]>) => data.ocs.data);
}

listGroups(): Thenable<Group[]> {
return $.getJSON(OC.linkToOCS('cloud', 1) + 'groups/details')
.then((data: OCSResult<{ groups: string[]; }>) => data.ocs.data.groups);
const version = parseInt(oc_config.version, 10);
if (version >= 14) {
return $.getJSON(OC.linkToOCS('cloud', 1) + 'groups/details')
.then((data: OCSResult<{ groups: Group[]; }>) => data.ocs.data.groups);
} else {
return $.getJSON(OC.linkToOCS('cloud', 1) + 'groups')
.then((data: OCSResult<{ groups: string[]; }>) => data.ocs.data.groups.map(group => {
return {
id: group,
displayname: group
};
}));
}
}

createFolder(mountPoint: string): Thenable<number> {
Expand Down
13 changes: 13 additions & 0 deletions js/Nextcloud.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ declare namespace OC {

declare function t(app: string, string: string, vars?: { [key: string]: string }, count?: number, options?: EscapeOptions): string;

declare const oc_config: {
blacklist_files_regex: string;
enable_avatars: boolean;
last_password_link: string | null;
modRewriteWorking: boolean;
session_keepalive: boolean;
session_lifetime: boolean;
"sharing.maxAutocompleteResults": number;
"sharing.minSearchStringLength": number;
version: string;
versionString: string;
};

declare module 'NC' {
export interface OCSResult<T> {
ocs: {
Expand Down

0 comments on commit 201a09d

Please sign in to comment.