|
12 | 12 | .factory('Location', [function () { |
13 | 13 | var _location = location; |
14 | 14 | return { |
15 | | - go: function (path) { |
| 15 | + go: function (path, pushToHistory = true) { |
16 | 16 | _location.href = path; |
17 | 17 | let label = path.includes('thread') ? 'thread' : path.includes('members') ? 'members' : 'report'; |
18 | | - buildfire.history.push(label, {}); |
| 18 | + if (pushToHistory) { |
| 19 | + buildfire.history.push(label, {}); |
| 20 | + } |
19 | 21 | }, |
20 | 22 | goToHome: function () { |
21 | 23 | _location.href = _location.href.substr(0, _location.href.indexOf('#')); |
|
134 | 136 | console.error('Error decoding deepLinkData:', error); |
135 | 137 | return null; |
136 | 138 | } |
| 139 | + }, |
| 140 | + evaluateExpression(expression) { |
| 141 | + return new Promise((resolve, reject) => { |
| 142 | + buildfire.dynamic.expressions.evaluate({expression}, (err, result) => { |
| 143 | + if (err) return reject(err); |
| 144 | + resolve(result.evaluatedExpression); |
| 145 | + }); |
| 146 | + }) |
| 147 | + }, |
| 148 | + setExpression(expression) { |
| 149 | + buildfire.dynamic.expressions.getContext = (options, callback) => { |
| 150 | + const context = { |
| 151 | + plugin: expression |
| 152 | + } |
| 153 | + callback(null, context) |
| 154 | + } |
137 | 155 | } |
138 | | - |
139 | 156 | } |
140 | 157 | }]) |
141 | 158 | .factory("SubscribedUsersData", function () { |
|
706 | 723 | } |
707 | 724 | } |
708 | 725 | }]) |
709 | | - .factory('SocialItems', ['Util', '$rootScope', function (Util, $rootScope) { |
| 726 | + .factory('SocialItems', ['Util', '$rootScope', '$timeout', function (Util, $rootScope, $timeout) { |
710 | 727 | var _this; |
711 | 728 | var SocialItems = function () { |
712 | 729 | _this = this; |
|
836 | 853 | if (error) return console.log(error); |
837 | 854 |
|
838 | 855 | if (data && data.result.length) { |
839 | | - const result = data.result.filter(item => !_this.items.find(_item => _item.id === item.id)); |
| 856 | + const result = data.result.filter(newItem => !_this.items.some(existItem => existItem.id === newItem.id)); |
840 | 857 | const newItems = result.map(item => { |
841 | | - _this.setupImageList(item.data); |
842 | 858 | return {...item.data, id: item.id}; |
843 | 859 | }); |
844 | 860 | _this.items = _this.items.concat(newItems); |
|
869 | 885 | }); |
870 | 886 | } |
871 | 887 |
|
| 888 | + SocialItems.prototype.getPostById = function (id, callback) { |
| 889 | + buildfire.publicData.getById(id, "posts", callback); |
| 890 | + } |
| 891 | + |
872 | 892 | function getSort() { |
873 | 893 | if (_this.indexingUpdateDone) |
874 | 894 | return { |
|
920 | 940 | return filter; |
921 | 941 | } |
922 | 942 |
|
923 | | - SocialItems.prototype.setupImageList = function(post) { |
924 | | - post.imageListId = "imageList_" + post.id; |
925 | | - if (post.imageUrl) { |
926 | | - setTimeout(function () { |
927 | | - let imageList = document.getElementById(post.imageListId); |
| 943 | + SocialItems.prototype.setupImageList = function(listId, item) { |
| 944 | + if (item.imageUrl) { |
| 945 | + $timeout(() => { |
| 946 | + let imageList = document.getElementById(listId); |
928 | 947 | if (!imageList) return; |
929 | | - if (Array.isArray(post.imageUrl)) { |
930 | | - imageList.images = post.imageUrl; |
| 948 | + if (Array.isArray(item.imageUrl)) { |
| 949 | + imageList.images = item.imageUrl; |
931 | 950 | } else { |
932 | | - imageList.images = [post.imageUrl]; |
| 951 | + imageList.images = [item.imageUrl]; |
933 | 952 | } |
934 | 953 | imageList.addEventListener('imageSelected', (e) => { |
935 | 954 | let selectedImage = e.detail.filter(image => image.selected); |
|
939 | 958 | images: selectedImage |
940 | 959 | }); |
941 | 960 | }); |
942 | | - }, 0); |
| 961 | + }); |
943 | 962 | } |
944 | 963 | }; |
945 | 964 |
|
946 | 965 | function startBackgroundService() { |
947 | 966 | if (!_this.newPostTimerChecker) { |
948 | 967 | _this.newPostTimerChecker = setInterval(function () { |
| 968 | + if (_this.items.length > _this.pageSize) { |
| 969 | + return clearInterval(_this.newPostTimerChecker); |
| 970 | + } |
949 | 971 | let searchOptions = { |
950 | 972 | filter: getFilter(), |
951 | 973 | sort: { |
|
963 | 985 | if (results.totalRecord > _this.pageSize) { |
964 | 986 | _this.showMorePosts = true; |
965 | 987 | } else _this.showMorePosts = false; |
966 | | - |
| 988 | + |
967 | 989 | if (data && data.length) { |
968 | 990 | let items = data.map(item => { |
969 | 991 | const existItem = _this.items.find(_item => _item.id === item.id) || {}; |
970 | | - _this.setupImageList(item.data); |
971 | 992 | return {...existItem, ...item.data, id: item.id}; |
972 | 993 | }); |
973 | 994 |
|
|
1015 | 1036 | delete stringsCopy[defaultKey].labels; |
1016 | 1037 | }); |
1017 | 1038 | let strings = {} |
1018 | | - strings = Object.assign({}, stringsCopy.mainWall, stringsCopy.sideThread, stringsCopy.members, stringsCopy.input, stringsCopy.modal); |
| 1039 | + for (let key in stringsConfig) { |
| 1040 | + strings = Object.assign(strings, stringsCopy[key]); |
| 1041 | + } |
1019 | 1042 | Object.keys(strings).forEach(e => { |
1020 | 1043 | strings[e].value ? _this.languages[e] = strings[e].value : _this.languages[e] = strings[e].defaultValue; |
1021 | 1044 | }); |
1022 | 1045 | } else { |
1023 | 1046 | let strings = {}; |
1024 | | - if (response.data && response.data.mainWall && response.data.sideThread && response.data.members && response.data.input && response.data.modal) |
| 1047 | + if (response.data && response.data.mainWall && response.data.sideThread && response.data.members && response.data.input && response.data.modal) { |
1025 | 1048 | strings = Object.assign({}, response.data.mainWall, response.data.sideThread, response.data.members, response.data.input, response.data.modal); |
1026 | | - else |
1027 | | - strings = Object.assign({}, stringsConfig.mainWall.labels, stringsConfig.sideThread.labels, stringsConfig.members.labels, stringsConfig.input.labels, stringsConfig.modal.labels); |
| 1049 | + |
| 1050 | + const newProperties = ['pushNotifications']; |
| 1051 | + newProperties.forEach((key) => { |
| 1052 | + if (response.data[key]) { |
| 1053 | + strings = Object.assign(strings, response.data[key]); |
| 1054 | + } else { |
| 1055 | + strings = Object.assign(strings, stringsConfig[key].labels); |
| 1056 | + } |
| 1057 | + }); |
| 1058 | + } else { |
| 1059 | + for (let key in stringsConfig) { |
| 1060 | + strings = Object.assign(strings, stringsCopy[key].labels); |
| 1061 | + } |
| 1062 | + } |
1028 | 1063 | Object.keys(strings).forEach(e => { |
1029 | 1064 | if (e == "specificChat" && strings[e].value == "") |
1030 | 1065 | _this.languages[e] = strings[e].value |
|
0 commit comments