MOBILE-3643 forum: Rename services
parent
e726858216
commit
5d39d8efc9
|
@ -17,7 +17,7 @@ import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { PopoverController } from '@singletons';
|
import { PopoverController } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { AddonModForum, AddonModForumDiscussion, AddonModForumProvider } from '../../services/forum.service';
|
import { AddonModForum, AddonModForumDiscussion, AddonModForumProvider } from '../../services/forum';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component is meant to display a popover with the discussion options.
|
* This component is meant to display a popover with the discussion options.
|
||||||
|
|
|
@ -18,8 +18,8 @@ import { CoreFileEntry, CoreFileUploader } from '@features/fileuploader/services
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { ModalController, Translate } from '@singletons';
|
import { ModalController, Translate } from '@singletons';
|
||||||
import { AddonModForumData, AddonModForumPost, AddonModForumReply } from '@addons/mod/forum/services/forum.service';
|
import { AddonModForumData, AddonModForumPost, AddonModForumReply } from '@addons/mod/forum/services/forum';
|
||||||
import { AddonModForumHelper } from '@addons/mod/forum/services/helper.service';
|
import { AddonModForumHelper } from '@addons/mod/forum/services/helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays a form to edit discussion post.
|
* Page that displays a form to edit discussion post.
|
||||||
|
|
|
@ -24,11 +24,11 @@ import {
|
||||||
AddonModForumDiscussion,
|
AddonModForumDiscussion,
|
||||||
AddonModForumNewDiscussionData,
|
AddonModForumNewDiscussionData,
|
||||||
AddonModForumReplyDiscussionData,
|
AddonModForumReplyDiscussionData,
|
||||||
} from '@addons/mod/forum/services/forum.service';
|
} from '@addons/mod/forum/services/forum';
|
||||||
import { AddonModForumOffline, AddonModForumOfflineDiscussion } from '@addons/mod/forum/services/offline.service';
|
import { AddonModForumOffline, AddonModForumOfflineDiscussion } from '@addons/mod/forum/services/offline';
|
||||||
import { ModalController, PopoverController, Translate } from '@singletons';
|
import { ModalController, PopoverController, Translate } from '@singletons';
|
||||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||||
import { AddonModForumHelper } from '@addons/mod/forum/services/helper.service';
|
import { AddonModForumHelper } from '@addons/mod/forum/services/helper';
|
||||||
import { CoreGroups, CoreGroupsProvider } from '@services/groups';
|
import { CoreGroups, CoreGroupsProvider } from '@services/groups';
|
||||||
import { CoreEvents, CoreEventObserver } from '@singletons/events';
|
import { CoreEvents, CoreEventObserver } from '@singletons/events';
|
||||||
import {
|
import {
|
||||||
|
@ -36,7 +36,7 @@ import {
|
||||||
AddonModForumManualSyncData,
|
AddonModForumManualSyncData,
|
||||||
AddonModForumSyncProvider,
|
AddonModForumSyncProvider,
|
||||||
AddonModForumSyncResult,
|
AddonModForumSyncResult,
|
||||||
} from '@addons/mod/forum/services/sync.service';
|
} from '@addons/mod/forum/services/sync';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreUser } from '@features/user/services/user';
|
import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
import { AddonModForum, AddonModForumPost } from '@addons/mod/forum/services/forum.service';
|
import { AddonModForum, AddonModForumPost } from '@addons/mod/forum/services/forum';
|
||||||
import { Network, NgZone, PopoverController } from '@singletons';
|
import { Network, NgZone, PopoverController } from '@singletons';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
|
|
|
@ -39,16 +39,16 @@ import {
|
||||||
AddonModForumReply,
|
AddonModForumReply,
|
||||||
AddonModForumUpdateDiscussionPostWSOptionsObject,
|
AddonModForumUpdateDiscussionPostWSOptionsObject,
|
||||||
AddonModForumWSPostAttachment,
|
AddonModForumWSPostAttachment,
|
||||||
} from '../../services/forum.service';
|
} from '../../services/forum';
|
||||||
import { CoreTag } from '@features/tag/services/tag';
|
import { CoreTag } from '@features/tag/services/tag';
|
||||||
import { ModalController, PopoverController, Translate } from '@singletons';
|
import { ModalController, PopoverController, Translate } from '@singletons';
|
||||||
import { CoreFileEntry, CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileEntry, CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
import { AddonModForumSync } from '../../services/sync.service';
|
import { AddonModForumSync } from '../../services/sync';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { AddonModForumHelper } from '../../services/helper.service';
|
import { AddonModForumHelper } from '../../services/helper';
|
||||||
import { AddonModForumOffline, AddonModForumReplyOptions } from '../../services/offline.service';
|
import { AddonModForumOffline, AddonModForumReplyOptions } from '../../services/offline';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModForumPostOptionsMenuComponent } from '../post-options-menu/post-options-menu';
|
import { AddonModForumPostOptionsMenuComponent } from '../post-options-menu/post-options-menu';
|
||||||
import { AddonModForumEditPostComponent } from '../edit-post/edit-post';
|
import { AddonModForumEditPostComponent } from '../edit-post/edit-post';
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { AddonModForumSortOrder } from '@addons/mod/forum/services/forum.service';
|
import { AddonModForumSortOrder } from '@addons/mod/forum/services/forum';
|
||||||
import { ModalController } from '@singletons';
|
import { ModalController } from '@singletons';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { CoreScreen } from '@services/screen';
|
||||||
|
|
||||||
import { AddonModForumComponentsModule } from './components/components.module';
|
import { AddonModForumComponentsModule } from './components/components.module';
|
||||||
import { AddonModForumModuleHandler, AddonModForumModuleHandlerService } from './services/handlers/module';
|
import { AddonModForumModuleHandler, AddonModForumModuleHandlerService } from './services/handlers/module';
|
||||||
import { SITE_SCHEMA } from './services/offline-db';
|
import { SITE_SCHEMA } from './services/database/offline';
|
||||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||||
import { AddonModForumPrefetchHandler } from './services/handlers/prefetch';
|
import { AddonModForumPrefetchHandler } from './services/handlers/prefetch';
|
||||||
import { CoreCronDelegate } from '@services/cron';
|
import { CoreCronDelegate } from '@services/cron';
|
||||||
|
|
|
@ -34,10 +34,10 @@ import {
|
||||||
AddonModForumPost,
|
AddonModForumPost,
|
||||||
AddonModForumProvider,
|
AddonModForumProvider,
|
||||||
AddonModForumRatingInfo,
|
AddonModForumRatingInfo,
|
||||||
} from '../../services/forum.service';
|
} from '../../services/forum';
|
||||||
import { AddonModForumHelper } from '../../services/helper.service';
|
import { AddonModForumHelper } from '../../services/helper';
|
||||||
import { AddonModForumOffline } from '../../services/offline.service';
|
import { AddonModForumOffline } from '../../services/offline';
|
||||||
import { AddonModForumSync, AddonModForumSyncProvider } from '../../services/sync.service';
|
import { AddonModForumSync, AddonModForumSyncProvider } from '../../services/sync';
|
||||||
|
|
||||||
type SortType = 'flat-newest' | 'flat-oldest' | 'nested';
|
type SortType = 'flat-newest' | 'flat-oldest' | 'nested';
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { AddonModForumData } from '@addons/mod/forum/services/forum.service';
|
import { AddonModForumData } from '@addons/mod/forum/services/forum';
|
||||||
import { CoreCourseAnyModuleData } from '@features/course/services/course';
|
import { CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,16 @@ import {
|
||||||
AddonModForumCanAddDiscussion,
|
AddonModForumCanAddDiscussion,
|
||||||
AddonModForumData,
|
AddonModForumData,
|
||||||
AddonModForumProvider,
|
AddonModForumProvider,
|
||||||
} from '@addons/mod/forum/services/forum.service';
|
} from '@addons/mod/forum/services/forum';
|
||||||
import { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor';
|
import { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor';
|
||||||
import { AddonModForumSync, AddonModForumSyncProvider } from '@addons/mod/forum/services/sync.service';
|
import { AddonModForumSync, AddonModForumSyncProvider } from '@addons/mod/forum/services/sync';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { AddonModForumDiscussionOptions, AddonModForumOffline } from '@addons/mod/forum/services/offline.service';
|
import { AddonModForumDiscussionOptions, AddonModForumOffline } from '@addons/mod/forum/services/offline';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModForumHelper } from '@addons/mod/forum/services/helper.service';
|
import { AddonModForumHelper } from '@addons/mod/forum/services/helper';
|
||||||
import { IonRefresher } from '@ionic/angular';
|
import { IonRefresher } from '@ionic/angular';
|
||||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { CoreSiteSchema } from '@services/sites';
|
import { CoreSiteSchema } from '@services/sites';
|
||||||
|
import { AddonModForumOfflineDiscussion, AddonModForumOfflineReply } from '../offline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database variables for AddonModForum service.
|
* Database variables for AddonModForum service.
|
||||||
|
@ -113,3 +114,11 @@ export const SITE_SCHEMA: CoreSiteSchema = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type AddonModForumOfflineDiscussionDBRecord = Omit<AddonModForumOfflineDiscussion, 'options'> & {
|
||||||
|
options: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AddonModForumOfflineReplyDBRecord = Omit<AddonModForumOfflineReply, 'options'> & {
|
||||||
|
options: string;
|
||||||
|
};
|
|
@ -26,7 +26,7 @@ import { CoreUrlUtils } from '@services/utils/url';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumReplyOptions } from './offline.service';
|
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumReplyOptions } from './offline';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'mmaModForum:';
|
const ROOT_CACHE_KEY = 'mmaModForum:';
|
||||||
|
|
||||||
|
@ -216,11 +216,7 @@ export class AddonModForumProvider {
|
||||||
const response = await site.write<AddonModForumAddDiscussionWSResponse>('mod_forum_add_discussion', params);
|
const response = await site.write<AddonModForumAddDiscussionWSResponse>('mod_forum_add_discussion', params);
|
||||||
|
|
||||||
// Other errors ocurring.
|
// Other errors ocurring.
|
||||||
if (!response || !response.discussionid) {
|
return response.discussionid;
|
||||||
return Promise.reject(CoreUtils.instance.createFakeWSError(''));
|
|
||||||
} else {
|
|
||||||
return response.discussionid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -832,7 +828,7 @@ export class AddonModForumProvider {
|
||||||
let numPages = typeof options.numPages == 'undefined' ? -1 : options.numPages;
|
let numPages = typeof options.numPages == 'undefined' ? -1 : options.numPages;
|
||||||
|
|
||||||
if (!numPages) {
|
if (!numPages) {
|
||||||
return Promise.resolve(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPage = (page: number): Promise<{ discussions: AddonModForumDiscussion[]; error: boolean }> =>
|
const getPage = (page: number): Promise<{ discussions: AddonModForumDiscussion[]; error: boolean }> =>
|
||||||
|
@ -1114,7 +1110,7 @@ export class AddonModForumProvider {
|
||||||
return storeOffline();
|
return storeOffline();
|
||||||
} else {
|
} else {
|
||||||
// The WebService has thrown an error or offline not supported, reject.
|
// The WebService has thrown an error or offline not supported, reject.
|
||||||
return Promise.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1142,8 +1138,10 @@ export class AddonModForumProvider {
|
||||||
subject: subject,
|
subject: subject,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
options: CoreUtils.instance.objectToArrayOfObjects<
|
||||||
options: CoreUtils.instance.objectToArrayOfObjects<AddonModForumAddDiscussionPostWSOptionsArray[0], AddonModForumAddDiscussionPostWSOptionsObject>(
|
AddonModForumAddDiscussionPostWSOptionsArray[0],
|
||||||
|
AddonModForumAddDiscussionPostWSOptionsObject
|
||||||
|
>(
|
||||||
options || {},
|
options || {},
|
||||||
'name',
|
'name',
|
||||||
'value',
|
'value',
|
||||||
|
@ -1297,8 +1295,10 @@ export class AddonModForumProvider {
|
||||||
subject: subject,
|
subject: subject,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
options: CoreUtils.instance.objectToArrayOfObjects<
|
||||||
options: CoreUtils.instance.objectToArrayOfObjects<AddonModForumUpdateDiscussionPostWSOptionsArray[0], AddonModForumUpdateDiscussionPostWSOptionsObject>(
|
AddonModForumUpdateDiscussionPostWSOptionsArray[0],
|
||||||
|
AddonModForumUpdateDiscussionPostWSOptionsObject
|
||||||
|
>(
|
||||||
options || {},
|
options || {},
|
||||||
'name',
|
'name',
|
||||||
'value',
|
'value',
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable, Type } from '@angular/core';
|
import { Injectable, Type } from '@angular/core';
|
||||||
import { AddonModForum, AddonModForumProvider } from '../forum.service';
|
import { AddonModForum, AddonModForumProvider } from '../forum';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||||
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
|
||||||
|
@ -73,7 +73,7 @@ export class AddonModForumModuleHandlerService implements CoreCourseModuleHandle
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_forum-handler',
|
class: 'addon-mod_forum-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(_: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): void {
|
action(event: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): void {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.params = options.params || {};
|
options.params = options.params || {};
|
||||||
Object.assign(options.params, { module });
|
Object.assign(options.params, { module });
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
|
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
|
||||||
import { AddonModForum, AddonModForumData, AddonModForumPost, AddonModForumProvider } from '../forum.service';
|
import { AddonModForum, AddonModForumData, AddonModForumPost, AddonModForumProvider } from '../forum';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreWSExternalFile } from '@services/ws';
|
import { CoreWSExternalFile } from '@services/ws';
|
||||||
|
@ -22,7 +22,7 @@ import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } fro
|
||||||
import { CoreUser } from '@features/user/services/user';
|
import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreGroups, CoreGroupsProvider } from '@services/groups';
|
import { CoreGroups, CoreGroupsProvider } from '@services/groups';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModForumSync } from '../sync.service';
|
import { AddonModForumSync } from '../sync';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
|
|
||||||
import { AddonModForum } from '@addons/mod/forum/services/forum.service';
|
import { AddonModForum } from '@addons/mod/forum/services/forum';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
|
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
|
||||||
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
|
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreCronHandler } from '@services/cron';
|
import { CoreCronHandler } from '@services/cron';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModForumSync } from '../sync.service';
|
import { AddonModForumSync } from '../sync';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronization cron handler.
|
* Synchronization cron handler.
|
||||||
|
|
|
@ -29,8 +29,8 @@ import {
|
||||||
AddonModForumDiscussion,
|
AddonModForumDiscussion,
|
||||||
AddonModForumPost,
|
AddonModForumPost,
|
||||||
AddonModForumProvider,
|
AddonModForumProvider,
|
||||||
} from './forum.service';
|
} from './forum';
|
||||||
import { AddonModForumDiscussionOptions, AddonModForumOffline, AddonModForumOfflineReply } from './offline.service';
|
import { AddonModForumDiscussionOptions, AddonModForumOffline, AddonModForumOfflineReply } from './offline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features for forums.
|
* Service that provides some features for forums.
|
|
@ -18,8 +18,13 @@ import { CoreFile } from '@services/file';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModForumProvider } from './forum.service';
|
import { AddonModForumProvider } from './forum';
|
||||||
import { DISCUSSIONS_TABLE, REPLIES_TABLE } from './offline-db';
|
import {
|
||||||
|
AddonModForumOfflineDiscussionDBRecord,
|
||||||
|
AddonModForumOfflineReplyDBRecord,
|
||||||
|
DISCUSSIONS_TABLE,
|
||||||
|
REPLIES_TABLE,
|
||||||
|
} from './database/offline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to handle offline forum.
|
* Service to handle offline forum.
|
||||||
|
@ -69,7 +74,7 @@ export class AddonModForumOfflineProvider {
|
||||||
timecreated: timeCreated,
|
timecreated: timeCreated,
|
||||||
};
|
};
|
||||||
|
|
||||||
const record = await site.getDb().getRecord<AddonModForumOfflineDiscussionRecord>(DISCUSSIONS_TABLE, conditions);
|
const record = await site.getDb().getRecord<AddonModForumOfflineDiscussionDBRecord>(DISCUSSIONS_TABLE, conditions);
|
||||||
|
|
||||||
return this.parseRecordOptions(record);
|
return this.parseRecordOptions(record);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +87,7 @@ export class AddonModForumOfflineProvider {
|
||||||
*/
|
*/
|
||||||
async getAllNewDiscussions(siteId?: string): Promise<AddonModForumOfflineDiscussion[]> {
|
async getAllNewDiscussions(siteId?: string): Promise<AddonModForumOfflineDiscussion[]> {
|
||||||
const site = await CoreSites.instance.getSite(siteId);
|
const site = await CoreSites.instance.getSite(siteId);
|
||||||
const records = await site.getDb().getRecords<AddonModForumOfflineDiscussionRecord>(DISCUSSIONS_TABLE);
|
const records = await site.getDb().getRecords<AddonModForumOfflineDiscussionDBRecord>(DISCUSSIONS_TABLE);
|
||||||
|
|
||||||
return this.parseRecordsOptions(records);
|
return this.parseRecordsOptions(records);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +127,7 @@ export class AddonModForumOfflineProvider {
|
||||||
userid: userId || site.getUserId(),
|
userid: userId || site.getUserId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const records = await site.getDb().getRecords<AddonModForumOfflineDiscussionRecord>(DISCUSSIONS_TABLE, conditions);
|
const records = await site.getDb().getRecords<AddonModForumOfflineDiscussionDBRecord>(DISCUSSIONS_TABLE, conditions);
|
||||||
|
|
||||||
return this.parseRecordsOptions(records);
|
return this.parseRecordsOptions(records);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +160,7 @@ export class AddonModForumOfflineProvider {
|
||||||
userId?: number,
|
userId?: number,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const site = await CoreSites.instance.getSite(siteId);
|
const site = await CoreSites.instance.getSite(siteId);
|
||||||
const data: AddonModForumOfflineDiscussionRecord = {
|
const data: AddonModForumOfflineDiscussionDBRecord = {
|
||||||
forumid: forumId,
|
forumid: forumId,
|
||||||
name: name,
|
name: name,
|
||||||
courseid: courseId,
|
courseid: courseId,
|
||||||
|
@ -196,7 +201,7 @@ export class AddonModForumOfflineProvider {
|
||||||
*/
|
*/
|
||||||
async getAllReplies(siteId?: string): Promise<AddonModForumOfflineReply[]> {
|
async getAllReplies(siteId?: string): Promise<AddonModForumOfflineReply[]> {
|
||||||
const site = await CoreSites.instance.getSite(siteId);
|
const site = await CoreSites.instance.getSite(siteId);
|
||||||
const records = await site.getDb().getRecords<AddonModForumOfflineReplyRecord>(REPLIES_TABLE);
|
const records = await site.getDb().getRecords<AddonModForumOfflineReplyDBRecord>(REPLIES_TABLE);
|
||||||
|
|
||||||
return this.parseRecordsOptions(records);
|
return this.parseRecordsOptions(records);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +241,7 @@ export class AddonModForumOfflineProvider {
|
||||||
userid: userId || site.getUserId(),
|
userid: userId || site.getUserId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const records = await site.getDb().getRecords<AddonModForumOfflineReplyRecord>(REPLIES_TABLE, conditions);
|
const records = await site.getDb().getRecords<AddonModForumOfflineReplyDBRecord>(REPLIES_TABLE, conditions);
|
||||||
|
|
||||||
return this.parseRecordsOptions(records);
|
return this.parseRecordsOptions(records);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +281,7 @@ export class AddonModForumOfflineProvider {
|
||||||
userid: userId || site.getUserId(),
|
userid: userId || site.getUserId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const records = await site.getDb().getRecords<AddonModForumOfflineReplyRecord>(REPLIES_TABLE, conditions);
|
const records = await site.getDb().getRecords<AddonModForumOfflineReplyDBRecord>(REPLIES_TABLE, conditions);
|
||||||
|
|
||||||
return this.parseRecordsOptions(records);
|
return this.parseRecordsOptions(records);
|
||||||
}
|
}
|
||||||
|
@ -309,7 +314,7 @@ export class AddonModForumOfflineProvider {
|
||||||
userId?: number,
|
userId?: number,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const site = await CoreSites.instance.getSite(siteId);
|
const site = await CoreSites.instance.getSite(siteId);
|
||||||
const data: AddonModForumOfflineReplyRecord = {
|
const data: AddonModForumOfflineReplyDBRecord = {
|
||||||
postid: postId,
|
postid: postId,
|
||||||
discussionid: discussionId,
|
discussionid: discussionId,
|
||||||
forumid: forumId,
|
forumid: forumId,
|
||||||
|
@ -437,10 +442,3 @@ export type AddonModForumOfflineReply = {
|
||||||
userid: number;
|
userid: number;
|
||||||
timecreated: number;
|
timecreated: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AddonModForumOfflineDiscussionRecord = Omit<AddonModForumOfflineDiscussion, 'options'> & {
|
|
||||||
options: string;
|
|
||||||
};
|
|
||||||
export type AddonModForumOfflineReplyRecord = Omit<AddonModForumOfflineReply, 'options'> & {
|
|
||||||
options: string;
|
|
||||||
};
|
|
|
@ -31,9 +31,9 @@ import {
|
||||||
AddonModForumAddDiscussionPostWSOptionsObject,
|
AddonModForumAddDiscussionPostWSOptionsObject,
|
||||||
AddonModForumAddDiscussionWSOptionsObject,
|
AddonModForumAddDiscussionWSOptionsObject,
|
||||||
AddonModForumProvider,
|
AddonModForumProvider,
|
||||||
} from './forum.service';
|
} from './forum';
|
||||||
import { AddonModForumHelper } from './helper.service';
|
import { AddonModForumHelper } from './helper';
|
||||||
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumOfflineReply } from './offline.service';
|
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumOfflineReply } from './offline';
|
||||||
|
|
||||||
declare module '@singletons/events' {
|
declare module '@singletons/events' {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreCourse } from '../../course/services/course';
|
import { CoreCourse } from '../../course/services/course';
|
||||||
import { CoreCourses } from '../../courses/services/courses';
|
import { CoreCourses } from '../../courses/services/courses';
|
||||||
import { AddonModForum, AddonModForumData } from '@addons/mod/forum/services/forum.service';
|
import { AddonModForum, AddonModForumData } from '@addons/mod/forum/services/forum';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Items with index 1 and 3 were removed on 2.5 and not being supported in the app.
|
* Items with index 1 and 3 were removed on 2.5 and not being supported in the app.
|
||||||
|
|
Loading…
Reference in New Issue