Mention users in comments (#429)

Mention users in comments (#429)
This commit is contained in:
MrPercheul
2022-06-01 13:23:21 +02:00
committed by GitHub
parent cbc9633fe2
commit f6a78dd0b4
17 changed files with 194 additions and 24 deletions

View File

@@ -51,6 +51,7 @@ class MediaPageStore extends EventEmitter {
this.pagePlaylistId = null;
this.pagePlaylistData = null;
this.userList = null;
MediaPageStoreData[
Object.defineProperty(this, 'id', { value: 'MediaPageStoreData_' + Object.keys(MediaPageStoreData).length }).id
@@ -158,6 +159,12 @@ class MediaPageStore extends EventEmitter {
getRequest(this.commentsAPIUrl, !1, this.commentsResponse);
}
loadUsers() {
this.usersAPIUrl = this.mediacms_config.api.users;
this.usersResponse = this.usersResponse.bind(this);
getRequest(this.usersAPIUrl, !1, this.usersResponse);
}
loadPlaylists() {
if (!this.mediacms_config.member.can.saveMedia) {
return;
@@ -187,6 +194,7 @@ class MediaPageStore extends EventEmitter {
}
this.loadPlaylists();
this.loadUsers();
if (this.mediacms_config.member.can.readComment) {
this.loadComments();
@@ -215,6 +223,13 @@ class MediaPageStore extends EventEmitter {
}
}
usersResponse(response) {
if (response && response.data) {
MediaPageStoreData.userList = response.data.count ? response.data.results : [];
this.emit('users_load');
}
}
playlistsResponse(response) {
if (response && response.data) {
let tmp_playlists = response.data.count ? response.data.results : [];
@@ -403,6 +418,9 @@ class MediaPageStore extends EventEmitter {
i,
r = null;
switch (type) {
case 'users':
r = MediaPageStoreData.userList || [];
break;
case 'playlists':
r = MediaPageStoreData[this.id].playlists || [];
break;