MOBILE-4616 forum: Move forum constants to a file
parent
94743ed700
commit
67cae258f6
|
@ -22,10 +22,10 @@ import {
|
|||
AddonModForumCanAddDiscussion,
|
||||
AddonModForumData,
|
||||
AddonModForumDiscussion,
|
||||
AddonModForumProvider,
|
||||
AddonModForumSortOrder,
|
||||
} from '../services/forum';
|
||||
import { AddonModForumOffline, AddonModForumOfflineDiscussion } from '../services/forum-offline';
|
||||
import { ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE } from '../constants';
|
||||
|
||||
export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource<AddonModForumDiscussionItem> {
|
||||
|
||||
|
@ -136,7 +136,7 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource
|
|||
* @inheritdoc
|
||||
*/
|
||||
getPageLength(): number {
|
||||
return AddonModForumProvider.DISCUSSIONS_PER_PAGE;
|
||||
return ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,8 @@ import { CoreSites } from '@services/sites';
|
|||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { PopoverController } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { AddonModForum, AddonModForumDiscussion, AddonModForumProvider } from '../../services/forum';
|
||||
import { AddonModForum, AddonModForumDiscussion } from '../../services/forum';
|
||||
import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT } from '../../constants';
|
||||
|
||||
/**
|
||||
* This component is meant to display a popover with the discussion options.
|
||||
|
@ -71,7 +72,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit {
|
|||
locked: response.locked,
|
||||
};
|
||||
|
||||
CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
PopoverController.dismiss({ action: 'lock', value: locked });
|
||||
CoreDomUtils.showToast('addon.mod_forum.lockupdated', true);
|
||||
} catch (error) {
|
||||
|
@ -100,7 +101,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit {
|
|||
pinned: pinned,
|
||||
};
|
||||
|
||||
CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
PopoverController.dismiss({ action: 'pin', value: pinned });
|
||||
CoreDomUtils.showToast('addon.mod_forum.pinupdated', true);
|
||||
} catch (error) {
|
||||
|
@ -129,7 +130,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit {
|
|||
starred: starred,
|
||||
};
|
||||
|
||||
CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
PopoverController.dismiss({ action: 'star', value: starred });
|
||||
CoreDomUtils.showToast('addon.mod_forum.favouriteupdated', true);
|
||||
} catch (error) {
|
||||
|
|
|
@ -20,7 +20,6 @@ import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/
|
|||
import {
|
||||
AddonModForum,
|
||||
AddonModForumData,
|
||||
AddonModForumProvider,
|
||||
AddonModForumSortOrder,
|
||||
AddonModForumDiscussion,
|
||||
AddonModForumNewDiscussionData,
|
||||
|
@ -35,7 +34,6 @@ import { CoreEvents, CoreEventObserver } from '@singletons/events';
|
|||
import {
|
||||
AddonModForumAutoSyncData,
|
||||
AddonModForumManualSyncData,
|
||||
AddonModForumSyncProvider,
|
||||
AddonModForumSyncResult,
|
||||
} from '@addons/mod/forum/services/forum-sync';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -46,7 +44,6 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
|||
import { AddonModForumDiscussionOptionsMenuComponent } from '../discussion-options-menu/discussion-options-menu';
|
||||
import { CoreScreen } from '@services/screen';
|
||||
import { AddonModForumPrefetchHandler } from '../../services/handlers/prefetch';
|
||||
import { AddonModForumModuleHandlerService } from '../../services/handlers/module';
|
||||
import { CoreRatingProvider } from '@features/rating/services/rating';
|
||||
import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync';
|
||||
import { CoreRatingOffline } from '@features/rating/services/rating-offline';
|
||||
|
@ -56,7 +53,17 @@ import { CoreListItemsManager } from '@classes/items-management/list-items-manag
|
|||
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
|
||||
import { CorePromisedValue } from '@classes/promised-value';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants';
|
||||
import {
|
||||
ADDON_MOD_FORUM_AUTO_SYNCED,
|
||||
ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_COMPONENT,
|
||||
ADDON_MOD_FORUM_MANUAL_SYNCED,
|
||||
ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_PAGE_NAME,
|
||||
ADDON_MOD_FORUM_PREFERENCE_SORTORDER,
|
||||
ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_SEARCH_PAGE_NAME,
|
||||
} from '@addons/mod/forum/constants';
|
||||
import { CoreSearchGlobalSearch } from '@features/search/services/global-search';
|
||||
/**
|
||||
* Component that displays a forum entry page.
|
||||
|
@ -70,7 +77,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
|
||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||
|
||||
component = AddonModForumProvider.COMPONENT;
|
||||
component = ADDON_MOD_FORUM_COMPONENT;
|
||||
pluginName = 'forum';
|
||||
descriptionNote?: string;
|
||||
promisedDiscussions: CorePromisedValue<AddonModForumDiscussionsManager>;
|
||||
|
@ -87,7 +94,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
showSearch = false;
|
||||
|
||||
protected fetchContentDefaultError = 'addon.mod_forum.errorgetforum';
|
||||
protected syncEventName = AddonModForumSyncProvider.AUTO_SYNCED;
|
||||
protected syncEventName = ADDON_MOD_FORUM_AUTO_SYNCED;
|
||||
protected syncManualObserver?: CoreEventObserver; // It will observe the sync manual event.
|
||||
protected replyObserver?: CoreEventObserver;
|
||||
protected newDiscObserver?: CoreEventObserver;
|
||||
|
@ -188,7 +195,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
// Initialize discussions manager.
|
||||
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
|
||||
AddonModForumDiscussionsSource,
|
||||
[this.courseId, this.module.id, this.courseContentsPage ? `${AddonModForumModuleHandlerService.PAGE_NAME}/` : ''],
|
||||
[this.courseId, this.module.id, this.courseContentsPage ? `${ADDON_MOD_FORUM_PAGE_NAME}/` : ''],
|
||||
);
|
||||
|
||||
this.sourceUnsubscribe = source.addListener({
|
||||
|
@ -229,20 +236,20 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
this.promisedDiscussions.resolve(new AddonModForumDiscussionsManager(source, this));
|
||||
|
||||
// Refresh data if this forum discussion is synchronized from discussions list.
|
||||
this.syncManualObserver = CoreEvents.on(AddonModForumSyncProvider.MANUAL_SYNCED, (data) => {
|
||||
this.syncManualObserver = CoreEvents.on(ADDON_MOD_FORUM_MANUAL_SYNCED, (data) => {
|
||||
this.autoSyncEventReceived(data);
|
||||
}, this.siteId);
|
||||
|
||||
// Listen for discussions added. When a discussion is added, we reload the data.
|
||||
this.newDiscObserver = CoreEvents.on(
|
||||
AddonModForumProvider.NEW_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT,
|
||||
(data) => this.eventReceived(true, data),
|
||||
);
|
||||
this.replyObserver = CoreEvents.on(
|
||||
AddonModForumProvider.REPLY_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT,
|
||||
(data) => this.eventReceived(false, data),
|
||||
);
|
||||
this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => {
|
||||
this.changeDiscObserver = CoreEvents.on(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data => {
|
||||
if (!this.forum) {
|
||||
return;
|
||||
}
|
||||
|
@ -419,7 +426,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
|
||||
if (updated) {
|
||||
// Sync successful, send event.
|
||||
CoreEvents.trigger(AddonModForumSyncProvider.MANUAL_SYNCED, {
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_MANUAL_SYNCED, {
|
||||
forumId: forum.id,
|
||||
userId: CoreSites.getCurrentSiteUserId(),
|
||||
source: 'index',
|
||||
|
@ -502,7 +509,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
}
|
||||
|
||||
if (this.sortingAvailable) {
|
||||
promises.push(CoreUser.invalidateUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER));
|
||||
promises.push(CoreUser.invalidateUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER));
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
@ -602,7 +609,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
this.discussions.getSource().setDirty(true);
|
||||
|
||||
try {
|
||||
await CoreUser.setUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER, sortOrder.value.toFixed(0));
|
||||
await CoreUser.setUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER, sortOrder.value.toFixed(0));
|
||||
await this.showLoadingAndFetch();
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'Error updating preference.');
|
||||
|
|
|
@ -34,7 +34,6 @@ import {
|
|||
AddonModForumData,
|
||||
AddonModForumDiscussion,
|
||||
AddonModForumPost,
|
||||
AddonModForumProvider,
|
||||
AddonModForumPostFormData,
|
||||
} from '../../services/forum';
|
||||
import { CoreTag } from '@features/tag/services/tag';
|
||||
|
@ -53,6 +52,7 @@ import { CoreFileEntry } from '@services/file-helper';
|
|||
import { AddonModForumSharedPostFormData } from '../../pages/discussion/discussion';
|
||||
import { CoreDom } from '@singletons/dom';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, ADDON_MOD_FORUM_COMPONENT } from '../../constants';
|
||||
|
||||
/**
|
||||
* Components that shows a discussion post, its attachments and the action buttons allowed (reply, etc.).
|
||||
|
@ -162,7 +162,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges
|
|||
};
|
||||
|
||||
CoreEvents.trigger(
|
||||
AddonModForumProvider.CHANGE_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT,
|
||||
data,
|
||||
CoreSites.getCurrentSiteId(),
|
||||
);
|
||||
|
@ -307,7 +307,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges
|
|||
await this.confirmDiscard();
|
||||
|
||||
this.formData.syncId = AddonModForumSync.getDiscussionSyncId(this.discussionId);
|
||||
CoreSync.blockOperation(AddonModForumProvider.COMPONENT, this.formData.syncId);
|
||||
CoreSync.blockOperation(ADDON_MOD_FORUM_COMPONENT, this.formData.syncId);
|
||||
|
||||
this.setFormData(
|
||||
this.post.parentid,
|
||||
|
@ -546,7 +546,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges
|
|||
return;
|
||||
}
|
||||
|
||||
CoreSync.unblockOperation(AddonModForumProvider.COMPONENT, this.formData.syncId);
|
||||
CoreSync.unblockOperation(ADDON_MOD_FORUM_COMPONENT, this.formData.syncId);
|
||||
delete this.formData.syncId;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,4 +12,30 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
export const ADDON_MOD_FORUM_PAGE_NAME = 'mod_forum';
|
||||
export const ADDON_MOD_FORUM_SEARCH_PAGE_NAME = 'forum/search';
|
||||
|
||||
export const ADDON_MOD_FORUM_COMPONENT = 'mmaModForum';
|
||||
|
||||
export const ADDON_MOD_FORUM_AUTO_SYNCED = 'addon_mod_forum_autom_synced';
|
||||
export const ADDON_MOD_FORUM_MANUAL_SYNCED = 'addon_mod_forum_manual_synced';
|
||||
|
||||
export const ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE = 10; // Max of discussions per page.
|
||||
export const ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT = 'addon_mod_forum_new_discussion';
|
||||
export const ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT = 'addon_mod_forum_reply_discussion';
|
||||
export const ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT = 'addon_mod_forum_change_discussion_status';
|
||||
export const ADDON_MOD_FORUM_MARK_READ_EVENT = 'addon_mod_forum_mark_read';
|
||||
|
||||
export const ADDON_MOD_FORUM_PREFERENCE_SORTORDER = 'forum_discussionlistsortorder';
|
||||
|
||||
export const enum AddonModForumSortorder {
|
||||
LASTPOST_DESC = 1,
|
||||
LASTPOST_ASC = 2,
|
||||
CREATED_DESC = 3,
|
||||
CREATED_ASC = 4,
|
||||
REPLIES_DESC = 5,
|
||||
REPLIES_ASC = 6,
|
||||
}
|
||||
|
||||
export const ADDON_MOD_FORUM_ALL_PARTICIPANTS = -1;
|
||||
export const ADDON_MOD_FORUM_ALL_GROUPS = -2;
|
||||
|
|
|
@ -36,4 +36,4 @@ const routes: Routes = [{
|
|||
AddonModForumDiscussionPage,
|
||||
],
|
||||
})
|
||||
export class AddonModForumDiscussionLazyModule {}
|
||||
export default class AddonModForumDiscussionLazyModule {}
|
||||
|
|
|
@ -29,15 +29,15 @@ const mobileRoutes: Routes = [
|
|||
},
|
||||
{
|
||||
path: ':courseId/:cmId/new/:timeCreated',
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule),
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module'),
|
||||
},
|
||||
{
|
||||
path: ':courseId/:cmId/:discussionId',
|
||||
loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule),
|
||||
loadChildren: () => import('./forum-discussion-lazy.module'),
|
||||
},
|
||||
{
|
||||
path: 'discussion/:discussionId', // Only for discussion link handling.
|
||||
loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule),
|
||||
loadChildren: () => import('./forum-discussion-lazy.module'),
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -48,11 +48,11 @@ const tabletRoutes: Routes = [
|
|||
children: [
|
||||
{
|
||||
path: 'new/:timeCreated',
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule),
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module'),
|
||||
},
|
||||
{
|
||||
path: ':discussionId',
|
||||
loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule),
|
||||
loadChildren: () => import('./forum-discussion-lazy.module'),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -73,4 +73,4 @@ const routes: Routes = [
|
|||
AddonModForumIndexPage,
|
||||
],
|
||||
})
|
||||
export class AddonModForumLazyModule {}
|
||||
export default class AddonModForumLazyModule {}
|
||||
|
|
|
@ -38,4 +38,4 @@ const routes: Routes = [{
|
|||
AddonModForumNewDiscussionPage,
|
||||
],
|
||||
})
|
||||
export class AddonModForumNewDiscussionLazyModule {}
|
||||
export default class AddonModForumNewDiscussionLazyModule {}
|
||||
|
|
|
@ -35,4 +35,4 @@ const routes: Routes = [{
|
|||
AddonModForumSearchPage,
|
||||
],
|
||||
})
|
||||
export class AddonModForumSearchLazyModule {}
|
||||
export default class AddonModForumSearchLazyModule {}
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
|
|||
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
import { CoreScreen } from '@services/screen';
|
||||
|
||||
import { AddonModForumModuleHandler, AddonModForumModuleHandlerService } from './services/handlers/module';
|
||||
import { AddonModForumModuleHandler } from './services/handlers/module';
|
||||
import { SITE_SCHEMA } from './services/database/offline';
|
||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import { AddonModForumPrefetchHandler } from './services/handlers/prefetch';
|
||||
|
@ -37,36 +37,35 @@ import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate';
|
|||
import { AddonModForumTagAreaHandler } from './services/handlers/tag-area';
|
||||
import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate';
|
||||
import { AddonModForumPushClickHandler } from './services/handlers/push-click';
|
||||
import { AddonModForumProvider } from './services/forum';
|
||||
import { COURSE_CONTENTS_PATH } from '@features/course/course.module';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants';
|
||||
import { ADDON_MOD_FORUM_COMPONENT, ADDON_MOD_FORUM_PAGE_NAME, ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants';
|
||||
|
||||
const mainMenuRoutes: Routes = [
|
||||
{
|
||||
path: ADDON_MOD_FORUM_SEARCH_PAGE_NAME,
|
||||
loadChildren: () => import('./forum-search-lazy.module').then(m => m.AddonModForumSearchLazyModule),
|
||||
loadChildren: () => import('./forum-search-lazy.module'),
|
||||
},
|
||||
{
|
||||
path: `${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/:discussionId`,
|
||||
loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule),
|
||||
path: `${ADDON_MOD_FORUM_PAGE_NAME}/discussion/:discussionId`,
|
||||
loadChildren: () => import('./forum-discussion-lazy.module'),
|
||||
data: { swipeEnabled: false },
|
||||
},
|
||||
{
|
||||
path: AddonModForumModuleHandlerService.PAGE_NAME,
|
||||
loadChildren: () => import('./forum-lazy.module').then(m => m.AddonModForumLazyModule),
|
||||
path: ADDON_MOD_FORUM_PAGE_NAME,
|
||||
loadChildren: () => import('./forum-lazy.module'),
|
||||
},
|
||||
...conditionalRoutes(
|
||||
[
|
||||
{
|
||||
path: `${COURSE_CONTENTS_PATH}/${AddonModForumModuleHandlerService.PAGE_NAME}/new/:timeCreated`,
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule),
|
||||
data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` },
|
||||
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`,
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module'),
|
||||
data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` },
|
||||
},
|
||||
{
|
||||
path: `${COURSE_CONTENTS_PATH}/${AddonModForumModuleHandlerService.PAGE_NAME}/:discussionId`,
|
||||
loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule),
|
||||
data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` },
|
||||
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`,
|
||||
loadChildren: () => import('./forum-discussion-lazy.module'),
|
||||
data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` },
|
||||
},
|
||||
],
|
||||
() => CoreScreen.isMobile,
|
||||
|
@ -77,14 +76,14 @@ const mainMenuRoutes: Routes = [
|
|||
const courseContentsRoutes: Routes = conditionalRoutes(
|
||||
[
|
||||
{
|
||||
path: `${AddonModForumModuleHandlerService.PAGE_NAME}/new/:timeCreated`,
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule),
|
||||
data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` },
|
||||
path: `${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`,
|
||||
loadChildren: () => import('./forum-new-discussion-lazy.module'),
|
||||
data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` },
|
||||
},
|
||||
{
|
||||
path: `${AddonModForumModuleHandlerService.PAGE_NAME}/:discussionId`,
|
||||
loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule),
|
||||
data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` },
|
||||
path: `${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`,
|
||||
loadChildren: () => import('./forum-discussion-lazy.module'),
|
||||
data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` },
|
||||
},
|
||||
],
|
||||
() => CoreScreen.isTablet,
|
||||
|
@ -115,7 +114,7 @@ const courseContentsRoutes: Routes = conditionalRoutes(
|
|||
CoreTagAreaDelegate.registerHandler(AddonModForumTagAreaHandler.instance);
|
||||
CorePushNotificationsDelegate.registerClickHandler(AddonModForumPushClickHandler.instance);
|
||||
|
||||
CoreCourseHelper.registerModuleReminderClick(AddonModForumProvider.COMPONENT);
|
||||
CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_FORUM_COMPONENT);
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
@ -42,15 +42,22 @@ import {
|
|||
AddonModForumData,
|
||||
AddonModForumDiscussion,
|
||||
AddonModForumPost,
|
||||
AddonModForumProvider,
|
||||
AddonModForumPostFormData,
|
||||
AddonModForumChangeDiscussionData,
|
||||
AddonModForumReplyDiscussionData,
|
||||
} from '../../services/forum';
|
||||
import { AddonModForumHelper } from '../../services/forum-helper';
|
||||
import { AddonModForumOffline } from '../../services/forum-offline';
|
||||
import { AddonModForumSync, AddonModForumSyncProvider } from '../../services/forum-sync';
|
||||
import { AddonModForumSync } from '../../services/forum-sync';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import {
|
||||
ADDON_MOD_FORUM_AUTO_SYNCED,
|
||||
ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_COMPONENT,
|
||||
ADDON_MOD_FORUM_MANUAL_SYNCED,
|
||||
ADDON_MOD_FORUM_MARK_READ_EVENT,
|
||||
ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT,
|
||||
} from '../../constants';
|
||||
|
||||
type SortType = 'flat-newest' | 'flat-oldest' | 'nested';
|
||||
|
||||
|
@ -101,7 +108,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
refreshIcon = CoreConstants.ICON_LOADING;
|
||||
syncIcon = CoreConstants.ICON_LOADING;
|
||||
discussionStr = '';
|
||||
component = AddonModForumProvider.COMPONENT;
|
||||
component = ADDON_MOD_FORUM_COMPONENT;
|
||||
cmId?: number;
|
||||
canPin = false;
|
||||
availabilityMessage: string | null = null;
|
||||
|
@ -216,7 +223,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
const discussion = this.discussion;
|
||||
|
||||
// Refresh data if this discussion is synchronized automatically.
|
||||
this.syncObserver = CoreEvents.on(AddonModForumSyncProvider.AUTO_SYNCED, data => {
|
||||
this.syncObserver = CoreEvents.on(ADDON_MOD_FORUM_AUTO_SYNCED, data => {
|
||||
if (data.forumId == this.forumId && this.discussionId == data.discussionId
|
||||
&& data.userId == CoreSites.getCurrentSiteUserId()) {
|
||||
// Refresh the data.
|
||||
|
@ -226,7 +233,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
}, CoreSites.getCurrentSiteId());
|
||||
|
||||
// Refresh data if this forum discussion is synchronized from discussions list.
|
||||
this.syncManualObserver = CoreEvents.on(AddonModForumSyncProvider.MANUAL_SYNCED, data => {
|
||||
this.syncManualObserver = CoreEvents.on(ADDON_MOD_FORUM_MANUAL_SYNCED, data => {
|
||||
if (data.source != 'discussion' && data.forumId == this.forumId &&
|
||||
data.userId == CoreSites.getCurrentSiteUserId()) {
|
||||
// Refresh the data.
|
||||
|
@ -255,7 +262,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
}
|
||||
});
|
||||
|
||||
this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => {
|
||||
this.changeDiscObserver = CoreEvents.on(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data => {
|
||||
if (discussion && this.forumId && (this.forumId === data.forumId || data.cmId === this.cmId)) {
|
||||
AddonModForum.invalidateDiscussionsList(this.forumId).finally(() => {
|
||||
if (data.locked !== undefined) {
|
||||
|
@ -607,7 +614,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
|
||||
if (result && result.updated && this.forumId) {
|
||||
// Sync successful, send event.
|
||||
CoreEvents.trigger(AddonModForumSyncProvider.MANUAL_SYNCED, {
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_MANUAL_SYNCED, {
|
||||
forumId: this.forumId,
|
||||
userId: CoreSites.getCurrentSiteUserId(),
|
||||
source: 'discussion',
|
||||
|
@ -719,7 +726,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
cmId: this.cmId,
|
||||
locked: this.discussion.locked,
|
||||
};
|
||||
CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
|
||||
CoreDomUtils.showToast('addon.mod_forum.lockupdated', true);
|
||||
} catch (error) {
|
||||
|
@ -752,7 +759,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
cmId: this.cmId,
|
||||
pinned: this.discussion.pinned,
|
||||
};
|
||||
CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
|
||||
CoreDomUtils.showToast('addon.mod_forum.pinupdated', true);
|
||||
} catch (error) {
|
||||
|
@ -785,7 +792,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
cmId: this.cmId,
|
||||
starred: this.discussion.starred,
|
||||
};
|
||||
CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
|
||||
CoreDomUtils.showToast('addon.mod_forum.favouriteupdated', true);
|
||||
} catch (error) {
|
||||
|
@ -809,7 +816,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
discussionId: this.discussionId,
|
||||
cmId: this.cmId,
|
||||
};
|
||||
CoreEvents.trigger(AddonModForumProvider.REPLY_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId());
|
||||
|
||||
this.discussionLoaded = false;
|
||||
this.refreshPosts().finally(() => {
|
||||
|
@ -868,7 +875,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
}
|
||||
|
||||
// Trigger mark read posts.
|
||||
CoreEvents.trigger(AddonModForumProvider.MARK_READ_EVENT, {
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_MARK_READ_EVENT, {
|
||||
courseId: this.courseId,
|
||||
moduleId: this.cmId,
|
||||
}, CoreSites.getCurrentSiteId());
|
||||
|
|
|
@ -23,10 +23,9 @@ import {
|
|||
AddonModForumAccessInformation,
|
||||
AddonModForumCanAddDiscussion,
|
||||
AddonModForumData,
|
||||
AddonModForumProvider,
|
||||
} from '@addons/mod/forum/services/forum';
|
||||
import { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor';
|
||||
import { AddonModForumSync, AddonModForumSyncProvider } from '@addons/mod/forum/services/forum-sync';
|
||||
import { AddonModForumSync } from '@addons/mod/forum/services/forum-sync';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { Translate } from '@singletons';
|
||||
|
@ -45,6 +44,13 @@ import { AddonModForumDiscussionsSource } from '../../classes/forum-discussions-
|
|||
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
|
||||
import { CoreTime } from '@singletons/time';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import {
|
||||
ADDON_MOD_FORUM_ALL_GROUPS,
|
||||
ADDON_MOD_FORUM_ALL_PARTICIPANTS,
|
||||
ADDON_MOD_FORUM_AUTO_SYNCED,
|
||||
ADDON_MOD_FORUM_COMPONENT,
|
||||
ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT,
|
||||
} from '../../constants';
|
||||
|
||||
type NewDiscussionData = {
|
||||
subject: string;
|
||||
|
@ -69,7 +75,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
@ViewChild('newDiscFormEl') formElement!: ElementRef;
|
||||
@ViewChild(CoreEditorRichTextEditorComponent) messageEditor!: CoreEditorRichTextEditorComponent;
|
||||
|
||||
component = AddonModForumProvider.COMPONENT;
|
||||
component = ADDON_MOD_FORUM_COMPONENT;
|
||||
messageControl = new FormControl<string | null>(null);
|
||||
groupsLoaded = false;
|
||||
showGroups = false;
|
||||
|
@ -133,7 +139,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
this.initialGroupId = CoreNavigator.getRouteNumberParam('groupId');
|
||||
|
||||
// Discussion list uses 0 for all participants, but this page WebServices use a different value. Convert it.
|
||||
this.initialGroupId = this.initialGroupId === 0 ? AddonModForumProvider.ALL_PARTICIPANTS : this.initialGroupId;
|
||||
this.initialGroupId = this.initialGroupId === 0 ? ADDON_MOD_FORUM_ALL_PARTICIPANTS : this.initialGroupId;
|
||||
|
||||
if (this.timeCreated !== 0 && (routeData.swipeEnabled ?? true)) {
|
||||
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
|
||||
|
@ -168,7 +174,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
}
|
||||
|
||||
// Refresh data if this discussion is synchronized automatically.
|
||||
this.syncObserver = CoreEvents.on(AddonModForumSyncProvider.AUTO_SYNCED, data => {
|
||||
this.syncObserver = CoreEvents.on(ADDON_MOD_FORUM_AUTO_SYNCED, data => {
|
||||
if (data.forumId == this.forumId && data.userId == CoreSites.getCurrentSiteUserId()) {
|
||||
CoreDomUtils.showAlertTranslated('core.notice', 'core.contenteditingsynced');
|
||||
this.returnToDiscussions();
|
||||
|
@ -262,7 +268,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
await AddonModForumSync.waitForSync(this.syncId).then(() => {
|
||||
// Do not block if the scope is already destroyed.
|
||||
if (!this.isDestroyed) {
|
||||
CoreSync.blockOperation(AddonModForumProvider.COMPONENT, this.syncId);
|
||||
CoreSync.blockOperation(ADDON_MOD_FORUM_COMPONENT, this.syncId);
|
||||
}
|
||||
|
||||
return AddonModForumOffline.instance
|
||||
|
@ -270,7 +276,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
.then(async (discussion) => {
|
||||
this.hasOffline = true;
|
||||
discussion.options = discussion.options || {};
|
||||
if (discussion.groupid == AddonModForumProvider.ALL_GROUPS) {
|
||||
if (discussion.groupid == ADDON_MOD_FORUM_ALL_GROUPS) {
|
||||
this.newDiscussion.groupId = this.groups[0].id;
|
||||
this.newDiscussion.postToAllGroups = true;
|
||||
} else {
|
||||
|
@ -438,7 +444,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
if (canAdd) {
|
||||
groups.unshift({
|
||||
courseid: this.courseId,
|
||||
id: AddonModForumProvider.ALL_PARTICIPANTS,
|
||||
id: ADDON_MOD_FORUM_ALL_PARTICIPANTS,
|
||||
name: Translate.instant('core.allparticipants'),
|
||||
});
|
||||
}
|
||||
|
@ -479,7 +485,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
CoreFileUploader.clearTmpFiles(this.newDiscussion.files);
|
||||
|
||||
CoreEvents.trigger(
|
||||
AddonModForumProvider.NEW_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT,
|
||||
{
|
||||
forumId: this.forumId,
|
||||
cmId: this.cmId,
|
||||
|
@ -683,7 +689,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
*/
|
||||
ngOnDestroy(): void {
|
||||
if (this.syncId) {
|
||||
CoreSync.unblockOperation(AddonModForumProvider.COMPONENT, this.syncId);
|
||||
CoreSync.unblockOperation(ADDON_MOD_FORUM_COMPONENT, this.syncId);
|
||||
}
|
||||
this.isDestroyed = true;
|
||||
this.discussions?.destroy();
|
||||
|
|
|
@ -28,10 +28,10 @@ import {
|
|||
AddonModForumData,
|
||||
AddonModForumDiscussion,
|
||||
AddonModForumPost,
|
||||
AddonModForumProvider,
|
||||
} from './forum';
|
||||
import { AddonModForumDiscussionOptions, AddonModForumOffline, AddonModForumOfflineReply } from './forum-offline';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { ADDON_MOD_FORUM_ALL_GROUPS, ADDON_MOD_FORUM_COMPONENT } from '../constants';
|
||||
|
||||
/**
|
||||
* Service that provides some features for forums.
|
||||
|
@ -76,7 +76,7 @@ export class AddonModForumHelperProvider {
|
|||
// Convenience function to store a message to be synchronized later.
|
||||
const storeOffline = async (): Promise<void> => {
|
||||
// Multiple groups, the discussion is being posted to all groups.
|
||||
const groupId = groupIds.length > 1 ? AddonModForumProvider.ALL_GROUPS : groupIds[0];
|
||||
const groupId = groupIds.length > 1 ? ADDON_MOD_FORUM_ALL_GROUPS : groupIds[0];
|
||||
|
||||
if (offlineAttachments && options) {
|
||||
options.attachmentsid = offlineAttachments;
|
||||
|
@ -502,7 +502,7 @@ export class AddonModForumHelperProvider {
|
|||
return this.storeNewDiscussionFiles(forumId, timecreated, files, siteId);
|
||||
}
|
||||
|
||||
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId);
|
||||
return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_FORUM_COMPONENT, forumId, siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -544,7 +544,7 @@ export class AddonModForumHelperProvider {
|
|||
return this.storeReplyFiles(forumId, postId, files, siteId, userId);
|
||||
}
|
||||
|
||||
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId);
|
||||
return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_FORUM_COMPONENT, forumId, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import { CoreFile } from '@services/file';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModForumProvider } from './forum';
|
||||
import {
|
||||
AddonModForumOfflineDiscussionDBRecord,
|
||||
AddonModForumOfflineReplyDBRecord,
|
||||
|
@ -26,6 +25,7 @@ import {
|
|||
REPLIES_TABLE,
|
||||
} from './database/offline';
|
||||
import { CorePath } from '@singletons/path';
|
||||
import { ADDON_MOD_FORUM_ALL_PARTICIPANTS } from '../constants';
|
||||
|
||||
/**
|
||||
* Service to handle offline forum.
|
||||
|
@ -168,7 +168,7 @@ export class AddonModForumOfflineProvider {
|
|||
subject: subject,
|
||||
message: message,
|
||||
options: JSON.stringify(options || {}),
|
||||
groupid: groupId || AddonModForumProvider.ALL_PARTICIPANTS,
|
||||
groupid: groupId || ADDON_MOD_FORUM_ALL_PARTICIPANTS,
|
||||
userid: userId || site.getUserId(),
|
||||
timecreated: timeCreated || Date.now(),
|
||||
};
|
||||
|
|
|
@ -29,10 +29,15 @@ import {
|
|||
AddonModForum,
|
||||
AddonModForumAddDiscussionPostWSOptionsObject,
|
||||
AddonModForumAddDiscussionWSOptionsObject,
|
||||
AddonModForumProvider,
|
||||
} from './forum';
|
||||
import { AddonModForumHelper } from './forum-helper';
|
||||
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumOfflineReply } from './forum-offline';
|
||||
import {
|
||||
ADDON_MOD_FORUM_ALL_GROUPS,
|
||||
ADDON_MOD_FORUM_AUTO_SYNCED,
|
||||
ADDON_MOD_FORUM_COMPONENT,
|
||||
ADDON_MOD_FORUM_MANUAL_SYNCED,
|
||||
} from '../constants';
|
||||
|
||||
declare module '@singletons/events' {
|
||||
|
||||
|
@ -42,8 +47,8 @@ declare module '@singletons/events' {
|
|||
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
||||
*/
|
||||
export interface CoreEventsData {
|
||||
[AddonModForumSyncProvider.AUTO_SYNCED]: AddonModForumAutoSyncData;
|
||||
[AddonModForumSyncProvider.MANUAL_SYNCED]: AddonModForumManualSyncData;
|
||||
[ADDON_MOD_FORUM_AUTO_SYNCED]: AddonModForumAutoSyncData;
|
||||
[ADDON_MOD_FORUM_MANUAL_SYNCED]: AddonModForumManualSyncData;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,9 +59,6 @@ declare module '@singletons/events' {
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModForumSyncResult> {
|
||||
|
||||
static readonly AUTO_SYNCED = 'addon_mod_forum_autom_synced';
|
||||
static readonly MANUAL_SYNCED = 'addon_mod_forum_manual_synced';
|
||||
|
||||
protected componentTranslatableString = 'forum';
|
||||
|
||||
constructor() {
|
||||
|
@ -100,7 +102,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
|
||||
if (result && result.updated) {
|
||||
// Sync successful, send event.
|
||||
CoreEvents.trigger(AddonModForumSyncProvider.AUTO_SYNCED, {
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_AUTO_SYNCED, {
|
||||
forumId: discussion.forumid,
|
||||
userId: discussion.userid,
|
||||
warnings: result.warnings,
|
||||
|
@ -134,7 +136,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
|
||||
if (result && result.updated) {
|
||||
// Sync successful, send event.
|
||||
CoreEvents.trigger(AddonModForumSyncProvider.AUTO_SYNCED, {
|
||||
CoreEvents.trigger(ADDON_MOD_FORUM_AUTO_SYNCED, {
|
||||
forumId: reply.forumid,
|
||||
discussionId: reply.discussionid,
|
||||
userId: reply.userid,
|
||||
|
@ -207,7 +209,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
}
|
||||
|
||||
// Verify that forum isn't blocked.
|
||||
if (CoreSync.isBlocked(AddonModForumProvider.COMPONENT, syncId, siteId)) {
|
||||
if (CoreSync.isBlocked(ADDON_MOD_FORUM_COMPONENT, syncId, siteId)) {
|
||||
this.logger.debug('Cannot sync forum ' + forumId + ' because it is blocked.');
|
||||
|
||||
throw new Error(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
|
||||
|
@ -223,7 +225,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
// Sync offline logs.
|
||||
const syncDiscussions = async (): Promise<AddonModForumSyncResult> => {
|
||||
await CoreUtils.ignoreErrors(
|
||||
CoreCourseLogHelper.syncActivity(AddonModForumProvider.COMPONENT, forumId, siteId),
|
||||
CoreCourseLogHelper.syncActivity(ADDON_MOD_FORUM_COMPONENT, forumId, siteId),
|
||||
);
|
||||
|
||||
// Get offline responses to be sent.
|
||||
|
@ -238,7 +240,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
|
||||
const promises = discussions.map(async discussion => {
|
||||
const errors: Error[] = [];
|
||||
const groupIds = discussion.groupid === AddonModForumProvider.ALL_GROUPS
|
||||
const groupIds = discussion.groupid === ADDON_MOD_FORUM_ALL_GROUPS
|
||||
? await AddonModForum.instance
|
||||
.getForumById(discussion.courseid, discussion.forumid, { siteId })
|
||||
.then(forum => CoreGroups.getActivityAllowedGroups(forum.cmid))
|
||||
|
@ -439,7 +441,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
}
|
||||
|
||||
// Verify that forum isn't blocked.
|
||||
if (CoreSync.isBlocked(AddonModForumProvider.COMPONENT, syncId, siteId)) {
|
||||
if (CoreSync.isBlocked(ADDON_MOD_FORUM_COMPONENT, syncId, siteId)) {
|
||||
this.logger.debug('Cannot sync forum discussion ' + discussionId + ' because it is blocked.');
|
||||
|
||||
throw new Error(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
|
||||
|
@ -607,7 +609,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
}
|
||||
}
|
||||
|
||||
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId);
|
||||
return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_FORUM_COMPONENT, forumId, siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,8 +30,18 @@ import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWar
|
|||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumReplyOptions } from './forum-offline';
|
||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||
|
||||
const ROOT_CACHE_KEY = 'mmaModForum:';
|
||||
import {
|
||||
ADDON_MOD_FORUM_ALL_GROUPS,
|
||||
ADDON_MOD_FORUM_ALL_PARTICIPANTS,
|
||||
ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_COMPONENT,
|
||||
ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE,
|
||||
ADDON_MOD_FORUM_MARK_READ_EVENT,
|
||||
ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT,
|
||||
ADDON_MOD_FORUM_PREFERENCE_SORTORDER,
|
||||
ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT,
|
||||
AddonModForumSortorder,
|
||||
} from '../constants';
|
||||
|
||||
declare module '@singletons/events' {
|
||||
|
||||
|
@ -41,10 +51,10 @@ declare module '@singletons/events' {
|
|||
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
||||
*/
|
||||
export interface CoreEventsData {
|
||||
[AddonModForumProvider.NEW_DISCUSSION_EVENT]: AddonModForumNewDiscussionData;
|
||||
[AddonModForumProvider.REPLY_DISCUSSION_EVENT]: AddonModForumReplyDiscussionData;
|
||||
[AddonModForumProvider.CHANGE_DISCUSSION_EVENT]: AddonModForumChangeDiscussionData;
|
||||
[AddonModForumProvider.MARK_READ_EVENT]: AddonModForumMarkReadData;
|
||||
[ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT]: AddonModForumNewDiscussionData;
|
||||
[ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT]: AddonModForumReplyDiscussionData;
|
||||
[ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT]: AddonModForumChangeDiscussionData;
|
||||
[ADDON_MOD_FORUM_MARK_READ_EVENT]: AddonModForumMarkReadData;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,24 +65,7 @@ declare module '@singletons/events' {
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModForumProvider {
|
||||
|
||||
static readonly COMPONENT = 'mmaModForum';
|
||||
static readonly DISCUSSIONS_PER_PAGE = 10; // Max of discussions per page.
|
||||
static readonly NEW_DISCUSSION_EVENT = 'addon_mod_forum_new_discussion';
|
||||
static readonly REPLY_DISCUSSION_EVENT = 'addon_mod_forum_reply_discussion';
|
||||
static readonly CHANGE_DISCUSSION_EVENT = 'addon_mod_forum_change_discussion_status';
|
||||
static readonly MARK_READ_EVENT = 'addon_mod_forum_mark_read';
|
||||
static readonly LEAVING_POSTS_PAGE = 'addon_mod_forum_leaving_posts_page';
|
||||
|
||||
static readonly PREFERENCE_SORTORDER = 'forum_discussionlistsortorder';
|
||||
static readonly SORTORDER_LASTPOST_DESC = 1;
|
||||
static readonly SORTORDER_LASTPOST_ASC = 2;
|
||||
static readonly SORTORDER_CREATED_DESC = 3;
|
||||
static readonly SORTORDER_CREATED_ASC = 4;
|
||||
static readonly SORTORDER_REPLIES_DESC = 5;
|
||||
static readonly SORTORDER_REPLIES_ASC = 6;
|
||||
|
||||
static readonly ALL_PARTICIPANTS = -1;
|
||||
static readonly ALL_GROUPS = -2;
|
||||
protected static readonly ROOT_CACHE_KEY = 'mmaModForum:';
|
||||
|
||||
/**
|
||||
* Get cache key for can add discussion WS calls.
|
||||
|
@ -93,7 +86,7 @@ export class AddonModForumProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getCommonCanAddDiscussionCacheKey(forumId: number): string {
|
||||
return ROOT_CACHE_KEY + 'canadddiscussion:' + forumId + ':';
|
||||
return AddonModForumProvider.ROOT_CACHE_KEY + 'canadddiscussion:' + forumId + ':';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,7 +96,7 @@ export class AddonModForumProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getForumDataPrefixCacheKey(forumId: number): string {
|
||||
return ROOT_CACHE_KEY + forumId;
|
||||
return AddonModForumProvider.ROOT_CACHE_KEY + forumId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +129,7 @@ export class AddonModForumProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getForumDataCacheKey(courseId: number): string {
|
||||
return ROOT_CACHE_KEY + 'forum:' + courseId;
|
||||
return AddonModForumProvider.ROOT_CACHE_KEY + 'forum:' + courseId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +140,7 @@ export class AddonModForumProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getAccessInformationCacheKey(forumId: number): string {
|
||||
return ROOT_CACHE_KEY + 'accessInformation:' + forumId;
|
||||
return AddonModForumProvider.ROOT_CACHE_KEY + 'accessInformation:' + forumId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,7 +151,7 @@ export class AddonModForumProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getDiscussionPostsCacheKey(discussionId: number): string {
|
||||
return ROOT_CACHE_KEY + 'discussion:' + discussionId;
|
||||
return AddonModForumProvider.ROOT_CACHE_KEY + 'discussion:' + discussionId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,7 +161,7 @@ export class AddonModForumProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getDiscussionsListCommonCacheKey(forumId: number): string {
|
||||
return ROOT_CACHE_KEY + 'discussions:' + forumId;
|
||||
return AddonModForumProvider.ROOT_CACHE_KEY + 'discussions:' + forumId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,7 +175,7 @@ export class AddonModForumProvider {
|
|||
protected getDiscussionsListCacheKey(forumId: number, sortOrder: number, groupId?: number): string {
|
||||
let key = this.getDiscussionsListCommonCacheKey(forumId);
|
||||
|
||||
if (sortOrder != AddonModForumProvider.SORTORDER_LASTPOST_DESC) {
|
||||
if (sortOrder !== AddonModForumSortorder.LASTPOST_DESC) {
|
||||
key += ':' + sortOrder;
|
||||
}
|
||||
if (groupId) {
|
||||
|
@ -257,7 +250,7 @@ export class AddonModForumProvider {
|
|||
};
|
||||
const preSets = {
|
||||
cacheKey: this.getCanAddDiscussionCacheKey(forumId, groupId),
|
||||
component: AddonModForumProvider.COMPONENT,
|
||||
component: ADDON_MOD_FORUM_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -292,7 +285,7 @@ export class AddonModForumProvider {
|
|||
* - cancreateattachment (boolean)
|
||||
*/
|
||||
canAddDiscussionToAll(forumId: number, options: CoreCourseCommonModWSOptions = {}): Promise<AddonModForumCanAddDiscussion> {
|
||||
return this.canAddDiscussion(forumId, AddonModForumProvider.ALL_PARTICIPANTS, options);
|
||||
return this.canAddDiscussion(forumId, ADDON_MOD_FORUM_ALL_PARTICIPANTS, options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,9 +387,9 @@ export class AddonModForumProvider {
|
|||
|
||||
// Format discussions.
|
||||
discussions.forEach((disc) => {
|
||||
if (disc.groupid == AddonModForumProvider.ALL_PARTICIPANTS) {
|
||||
if (disc.groupid == ADDON_MOD_FORUM_ALL_PARTICIPANTS) {
|
||||
disc.groupname = strAllParts;
|
||||
} else if (disc.groupid == AddonModForumProvider.ALL_GROUPS) {
|
||||
} else if (disc.groupid == ADDON_MOD_FORUM_ALL_GROUPS) {
|
||||
// Offline discussions only.
|
||||
disc.groupname = strAllGroups;
|
||||
} else {
|
||||
|
@ -427,7 +420,7 @@ export class AddonModForumProvider {
|
|||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getForumDataCacheKey(courseId),
|
||||
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
||||
component: AddonModForumProvider.COMPONENT,
|
||||
component: ADDON_MOD_FORUM_COMPONENT,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
|
||||
};
|
||||
|
||||
|
@ -456,7 +449,7 @@ export class AddonModForumProvider {
|
|||
const preSets = {
|
||||
cacheKey: this.getDiscussionPostDataCacheKey(forumId, discussionId, postId),
|
||||
updateFrequency: CoreSite.FREQUENCY_USUALLY,
|
||||
component: AddonModForumProvider.COMPONENT,
|
||||
component: ADDON_MOD_FORUM_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -537,7 +530,7 @@ export class AddonModForumProvider {
|
|||
};
|
||||
const preSets = {
|
||||
cacheKey: this.getAccessInformationCacheKey(forumId),
|
||||
component: AddonModForumProvider.COMPONENT,
|
||||
component: ADDON_MOD_FORUM_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -607,7 +600,7 @@ export class AddonModForumProvider {
|
|||
};
|
||||
const preSets = {
|
||||
cacheKey: this.getDiscussionPostsCacheKey(discussionId),
|
||||
component: AddonModForumProvider.COMPONENT,
|
||||
component: ADDON_MOD_FORUM_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -684,7 +677,7 @@ export class AddonModForumProvider {
|
|||
const sortOrders = [
|
||||
{
|
||||
label: 'addon.mod_forum.discussionlistsortbylastpostdesc',
|
||||
value: AddonModForumProvider.SORTORDER_LASTPOST_DESC,
|
||||
value: AddonModForumSortorder.LASTPOST_DESC,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -692,23 +685,23 @@ export class AddonModForumProvider {
|
|||
sortOrders.push(
|
||||
{
|
||||
label: 'addon.mod_forum.discussionlistsortbylastpostasc',
|
||||
value: AddonModForumProvider.SORTORDER_LASTPOST_ASC,
|
||||
value: AddonModForumSortorder.LASTPOST_ASC,
|
||||
},
|
||||
{
|
||||
label: 'addon.mod_forum.discussionlistsortbycreateddesc',
|
||||
value: AddonModForumProvider.SORTORDER_CREATED_DESC,
|
||||
value: AddonModForumSortorder.CREATED_DESC,
|
||||
},
|
||||
{
|
||||
label: 'addon.mod_forum.discussionlistsortbycreatedasc',
|
||||
value: AddonModForumProvider.SORTORDER_CREATED_ASC,
|
||||
value: AddonModForumSortorder.CREATED_ASC,
|
||||
},
|
||||
{
|
||||
label: 'addon.mod_forum.discussionlistsortbyrepliesdesc',
|
||||
value: AddonModForumProvider.SORTORDER_REPLIES_DESC,
|
||||
value: AddonModForumSortorder.REPLIES_DESC,
|
||||
},
|
||||
{
|
||||
label: 'addon.mod_forum.discussionlistsortbyrepliesasc',
|
||||
value: AddonModForumProvider.SORTORDER_REPLIES_ASC,
|
||||
value: AddonModForumSortorder.REPLIES_ASC,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -727,7 +720,7 @@ export class AddonModForumProvider {
|
|||
|
||||
if (this.isDiscussionListSortingAvailable()) {
|
||||
const preferenceValue = await CoreUtils.ignoreErrors(
|
||||
CoreUser.getUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER),
|
||||
CoreUser.getUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER),
|
||||
);
|
||||
|
||||
sortOrderValue = preferenceValue ? parseInt(preferenceValue, 10) : null;
|
||||
|
@ -750,7 +743,7 @@ export class AddonModForumProvider {
|
|||
forumId: number,
|
||||
options: AddonModForumGetDiscussionsOptions = {},
|
||||
): Promise<{ discussions: AddonModForumDiscussion[]; canLoadMore: boolean }> {
|
||||
options.sortOrder = options.sortOrder || AddonModForumProvider.SORTORDER_LASTPOST_DESC;
|
||||
options.sortOrder = options.sortOrder || AddonModForumSortorder.LASTPOST_DESC;
|
||||
options.page = options.page || 0;
|
||||
|
||||
const site = await CoreSites.getSite(options.siteId);
|
||||
|
@ -758,7 +751,7 @@ export class AddonModForumProvider {
|
|||
const params: AddonModForumGetForumDiscussionsPaginatedWSParams | AddonModForumGetForumDiscussionsWSParams = {
|
||||
forumid: forumId,
|
||||
page: options.page,
|
||||
perpage: AddonModForumProvider.DISCUSSIONS_PER_PAGE,
|
||||
perpage: ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE,
|
||||
};
|
||||
|
||||
if (site.wsAvailable('mod_forum_get_forum_discussions')) {
|
||||
|
@ -767,7 +760,7 @@ export class AddonModForumProvider {
|
|||
(params as AddonModForumGetForumDiscussionsWSParams).sortorder = options.sortOrder;
|
||||
(params as AddonModForumGetForumDiscussionsWSParams).groupid = options.groupId;
|
||||
} else {
|
||||
if (options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC) {
|
||||
if (options.sortOrder !== AddonModForumSortorder.LASTPOST_DESC) {
|
||||
throw new Error('Sorting not supported with the old WS method.');
|
||||
}
|
||||
|
||||
|
@ -777,7 +770,7 @@ export class AddonModForumProvider {
|
|||
|
||||
const preSets = {
|
||||
cacheKey: this.getDiscussionsListCacheKey(forumId, options.sortOrder),
|
||||
component: AddonModForumProvider.COMPONENT,
|
||||
component: ADDON_MOD_FORUM_COMPONENT,
|
||||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
|
@ -795,7 +788,7 @@ export class AddonModForumProvider {
|
|||
if (
|
||||
CoreNetwork.isOnline() ||
|
||||
method !== 'mod_forum_get_forum_discussions' ||
|
||||
options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC
|
||||
options.sortOrder !== AddonModForumSortorder.LASTPOST_DESC
|
||||
) {
|
||||
throw error;
|
||||
}
|
||||
|
@ -803,7 +796,7 @@ export class AddonModForumProvider {
|
|||
const params: AddonModForumGetForumDiscussionsPaginatedWSParams = {
|
||||
forumid: forumId,
|
||||
page: options.page,
|
||||
perpage: AddonModForumProvider.DISCUSSIONS_PER_PAGE,
|
||||
perpage: ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE,
|
||||
sortby: 'timemodified',
|
||||
sortdirection: 'DESC',
|
||||
};
|
||||
|
@ -824,7 +817,7 @@ export class AddonModForumProvider {
|
|||
|
||||
return {
|
||||
discussions: response.discussions,
|
||||
canLoadMore: response.discussions.length >= AddonModForumProvider.DISCUSSIONS_PER_PAGE,
|
||||
canLoadMore: response.discussions.length >= ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -930,7 +923,7 @@ export class AddonModForumProvider {
|
|||
});
|
||||
|
||||
if (this.isDiscussionListSortingAvailable()) {
|
||||
promises.push(CoreUser.invalidateUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER));
|
||||
promises.push(CoreUser.invalidateUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER));
|
||||
}
|
||||
|
||||
return CoreUtils.allPromises(promises);
|
||||
|
@ -1008,7 +1001,7 @@ export class AddonModForumProvider {
|
|||
return CoreCourseLogHelper.log(
|
||||
'mod_forum_view_forum',
|
||||
params,
|
||||
AddonModForumProvider.COMPONENT,
|
||||
ADDON_MOD_FORUM_COMPONENT,
|
||||
id,
|
||||
siteId,
|
||||
);
|
||||
|
@ -1030,7 +1023,7 @@ export class AddonModForumProvider {
|
|||
return CoreCourseLogHelper.log(
|
||||
'mod_forum_view_forum_discussion',
|
||||
params,
|
||||
AddonModForumProvider.COMPONENT,
|
||||
ADDON_MOD_FORUM_COMPONENT,
|
||||
forumId,
|
||||
siteId,
|
||||
);
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModForumModuleHandlerService } from './module';
|
||||
import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to treat links to forum review.
|
||||
|
@ -66,7 +66,7 @@ export class AddonModForumDiscussionLinkHandlerService extends CoreContentLinksH
|
|||
}
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/${discussionId}`,
|
||||
`${ADDON_MOD_FORUM_PAGE_NAME}/discussion/${discussionId}`,
|
||||
{ siteId, params: pageParams },
|
||||
);
|
||||
},
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable, Type } from '@angular/core';
|
||||
import { AddonModForum, AddonModForumProvider, AddonModForumTracking } from '../forum';
|
||||
import { AddonModForum, AddonModForumTracking } from '../forum';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
|
@ -23,6 +23,7 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
|
|||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { ADDON_MOD_FORUM_MARK_READ_EVENT, ADDON_MOD_FORUM_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to support forum modules.
|
||||
|
@ -30,11 +31,9 @@ import { CoreUser } from '@features/user/services/user';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'mod_forum';
|
||||
|
||||
name = 'AddonModForum';
|
||||
modName = 'forum';
|
||||
protected pageName = AddonModForumModuleHandlerService.PAGE_NAME;
|
||||
protected pageName = ADDON_MOD_FORUM_PAGE_NAME;
|
||||
|
||||
supportedFeatures = {
|
||||
[CoreConstants.FEATURE_GROUPS]: true,
|
||||
|
@ -88,7 +87,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp
|
|||
}
|
||||
|
||||
const event = CoreEvents.on(
|
||||
AddonModForumProvider.MARK_READ_EVENT,
|
||||
ADDON_MOD_FORUM_MARK_READ_EVENT,
|
||||
eventData => {
|
||||
if (eventData.courseId !== courseId || eventData.moduleId !== module.id) {
|
||||
return;
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModForumModuleHandlerService } from './module';
|
||||
import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Content links handler for forum new discussion.
|
||||
|
@ -54,7 +54,7 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler
|
|||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${AddonModForumModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/new/0`,
|
||||
`${ADDON_MOD_FORUM_PAGE_NAME}/${module.course}/${module.id}/new/0`,
|
||||
{ siteId, params: { forumId: module.instance } },
|
||||
);
|
||||
} finally {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
|
||||
import { AddonModForum, AddonModForumData, AddonModForumPost, AddonModForumProvider } from '../forum';
|
||||
import { AddonModForum, AddonModForumData, AddonModForumPost } from '../forum';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
|
@ -25,6 +25,7 @@ import { CoreUtils } from '@services/utils/utils';
|
|||
import { AddonModForumSync, AddonModForumSyncResult } from '../forum-sync';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreCourses } from '@features/courses/services/courses';
|
||||
import { ADDON_MOD_FORUM_COMPONENT } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to prefetch forums.
|
||||
|
@ -34,7 +35,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
|
|||
|
||||
name = 'AddonModForum';
|
||||
modName = 'forum';
|
||||
component = AddonModForumProvider.COMPONENT;
|
||||
component = ADDON_MOD_FORUM_COMPONENT;
|
||||
updatesNames = /^configuration$|^.*files$|^discussions$/;
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,8 +23,8 @@ import { CoreUrlUtils } from '@services/utils/url';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
import { AddonModForumModuleHandlerService } from './module';
|
||||
import { isSafeNumber } from '@/core/utils/types';
|
||||
import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler for forum push notifications clicks.
|
||||
|
@ -80,7 +80,7 @@ export class AddonModForumPushClickHandlerService implements CorePushNotificatio
|
|||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/${discussionId}`,
|
||||
`${ADDON_MOD_FORUM_PAGE_NAME}/discussion/${discussionId}`,
|
||||
{ siteId: notification.site, params: pageParams },
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue