2021-09-13 20:41:05 +00:00
|
|
|
import { coerce, gt, gte, lt, lte } from 'semver';
|
2021-03-18 13:33:35 +00:00
|
|
|
|
2019-12-18 21:13:11 +00:00
|
|
|
export const formatAttachmentUrl = (attachmentUrl, userId, token, server) => {
|
|
|
|
if (attachmentUrl.startsWith('http')) {
|
|
|
|
if (attachmentUrl.includes('rc_token')) {
|
|
|
|
return encodeURI(attachmentUrl);
|
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
return encodeURI(`${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
|
2019-12-18 21:13:11 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
return encodeURI(`${server}${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
|
2019-12-18 21:13:11 +00:00
|
|
|
};
|
2021-03-18 13:33:35 +00:00
|
|
|
|
|
|
|
export const methods = {
|
|
|
|
lowerThan: lt,
|
|
|
|
lowerThanOrEqualTo: lte,
|
|
|
|
greaterThan: gt,
|
|
|
|
greaterThanOrEqualTo: gte
|
|
|
|
};
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
export const compareServerVersion = (currentServerVersion, versionToCompare, func) =>
|
|
|
|
currentServerVersion && func(coerce(currentServerVersion), versionToCompare);
|
2021-05-26 17:24:54 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
export const generateLoadMoreId = id => `load-more-${id}`;
|