2017-06-30 04:22:09 +08:00
|
|
|
import Captions from '/imports/api/2.0/captions';
|
2016-07-23 08:12:31 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-04-06 19:46:15 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2016-07-23 08:12:31 +08:00
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
const getCCData = () => {
|
2016-07-23 08:12:31 +08:00
|
|
|
const meetingID = Auth.meetingID;
|
2016-08-10 06:35:16 +08:00
|
|
|
|
2017-04-06 19:46:15 +08:00
|
|
|
const ccSettings = Settings.cc;
|
2016-12-23 16:26:22 +08:00
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
const CCEnabled = ccSettings.enabled;
|
2016-08-10 06:35:16 +08:00
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
// associative array that keeps locales with arrays of string objects related to those locales
|
|
|
|
const captions = [];
|
2016-07-23 08:12:31 +08:00
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
// list of unique locales in the Captions Collection
|
2017-02-22 04:29:36 +08:00
|
|
|
if (CCEnabled) {
|
2017-06-03 03:25:02 +08:00
|
|
|
const locales = _.uniq(Captions.find({}, {
|
2016-12-23 16:26:22 +08:00
|
|
|
sort: { locale: 1 },
|
|
|
|
fields: { locale: true },
|
2017-06-03 03:25:02 +08:00
|
|
|
}).fetch().map(obj => obj.locale), true);
|
2016-12-23 16:26:22 +08:00
|
|
|
|
2016-12-24 02:49:17 +08:00
|
|
|
locales.forEach((locale) => {
|
2017-06-03 03:25:02 +08:00
|
|
|
const captionObjects = Captions.find({
|
2016-12-23 16:26:22 +08:00
|
|
|
meetingId: meetingID,
|
2017-06-03 03:25:02 +08:00
|
|
|
locale,
|
2016-12-23 16:26:22 +08:00
|
|
|
}, {
|
|
|
|
sort: {
|
|
|
|
locale: 1,
|
|
|
|
'captionHistory.index': 1,
|
|
|
|
},
|
|
|
|
}).fetch();
|
|
|
|
|
|
|
|
let current = captionObjects[0];
|
|
|
|
captions[current.locale] = {
|
|
|
|
ownerId: current.captionHistory.ownerId ? current.captionHistory.ownerId : null,
|
|
|
|
captions: [],
|
|
|
|
};
|
|
|
|
while (current != null) {
|
|
|
|
captions[current.locale].captions.push({
|
|
|
|
captions: current.captionHistory.captions,
|
|
|
|
index: current.captionHistory.index,
|
|
|
|
});
|
|
|
|
current = captionObjects[current.captionHistory.next];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-07-23 08:12:31 +08:00
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
// fetching settings for the captions
|
|
|
|
const selectedLocale = ccSettings.locale;
|
|
|
|
const ccFontFamily = ccSettings.fontFamily ? ccSettings.fontFamily : 'Arial';
|
|
|
|
const ccFontSize = ccSettings.fontSize ? ccSettings.fontSize : 18;
|
|
|
|
const ccBackgroundColor = ccSettings.backgroundColor ? ccSettings.backgroundColor : '#f3f6f9';
|
|
|
|
const ccFontColor = ccSettings.fontColor ? ccSettings.fontColor : '#000000';
|
2016-07-23 08:12:31 +08:00
|
|
|
return {
|
2016-12-23 16:26:22 +08:00
|
|
|
locale: selectedLocale,
|
|
|
|
fontFamily: ccFontFamily,
|
|
|
|
fontSize: ccFontSize,
|
|
|
|
fontColor: ccFontColor,
|
|
|
|
backgroundColor: ccBackgroundColor,
|
2017-06-03 03:25:02 +08:00
|
|
|
captions,
|
2016-07-23 08:12:31 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
getCCData,
|
|
|
|
};
|