frc-ui
Version:
React Web UI
207 lines (190 loc) • 6.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _interfaces = require("../interfaces");
var _common = require("../common");
var _urls = require("./urls");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var _default = function _default(prefix) {
return [{
key: 'chat',
initialState: {
channel: 'credBChat',
isOpen: false,
showSetting: false,
isAnonymous: (0, _common.getLocalStorageItem)(_interfaces.LocalStorageKey.isAnonymous, 'false') === 'true',
fontSize: (0, _common.getLocalStorageItem)(_interfaces.LocalStorageKey.danmakuFontSize, 12) || 12,
colorIndex: '#FFFFFF',
history: false,
emo: undefined,
selectMessageId: null
},
loading: function loading(state, action) {
return Object.assign({}, state, Object.assign({}, action.payload));
}
}, {
key: 'chatMessage.clientCount',
method: 'get',
url: function url(code) {
return "".concat(prefix).concat(_urls.chat, "clients/count?chatRoomCode=").concat(code);
}
}, {
key: 'chatMessage.history',
initialState: {
pageInfo: {
startIndex: 0,
totalSize: 0,
endIndex: 0
},
result: [],
enableLoad: true
},
method: 'post',
url: function url() {
return "".concat(prefix).concat(_urls.chat, "chat/messages/query");
},
loading: function loading(state) {
var h = Object.assign({}, state.history);
h.pageInfo = {
startIndex: 0,
totalSize: 0,
endIndex: 0
};
h.result = [];
h.loading = true;
h.success = false;
h.enableLoad = true;
return h;
},
success: function success(state, action) {
var h = Object.assign({}, state.history);
var _action$result = action.result,
pageInfo = _action$result.pageInfo,
result = _action$result.result;
h.pageInfo = Object.assign(Object.assign({}, h.pageInfo), pageInfo);
h.result = [].concat(_toConsumableArray(result || []), _toConsumableArray(h.result || []));
h.result.sort(function (a, b) {
return a.time - b.time;
});
h.loading = false;
h.success = true;
h.enableLoad = (result || []).length >= action.payload.pageSize;
h.status = action.status;
return h;
}
}, {
key: 'chatMessage.histories',
initialState: {
pageInfo: {
startIndex: 0,
totalSize: 0,
endIndex: 0
},
result: [],
enableLoad: true
},
method: 'post',
url: function url() {
return "".concat(prefix).concat(_urls.chat, "chat/messages/query");
},
loading: function loading(state, action) {
var h = Object.assign({}, state.histories);
if (action.payload.startIndex === 0) {
h.pageInfo = {
startIndex: 0,
totalSize: 0,
endIndex: 0
};
h.result = [];
}
h.loading = true;
h.success = false;
h.enableLoad = true;
return h;
},
success: function success(state, action) {
var h = Object.assign({}, state.histories);
var _ref = action.result || {},
pageInfo = _ref.pageInfo,
result = _ref.result;
if (action.payload === 'clear') {
h.pageInfo = {
startIndex: 0,
totalSize: 0,
endIndex: 0
};
h.result = [];
h.enableLoad = true;
} else {
h.pageInfo = Object.assign(Object.assign({}, h.pageInfo), pageInfo);
h.result = [].concat(_toConsumableArray(result || []), _toConsumableArray(h.result || []));
h.result.sort(function (a, b) {
return a.time - b.time;
});
h.enableLoad = (result || []).length >= action.payload.pageSize;
}
h.loading = false;
h.success = true;
return h;
}
}, {
key: 'chatMessage.anonymousName',
method: 'get',
url: function url(code) {
return "".concat(prefix).concat(_urls.chat, "anonnames/anonname?chatRoomCode=").concat(code);
}
}, {
key: 'chatGag.gag',
method: 'post',
url: function url(_ref2) {
var userId = _ref2.userId,
chatRoomCode = _ref2.chatRoomCode;
return "".concat(prefix).concat(_urls.chatGag, "gaguser?userId=").concat(userId, "&chatRoomCode=").concat(chatRoomCode);
}
}, {
key: 'chatGag.isGag',
method: 'get',
url: function url(_ref3) {
var userId = _ref3.userId,
chatRoomCode = _ref3.chatRoomCode;
return "".concat(prefix).concat(_urls.chatGag, "isag?userId=").concat(userId, "&chatRoomCode=").concat(chatRoomCode);
}
}, {
key: 'chatGag.ungag',
method: 'delete',
url: function url(_ref4) {
var userId = _ref4.userId,
chatRoomCode = _ref4.chatRoomCode;
return "".concat(prefix).concat(_urls.chatGag, "gaguser?userId=").concat(userId, "&chatRoomCode=").concat(chatRoomCode);
}
}, {
key: 'chatPermission',
method: 'get',
url: function url(code) {
return "".concat(prefix).concat(_urls.chat, "chatrooms/users/user/permissions?chatRoomCode=").concat(code);
}
}, {
key: 'chatTrend.type',
method: 'get',
url: function url() {
return "".concat(prefix).concat(_urls.tender, "market/trend/vote");
}
}, {
key: 'chatTrend.change',
method: 'put',
url: function url(trendType) {
return "".concat(prefix).concat(_urls.tender, "market/trend/vote?trend=").concat(trendType);
},
body: function body() {
return null;
}
}];
};
exports["default"] = _default;