@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
19 lines • 767 B
JavaScript
export var getUserName = function (user, priority) {
var _a;
if (priority === void 0) { priority = 'username'; }
if (priority === 'username' && user.username)
return user.username;
if (priority === 'name' && user.name)
return user.name;
// Fallback to the other field if priority is not available
if (user.username)
return user.username;
if (user.name)
return user.name;
// Generate a fallback value based on user ID
if (user.id)
return "user-" + ((_a = user === null || user === void 0 ? void 0 : user.id) === null || _a === void 0 ? void 0 : _a.split("-")[0].split("").reverse().join(""));
// Final fallback
return "Invalid User Details";
};
//# sourceMappingURL=getUserName.js.map