"eslint": "^7.20.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^5.1.0",
- "lemmy-js-client": "0.10.0-rc.1",
+ "lemmy-js-client": "0.10.0-rc.5",
"lint-staged": "^10.5.4",
"mini-css-extract-plugin": "^1.3.8",
"node-fetch": "^2.6.1",
? req.headers["accept-language"].split(",")[0]
: "en";
let lang = site.my_user
- ? site.my_user.lang == "browser"
+ ? site.my_user.local_user.lang == "browser"
? acceptLang
: "en"
: acceptLang;
} from "../utils";
import autosize from "autosize";
import { SiteForm } from "./site-form";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { HtmlTags } from "./html-tags";
import { Spinner } from "./icon";
import { i18n } from "../i18next";
<ul class="list-unstyled">
{this.state.siteRes.admins.map(admin => (
<li class="list-inline-item">
- <UserListing user={admin.user} />
+ <PersonListing person={admin.person} />
</li>
))}
</ul>
<ul class="list-unstyled">
{this.state.siteRes.banned.map(banned => (
<li class="list-inline-item">
- <UserListing user={banned.user} />
+ <PersonListing person={banned.person} />
</li>
))}
</ul>
<>
<Provider i18next={i18n}>
<div>
- <Theme user={siteRes.my_user} />
+ <Theme localUserView={siteRes.my_user} />
{siteRes &&
siteRes.site_view &&
this.props.siteRes.site_view.site.icon && (
render() {
return (
<div class="mb-3">
- {UserService.Instance.user ? (
+ {UserService.Instance.localUserView ? (
<MarkdownTextArea
initialContent={
this.props.edit
let op = wsUserOp(msg);
// Only do the showing and hiding if logged in
- if (UserService.Instance.user) {
+ if (UserService.Instance.localUserView) {
if (
op == UserOperation.CreateComment ||
op == UserOperation.EditComment
DeleteComment,
RemoveComment,
MarkCommentAsRead,
- MarkUserMentionAsRead,
+ MarkPersonMentionAsRead,
SaveComment,
BanFromCommunity,
- BanUser,
+ BanPerson,
CommunityModeratorView,
- UserViewSafe,
+ PersonViewSafe,
AddModToCommunity,
AddAdmin,
TransferCommunity,
TransferSite,
CommentView,
- UserMentionView,
+ PersonMentionView,
} from "lemmy-js-client";
import { CommentNode as CommentNodeI, BanType } from "../interfaces";
import { WebSocketService, UserService } from "../services";
import { MomentTime } from "./moment-time";
import { CommentForm } from "./comment-form";
import { CommentNodes } from "./comment-nodes";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { CommunityLink } from "./community-link";
import { Icon, Spinner } from "./icon";
import { i18n } from "../i18next";
markable?: boolean;
showContext?: boolean;
moderators: CommunityModeratorView[];
- admins: UserViewSafe[];
+ admins: PersonViewSafe[];
// TODO is this necessary, can't I get it from the node itself?
postCreatorId?: number;
showCommunity?: boolean;
>
<div class="d-flex flex-wrap align-items-center text-muted small">
<span class="mr-2">
- <UserListing user={cv.creator} />
+ <PersonListing person={cv.creator} />
</span>
{this.isMod && (
)}
</button>
)}
- {UserService.Instance.user && !this.props.viewOnly && (
+ {UserService.Instance.localUserView && !this.props.viewOnly && (
<>
<button
className={`btn btn-link btn-animate ${
get commentOrMentionRead() {
let cv = this.props.node.comment_view;
- return this.isUserMentionType(cv) ? cv.user_mention.read : cv.comment.read;
+ return this.isPersonMentionType(cv)
+ ? cv.person_mention.read
+ : cv.comment.read;
}
get linkBtn() {
get myComment(): boolean {
return (
- UserService.Instance.user &&
- this.props.node.comment_view.creator.id == UserService.Instance.user.id
+ this.props.node.comment_view.creator.id ==
+ UserService.Instance.localUserView?.person.id
);
}
return (
this.props.admins &&
isMod(
- this.props.admins.map(a => a.user.id),
+ this.props.admins.map(a => a.person.id),
this.props.node.comment_view.creator.id
)
);
get canMod(): boolean {
if (this.props.admins && this.props.moderators) {
let adminsThenMods = this.props.admins
- .map(a => a.user.id)
+ .map(a => a.person.id)
.concat(this.props.moderators.map(m => m.moderator.id));
return canMod(
- UserService.Instance.user,
+ UserService.Instance.localUserView,
adminsThenMods,
this.props.node.comment_view.creator.id
);
return (
this.props.admins &&
canMod(
- UserService.Instance.user,
- this.props.admins.map(a => a.user.id),
+ UserService.Instance.localUserView,
+ this.props.admins.map(a => a.person.id),
this.props.node.comment_view.creator.id
)
);
get amCommunityCreator(): boolean {
return (
this.props.moderators &&
- UserService.Instance.user &&
- this.props.node.comment_view.creator.id != UserService.Instance.user.id &&
- UserService.Instance.user.id == this.props.moderators[0].moderator.id
+ UserService.Instance.localUserView &&
+ this.props.node.comment_view.creator.id !=
+ UserService.Instance.localUserView.person.id &&
+ UserService.Instance.localUserView.person.id ==
+ this.props.moderators[0].moderator.id
);
}
get amSiteCreator(): boolean {
return (
this.props.admins &&
- UserService.Instance.user &&
- this.props.node.comment_view.creator.id != UserService.Instance.user.id &&
- UserService.Instance.user.id == this.props.admins[0].user.id
+ UserService.Instance.localUserView &&
+ this.props.node.comment_view.creator.id !=
+ UserService.Instance.localUserView.person.id &&
+ UserService.Instance.localUserView.person.id ==
+ this.props.admins[0].person.id
);
}
i.setState(i.state);
}
- isUserMentionType(
- item: CommentView | UserMentionView
- ): item is UserMentionView {
- return (item as UserMentionView).user_mention?.id !== undefined;
+ isPersonMentionType(
+ item: CommentView | PersonMentionView
+ ): item is PersonMentionView {
+ return (item as PersonMentionView).person_mention?.id !== undefined;
}
handleMarkRead(i: CommentNode) {
- if (i.isUserMentionType(i.props.node.comment_view)) {
- let form: MarkUserMentionAsRead = {
- user_mention_id: i.props.node.comment_view.user_mention.id,
- read: !i.props.node.comment_view.user_mention.read,
+ if (i.isPersonMentionType(i.props.node.comment_view)) {
+ let form: MarkPersonMentionAsRead = {
+ person_mention_id: i.props.node.comment_view.person_mention.id,
+ read: !i.props.node.comment_view.person_mention.read,
auth: authField(),
};
- WebSocketService.Instance.send(wsClient.markUserMentionAsRead(form));
+ WebSocketService.Instance.send(wsClient.markPersonMentionAsRead(form));
} else {
let form: MarkCommentAsRead = {
comment_id: i.props.node.comment_view.comment.id,
i.state.removeData = false;
}
let form: BanFromCommunity = {
- user_id: cv.creator.id,
+ person_id: cv.creator.id,
community_id: cv.community.id,
ban,
remove_data: i.state.removeData,
if (ban == false) {
i.state.removeData = false;
}
- let form: BanUser = {
- user_id: cv.creator.id,
+ let form: BanPerson = {
+ person_id: cv.creator.id,
ban,
remove_data: i.state.removeData,
reason: i.state.banReason,
expires: getUnixTime(i.state.banExpires),
auth: authField(),
};
- WebSocketService.Instance.send(wsClient.banUser(form));
+ WebSocketService.Instance.send(wsClient.banPerson(form));
}
i.state.showBanDialog = false;
handleAddModToCommunity(i: CommentNode) {
let cv = i.props.node.comment_view;
let form: AddModToCommunity = {
- user_id: cv.creator.id,
+ person_id: cv.creator.id,
community_id: cv.community.id,
added: !i.isMod,
auth: authField(),
handleAddAdmin(i: CommentNode) {
let form: AddAdmin = {
- user_id: i.props.node.comment_view.creator.id,
+ person_id: i.props.node.comment_view.creator.id,
added: !i.isAdmin,
auth: authField(),
};
let cv = i.props.node.comment_view;
let form: TransferCommunity = {
community_id: cv.community.id,
- user_id: cv.creator.id,
+ person_id: cv.creator.id,
auth: authField(),
};
WebSocketService.Instance.send(wsClient.transferCommunity(form));
handleTransferSite(i: CommentNode) {
let form: TransferSite = {
- user_id: i.props.node.comment_view.creator.id,
+ person_id: i.props.node.comment_view.creator.id,
auth: authField(),
};
WebSocketService.Instance.send(wsClient.transferSite(form));
import { Component } from "inferno";
import { CommentNode as CommentNodeI } from "../interfaces";
-import { CommunityModeratorView, UserViewSafe } from "lemmy-js-client";
+import { CommunityModeratorView, PersonViewSafe } from "lemmy-js-client";
import { CommentNode } from "./comment-node";
interface CommentNodesProps {
nodes: CommentNodeI[];
moderators?: CommunityModeratorView[];
- admins?: UserViewSafe[];
+ admins?: PersonViewSafe[];
postCreatorId?: number;
noBorder?: boolean;
noIndent?: boolean;
let sort: SortType = pathSplit[6]
? SortType[pathSplit[6]]
- : UserService.Instance.user
- ? Object.values(SortType)[UserService.Instance.user.default_sort_type]
+ : UserService.Instance.localUserView
+ ? Object.values(SortType)[
+ UserService.Instance.localUserView.local_user.default_sort_type
+ ]
: SortType.Active;
let page = pathSplit[8] ? Number(pathSplit[8]) : 1;
// TODO this might be incorrect
this.state.posts
- .filter(p => p.creator.id == data.user_view.user.id)
+ .filter(p => p.creator.id == data.person_view.person.id)
.forEach(p => (p.creator_banned_from_community = data.banned));
this.setState(this.state);
this.parseMessage = this.parseMessage.bind(this);
this.subscription = wsSubscribe(this.parseMessage);
- if (!UserService.Instance.user && isBrowser()) {
+ if (!UserService.Instance.localUserView && isBrowser()) {
toast(i18n.t("not_logged_in"), "danger");
this.context.router.history.push(`/login`);
}
this.handlePostCreate = this.handlePostCreate.bind(this);
this.state = this.emptyState;
- if (!UserService.Instance.user && isBrowser()) {
+ if (!UserService.Instance.localUserView && isBrowser()) {
toast(i18n.t("not_logged_in"), "danger");
this.context.router.history.push(`/login`);
}
import {
SiteView,
UserOperation,
- GetUserDetailsResponse,
- UserViewSafe,
+ GetPersonDetailsResponse,
+ PersonViewSafe,
SortType,
- GetUserDetails,
+ GetPersonDetails,
} from "lemmy-js-client";
import {
authField,
interface CreatePrivateMessageState {
site_view: SiteView;
- recipient: UserViewSafe;
+ recipient: PersonViewSafe;
recipient_id: number;
loading: boolean;
}
this.parseMessage = this.parseMessage.bind(this);
this.subscription = wsSubscribe(this.parseMessage);
- if (!UserService.Instance.user) {
+ if (!UserService.Instance.localUserView) {
toast(i18n.t("not_logged_in"), "danger");
this.context.router.history.push(`/login`);
}
this.state.recipient = this.isoData.routeData[0].user;
this.state.loading = false;
} else {
- this.fetchUserDetails();
+ this.fetchPersonDetails();
}
}
- fetchUserDetails() {
- let form: GetUserDetails = {
- user_id: this.state.recipient_id,
+ fetchPersonDetails() {
+ let form: GetPersonDetails = {
+ person_id: this.state.recipient_id,
sort: SortType.New,
saved_only: false,
auth: authField(false),
};
- WebSocketService.Instance.send(wsClient.getUserDetails(form));
+ WebSocketService.Instance.send(wsClient.getPersonDetails(form));
}
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
- let user_id = Number(req.path.split("/").pop());
- let form: GetUserDetails = {
- user_id,
+ let person_id = Number(req.path.split("/").pop());
+ let form: GetPersonDetails = {
+ person_id,
sort: SortType.New,
saved_only: false,
auth: req.auth,
};
- return [req.client.getUserDetails(form)];
+ return [req.client.getPersonDetails(form)];
}
get documentTitle(): string {
<h5>{i18n.t("create_private_message")}</h5>
<PrivateMessageForm
onCreate={this.handlePrivateMessageCreate}
- recipient={this.state.recipient.user}
+ recipient={this.state.recipient.person}
/>
</div>
</div>
this.state.loading = false;
this.setState(this.state);
return;
- } else if (op == UserOperation.GetUserDetails) {
- let data = wsJsonToRes<GetUserDetailsResponse>(msg).data;
- this.state.recipient = data.user_view;
+ } else if (op == UserOperation.GetPersonDetails) {
+ let data = wsJsonToRes<GetPersonDetailsResponse>(msg).data;
+ this.state.recipient = data.person_view;
this.state.loading = false;
this.setState(this.state);
}
accept="image/*,video/*"
name={this.id}
class="d-none"
- disabled={!UserService.Instance.user}
+ disabled={!UserService.Instance.localUserView}
onChange={linkEvent(this, this.handleImageUpload)}
/>
</form>
SortType,
GetReplies,
GetRepliesResponse,
- GetUserMentions,
- GetUserMentionsResponse,
- UserMentionResponse,
+ GetPersonMentions,
+ GetPersonMentionsResponse,
+ PersonMentionResponse,
CommentResponse,
PrivateMessageView,
GetPrivateMessages,
PrivateMessagesResponse,
PrivateMessageResponse,
SiteView,
- UserMentionView,
+ PersonMentionView,
} from "lemmy-js-client";
import { WebSocketService, UserService } from "../services";
import {
type ReplyType = {
id: number;
type_: ReplyEnum;
- view: CommentView | PrivateMessageView | UserMentionView;
+ view: CommentView | PrivateMessageView | PersonMentionView;
published: string;
};
unreadOrAll: UnreadOrAll;
messageType: MessageType;
replies: CommentView[];
- mentions: UserMentionView[];
+ mentions: PersonMentionView[];
messages: PrivateMessageView[];
combined: ReplyType[];
sort: SortType;
this.state = this.emptyState;
this.handleSortChange = this.handleSortChange.bind(this);
- if (!UserService.Instance.user && isBrowser()) {
+ if (!UserService.Instance.localUserView && isBrowser()) {
toast(i18n.t("not_logged_in"), "danger");
this.context.router.history.push(`/login`);
}
}
get documentTitle(): string {
- return `@${UserService.Instance.user.name} ${i18n.t("inbox")} - ${
- this.state.site_view.site.name
- }`;
+ return `@${UserService.Instance.localUserView.person.name} ${i18n.t(
+ "inbox"
+ )} - ${this.state.site_view.site.name}`;
}
render() {
};
}
- mentionToReplyType(r: UserMentionView): ReplyType {
+ mentionToReplyType(r: PersonMentionView): ReplyType {
return {
- id: r.user_mention.id,
+ id: r.person_mention.id,
type_: ReplyEnum.Mention,
view: r,
published: r.comment.published,
return (
<CommentNodes
key={i.id}
- nodes={[{ comment_view: i.view as UserMentionView }]}
+ nodes={[{ comment_view: i.view as PersonMentionView }]}
noIndent
markable
showCommunity
<div>
{this.state.mentions.map(umv => (
<CommentNodes
- key={umv.user_mention.id}
+ key={umv.person_mention.id}
nodes={[{ comment_view: umv }]}
noIndent
markable
};
promises.push(req.client.getReplies(repliesForm));
- let userMentionsForm: GetUserMentions = {
+ let personMentionsForm: GetPersonMentions = {
sort: SortType.New,
unread_only: true,
page: 1,
limit: fetchLimit,
auth: req.auth,
};
- promises.push(req.client.getUserMentions(userMentionsForm));
+ promises.push(req.client.getPersonMentions(personMentionsForm));
let privateMessagesForm: GetPrivateMessages = {
unread_only: true,
};
WebSocketService.Instance.send(wsClient.getReplies(repliesForm));
- let userMentionsForm: GetUserMentions = {
+ let personMentionsForm: GetPersonMentions = {
sort: this.state.sort,
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
page: this.state.page,
limit: fetchLimit,
auth: authField(),
};
- WebSocketService.Instance.send(wsClient.getUserMentions(userMentionsForm));
+ WebSocketService.Instance.send(
+ wsClient.getPersonMentions(personMentionsForm)
+ );
let privateMessagesForm: GetPrivateMessages = {
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
window.scrollTo(0, 0);
this.setState(this.state);
setupTippy();
- } else if (op == UserOperation.GetUserMentions) {
- let data = wsJsonToRes<GetUserMentionsResponse>(msg).data;
+ } else if (op == UserOperation.GetPersonMentions) {
+ let data = wsJsonToRes<GetPersonMentionsResponse>(msg).data;
this.state.mentions = data.mentions;
this.state.combined = this.buildCombined();
this.sendUnreadCount();
this.sendUnreadCount();
this.setState(this.state);
setupTippy();
- } else if (op == UserOperation.MarkUserMentionAsRead) {
- let data = wsJsonToRes<UserMentionResponse>(msg).data;
+ } else if (op == UserOperation.MarkPersonMentionAsRead) {
+ let data = wsJsonToRes<PersonMentionResponse>(msg).data;
// TODO this might not be correct, it might need to use the comment id
let found = this.state.mentions.find(
- c => c.user_mention.id == data.user_mention_view.user_mention.id
+ c => c.person_mention.id == data.person_mention_view.person_mention.id
);
if (found) {
let combinedView = this.state.combined.find(
- i => i.id == data.user_mention_view.user_mention.id
- ).view as UserMentionView;
+ i => i.id == data.person_mention_view.person_mention.id
+ ).view as PersonMentionView;
found.comment.content = combinedView.comment.content =
- data.user_mention_view.comment.content;
+ data.person_mention_view.comment.content;
found.comment.updated = combinedView.comment.updated =
- data.user_mention_view.comment.updated;
+ data.person_mention_view.comment.updated;
found.comment.removed = combinedView.comment.removed =
- data.user_mention_view.comment.removed;
+ data.person_mention_view.comment.removed;
found.comment.deleted = combinedView.comment.deleted =
- data.user_mention_view.comment.deleted;
+ data.person_mention_view.comment.deleted;
found.counts.upvotes = combinedView.counts.upvotes =
- data.user_mention_view.counts.upvotes;
+ data.person_mention_view.counts.upvotes;
found.counts.downvotes = combinedView.counts.downvotes =
- data.user_mention_view.counts.downvotes;
+ data.person_mention_view.counts.downvotes;
found.counts.score = combinedView.counts.score =
- data.user_mention_view.counts.score;
+ data.person_mention_view.counts.score;
// If youre in the unread view, just remove it from the list
if (
this.state.unreadOrAll == UnreadOrAll.Unread &&
- data.user_mention_view.user_mention.read
+ data.person_mention_view.person_mention.read
) {
this.state.mentions = this.state.mentions.filter(
- r => r.user_mention.id !== data.user_mention_view.user_mention.id
+ r =>
+ r.person_mention.id !== data.person_mention_view.person_mention.id
);
this.state.combined = this.state.combined.filter(
- r => r.id !== data.user_mention_view.user_mention.id
+ r => r.id !== data.person_mention_view.person_mention.id
);
} else {
// TODO test to make sure these mentions are getting marked as read
- found.user_mention.read = combinedView.user_mention.read =
- data.user_mention_view.user_mention.read;
+ found.person_mention.read = combinedView.person_mention.read =
+ data.person_mention_view.person_mention.read;
}
}
this.sendUnreadCount();
} else if (op == UserOperation.CreateComment) {
let data = wsJsonToRes<CommentResponse>(msg).data;
- if (data.recipient_ids.includes(UserService.Instance.user.id)) {
+ if (
+ data.recipient_ids.includes(
+ UserService.Instance.localUserView.local_user.id
+ )
+ ) {
this.state.replies.unshift(data.comment_view);
this.state.combined.unshift(this.replyToReplyType(data.comment_view));
this.setState(this.state);
- } else if (data.comment_view.creator.id == UserService.Instance.user.id) {
+ } else if (
+ data.comment_view.creator.id ==
+ UserService.Instance.localUserView.person.id
+ ) {
// TODO this seems wrong, you should be using form_id
toast(i18n.t("reply_sent"));
}
} else if (op == UserOperation.CreatePrivateMessage) {
let data = wsJsonToRes<PrivateMessageResponse>(msg).data;
if (
- data.private_message_view.recipient.id == UserService.Instance.user.id
+ data.private_message_view.recipient.id ==
+ UserService.Instance.localUserView.person.id
) {
this.state.messages.unshift(data.private_message_view);
this.state.combined.unshift(
unreadCount(): number {
return (
this.state.replies.filter(r => !r.comment.read).length +
- this.state.mentions.filter(r => !r.user_mention.read).length +
+ this.state.mentions.filter(r => !r.person_mention.read).length +
this.state.messages.filter(
r =>
- UserService.Instance.user &&
+ UserService.Instance.localUserView &&
!r.private_message.read &&
- // TODO also seems very strang and wrong
- r.creator.id !== UserService.Instance.user.id
+ // TODO also seems very strange and wrong
+ r.creator.id !== UserService.Instance.localUserView.person.id
).length
);
}
<label
className={`btn btn-outline-secondary
${this.state.type_ == ListingType.Subscribed && "active"}
- ${UserService.Instance.user == undefined ? "disabled" : "pointer"}
+ ${
+ UserService.Instance.localUserView == undefined
+ ? "disabled"
+ : "pointer"
+ }
`}
>
<input
value={ListingType.Subscribed}
checked={this.state.type_ == ListingType.Subscribed}
onChange={linkEvent(this, this.handleTypeChange)}
- disabled={UserService.Instance.user == undefined}
+ disabled={UserService.Instance.localUserView == undefined}
/>
{i18n.t("subscribed")}
</label>
GetCommentsResponse,
CommentResponse,
AddAdminResponse,
- BanUserResponse,
+ BanPersonResponse,
} from "lemmy-js-client";
import { DataType, InitialFetchRequest } from "../interfaces";
import { WebSocketService, UserService } from "../services";
import { ListingTypeSelect } from "./listing-type-select";
import { DataTypeSelect } from "./data-type-select";
import { SiteForm } from "./site-form";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { CommunityLink } from "./community-link";
import { BannerIconHeader } from "./banner-icon-header";
import { Icon, Spinner } from "./icon";
this.state.comments = this.isoData.routeData[0].comments;
}
this.state.trendingCommunities = this.isoData.routeData[1].communities;
- if (UserService.Instance.user) {
+ if (UserService.Instance.localUserView) {
this.state.subscribedCommunities = this.isoData.routeData[2].communities;
}
this.state.loading = false;
} else {
this.fetchTrendingCommunities();
this.fetchData();
- if (UserService.Instance.user) {
+ if (UserService.Instance.localUserView) {
WebSocketService.Instance.send(
wsClient.getFollowedCommunities({
auth: authField(),
// TODO figure out auth default_listingType, default_sort_type
let type_: ListingType = pathSplit[5]
? ListingType[pathSplit[5]]
- : UserService.Instance.user
+ : UserService.Instance.localUserView
? Object.values(ListingType)[
- UserService.Instance.user.default_listing_type
+ UserService.Instance.localUserView.local_user.default_listing_type
]
: ListingType.Local;
let sort: SortType = pathSplit[7]
? SortType[pathSplit[7]]
- : UserService.Instance.user
- ? Object.values(SortType)[UserService.Instance.user.default_sort_type]
+ : UserService.Instance.localUserView
+ ? Object.values(SortType)[
+ UserService.Instance.localUserView.local_user.default_sort_type
+ ]
: SortType.Active;
let page = pathSplit[9] ? Number(pathSplit[9]) : 1;
</div>
</div>
- {UserService.Instance.user &&
+ {UserService.Instance.localUserView &&
this.state.subscribedCommunities.length > 0 && (
<div class="card border-secondary mb-3">
<div class="card-body">{this.subscribedCommunities()}</div>
<li class="list-inline-item">{i18n.t("admins")}:</li>
{this.state.siteRes.admins.map(av => (
<li class="list-inline-item">
- <UserListing user={av.user} />
+ <PersonListing person={av.person} />
</li>
))}
</ul>
<Icon icon="rss" classes="text-muted small" />
</a>
)}
- {UserService.Instance.user &&
+ {UserService.Instance.localUserView &&
this.state.listingType == ListingType.Subscribed && (
<a
href={`/feeds/front/${UserService.Instance.auth}.xml?sort=${this.state.sort}`}
get canAdmin(): boolean {
return (
- UserService.Instance.user &&
+ UserService.Instance.localUserView &&
this.state.siteRes.admins
- .map(a => a.user.id)
- .includes(UserService.Instance.user.id)
+ .map(a => a.person.id)
+ .includes(UserService.Instance.localUserView.person.id)
);
}
let nsfwCheck =
!nsfw ||
(nsfw &&
- UserService.Instance.user &&
- UserService.Instance.user.show_nsfw);
+ UserService.Instance.localUserView &&
+ UserService.Instance.localUserView.local_user.show_nsfw);
// Only push these if you're on the first page, and you pass the nsfw check
if (this.state.page == 1 && nsfwCheck) {
let data = wsJsonToRes<AddAdminResponse>(msg).data;
this.state.siteRes.admins = data.admins;
this.setState(this.state);
- } else if (op == UserOperation.BanUser) {
- let data = wsJsonToRes<BanUserResponse>(msg).data;
+ } else if (op == UserOperation.BanPerson) {
+ let data = wsJsonToRes<BanPersonResponse>(msg).data;
let found = this.state.siteRes.banned.find(
- u => (u.user.id = data.user_view.user.id)
+ p => (p.person.id = data.person_view.person.id)
);
// Remove the banned if its found in the list, and the action is an unban
if (found && !data.banned) {
this.state.siteRes.banned = this.state.siteRes.banned.filter(
- i => i.user.id !== data.user_view.user.id
+ i => i.person.id !== data.person_view.person.id
);
} else {
- this.state.siteRes.banned.push(data.user_view);
+ this.state.siteRes.banned.push(data.person_view);
}
this.state.posts
- .filter(p => p.creator.id == data.user_view.user.id)
+ .filter(p => p.creator.id == data.person_view.person.id)
.forEach(p => (p.creator.banned = data.banned));
this.setState(this.state);
<form class="btn btn-sm text-muted font-weight-bold">
<label
htmlFor={`file-upload-${this.id}`}
- className={`mb-0 ${UserService.Instance.user && "pointer"}`}
+ className={`mb-0 ${
+ UserService.Instance.localUserView && "pointer"
+ }`}
data-tippy-content={i18n.t("upload_image")}
>
{this.state.imageLoading ? (
accept="image/*,video/*"
name="file"
class="d-none"
- disabled={!UserService.Instance.user}
+ disabled={!UserService.Instance.localUserView}
onChange={linkEvent(this, this.handleImageUpload)}
/>
</form>
import moment from "moment";
import { i18n } from "../i18next";
import { InitialFetchRequest } from "shared/interfaces";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { CommunityLink } from "./community-link";
import { Spinner } from "./icon";
</span>,
<span>
{" "}
- by <UserListing user={mrc.commenter} />
+ by <PersonListing person={mrc.commenter} />
</span>,
mrc.mod_remove_comment.reason &&
` reason: ${mrc.mod_remove_comment.reason}`,
{mbfc.mod_ban_from_community.banned ? "Banned " : "Unbanned "}{" "}
</span>,
<span>
- <UserListing user={mbfc.banned_user} />
+ <PersonListing person={mbfc.banned_person} />
</span>,
<span> from the community </span>,
<span>
{mac.mod_add_community.removed ? "Removed " : "Appointed "}{" "}
</span>,
<span>
- <UserListing user={mac.modded_user} />
+ <PersonListing person={mac.modded_person} />
</span>,
<span> as a mod to the community </span>,
<span>
return [
<span>{mb.mod_ban.banned ? "Banned " : "Unbanned "} </span>,
<span>
- <UserListing user={mb.banned_user} />
+ <PersonListing person={mb.banned_person} />
</span>,
<div>{mb.mod_ban.reason && ` reason: ${mb.mod_ban.reason}`}</div>,
<div>
return [
<span>{ma.mod_add.removed ? "Removed " : "Appointed "} </span>,
<span>
- <UserListing user={ma.modded_user} />
+ <PersonListing person={ma.modded_person} />
</span>,
<span> as an admin </span>,
];
<MomentTime data={i} />
</td>
<td>
- <UserListing user={i.view.moderator} />
+ <PersonListing person={i.view.moderator} />
</td>
<td>{this.renderModlogType(i)}</td>
</tr>
UserOperation,
GetReplies,
GetRepliesResponse,
- GetUserMentions,
- GetUserMentionsResponse,
+ GetPersonMentions,
+ GetPersonMentionsResponse,
GetPrivateMessages,
PrivateMessagesResponse,
SortType,
// TODO class active corresponding to current page
navbar() {
- let user = UserService.Instance.user || this.props.site_res.my_user;
+ let localUserView =
+ UserService.Instance.localUserView || this.props.site_res.my_user;
return (
<nav class="navbar navbar-expand-lg navbar-light shadow-sm p-0 px-3">
<div class="container">
<li className="nav-item">
<Link
className="nav-link"
- to={`/u/${user.name}`}
+ to={`/u/${localUserView.person.name}`}
title={i18n.t("settings")}
>
<span>
- {user.avatar && showAvatars() && (
- <PictrsImage src={user.avatar} icon />
+ {localUserView.person.avatar && showAvatars() && (
+ <PictrsImage src={localUserView.person.avatar} icon />
)}
- {user.preferred_username
- ? user.preferred_username
- : user.name}
+ {localUserView.person.preferred_username
+ ? localUserView.person.preferred_username
+ : localUserView.person.name}
</span>
</Link>
</li>
this.state.unreadCount = this.calculateUnreadCount();
this.setState(this.state);
this.sendUnreadCount();
- } else if (op == UserOperation.GetUserMentions) {
- let data = wsJsonToRes<GetUserMentionsResponse>(msg).data;
+ } else if (op == UserOperation.GetPersonMentions) {
+ let data = wsJsonToRes<GetPersonMentionsResponse>(msg).data;
let unreadMentions = data.mentions.filter(r => !r.comment.read);
this.state.mentions = unreadMentions;
// This is only called on a successful login
let data = wsJsonToRes<GetSiteResponse>(msg).data;
console.log(data.my_user);
- UserService.Instance.user = data.my_user;
- setTheme(UserService.Instance.user.theme);
+ UserService.Instance.localUserView = data.my_user;
+ setTheme(UserService.Instance.localUserView.local_user.theme);
i18n.changeLanguage(getLanguage());
this.state.isLoggedIn = true;
this.setState(this.state);
let data = wsJsonToRes<CommentResponse>(msg).data;
if (this.state.isLoggedIn) {
- if (data.recipient_ids.includes(UserService.Instance.user.id)) {
+ if (
+ data.recipient_ids.includes(
+ UserService.Instance.localUserView.local_user.id
+ )
+ ) {
this.state.replies.push(data.comment_view);
this.state.unreadCount++;
this.setState(this.state);
if (this.state.isLoggedIn) {
if (
- data.private_message_view.recipient.id == UserService.Instance.user.id
+ data.private_message_view.recipient.id ==
+ UserService.Instance.localUserView.person.id
) {
this.state.messages.push(data.private_message_view);
this.state.unreadCount++;
auth: authField(),
};
- let userMentionsForm: GetUserMentions = {
+ let personMentionsForm: GetPersonMentions = {
sort: SortType.New,
unread_only: true,
page: 1,
if (this.currentLocation !== "/inbox") {
WebSocketService.Instance.send(wsClient.getReplies(repliesForm));
WebSocketService.Instance.send(
- wsClient.getUserMentions(userMentionsForm)
+ wsClient.getPersonMentions(personMentionsForm)
);
WebSocketService.Instance.send(
wsClient.getPrivateMessages(privateMessagesForm)
get canAdmin(): boolean {
return (
- UserService.Instance.user &&
+ UserService.Instance.localUserView &&
this.props.site_res.admins
- .map(a => a.user.id)
- .includes(UserService.Instance.user.id)
+ .map(a => a.person.id)
+ .includes(UserService.Instance.localUserView.person.id)
);
}
requestNotificationPermission() {
- if (UserService.Instance.user) {
+ if (UserService.Instance.localUserView) {
document.addEventListener("DOMContentLoaded", function () {
if (!Notification) {
toast(i18n.t("notifications_error"), "danger");
PostView,
CommentView,
SortType,
- GetUserDetailsResponse,
- UserViewSafe,
+ GetPersonDetailsResponse,
+ PersonViewSafe,
} from "lemmy-js-client";
-import { UserDetailsView } from "../interfaces";
+import { PersonDetailsView } from "../interfaces";
import { commentsToFlatNodes, setupTippy } from "../utils";
import { PostListing } from "./post-listing";
import { CommentNodes } from "./comment-nodes";
-interface UserDetailsProps {
- userRes: GetUserDetailsResponse;
- admins: UserViewSafe[];
+interface PersonDetailsProps {
+ personRes: GetPersonDetailsResponse;
+ admins: PersonViewSafe[];
page: number;
limit: number;
sort: SortType;
enableDownvotes: boolean;
enableNsfw: boolean;
- view: UserDetailsView;
+ view: PersonDetailsView;
onPageChange(page: number): number | any;
}
score: number;
};
-export class UserDetails extends Component<UserDetailsProps, any> {
+export class PersonDetails extends Component<PersonDetailsProps, any> {
constructor(props: any, context: any) {
super(props, context);
}
);
}
- viewSelector(view: UserDetailsView) {
- if (view === UserDetailsView.Overview || view === UserDetailsView.Saved) {
+ viewSelector(view: PersonDetailsView) {
+ if (
+ view === PersonDetailsView.Overview ||
+ view === PersonDetailsView.Saved
+ ) {
return this.overview();
- } else if (view === UserDetailsView.Comments) {
+ } else if (view === PersonDetailsView.Comments) {
return this.comments();
- } else if (view === UserDetailsView.Posts) {
+ } else if (view === PersonDetailsView.Posts) {
return this.posts();
} else {
return null;
overview() {
let id = 0;
- let comments: ItemType[] = this.props.userRes.comments.map(r => ({
+ let comments: ItemType[] = this.props.personRes.comments.map(r => ({
id: id++,
type_: ItemEnum.Comment,
view: r,
published: r.comment.published,
score: r.counts.score,
}));
- let posts: ItemType[] = this.props.userRes.posts.map(r => ({
+ let posts: ItemType[] = this.props.personRes.posts.map(r => ({
id: id++,
type_: ItemEnum.Post,
view: r,
return (
<div>
<CommentNodes
- nodes={commentsToFlatNodes(this.props.userRes.comments)}
+ nodes={commentsToFlatNodes(this.props.personRes.comments)}
admins={this.props.admins}
noIndent
showCommunity
posts() {
return (
<div>
- {this.props.userRes.posts.map(post => (
+ {this.props.personRes.posts.map(post => (
<>
<PostListing
post_view={post}
{i18n.t("prev")}
</button>
)}
- {this.props.userRes.comments.length + this.props.userRes.posts.length >
+ {this.props.personRes.comments.length +
+ this.props.personRes.posts.length >
0 && (
<button
class="btn btn-secondary"
);
}
- nextPage(i: UserDetails) {
+ nextPage(i: PersonDetails) {
i.props.onPageChange(i.props.page + 1);
}
- prevPage(i: UserDetails) {
+ prevPage(i: PersonDetails) {
i.props.onPageChange(i.props.page - 1);
}
}
import { Component } from "inferno";
import { Link } from "inferno-router";
-import { UserSafe } from "lemmy-js-client";
+import { PersonSafe } from "lemmy-js-client";
import { showAvatars, hostname, isCakeDay } from "../utils";
import { CakeDay } from "./cake-day";
import { PictrsImage } from "./pictrs-image";
-interface UserListingProps {
- user: UserSafe;
+interface PersonListingProps {
+ person: PersonSafe;
realLink?: boolean;
useApubName?: boolean;
muted?: boolean;
showApubName?: boolean;
}
-export class UserListing extends Component<UserListingProps, any> {
+export class PersonListing extends Component<PersonListingProps, any> {
constructor(props: any, context: any) {
super(props, context);
}
render() {
- let user = this.props.user;
- let local = user.local == null ? true : user.local;
+ let person = this.props.person;
+ let local = person.local == null ? true : person.local;
let apubName: string, link: string;
if (local) {
- apubName = `@${user.name}`;
- link = `/u/${user.name}`;
+ apubName = `@${person.name}`;
+ link = `/u/${person.name}`;
} else {
- apubName = `@${user.name}@${hostname(user.actor_id)}`;
- link = !this.props.realLink ? `/user/${user.id}` : user.actor_id;
+ apubName = `@${person.name}@${hostname(person.actor_id)}`;
+ link = !this.props.realLink ? `/user/${person.id}` : person.actor_id;
}
let displayName = this.props.useApubName
? apubName
- : user.preferred_username
- ? user.preferred_username
+ : person.preferred_username
+ ? person.preferred_username
: apubName;
- if (this.props.showApubName && !local && user.preferred_username) {
+ if (this.props.showApubName && !local && person.preferred_username) {
displayName = `${displayName} (${apubName})`;
}
className={this.props.muted ? "text-muted" : "text-info"}
to={link}
>
- {!this.props.hideAvatar && user.avatar && showAvatars() && (
- <PictrsImage src={user.avatar} icon />
+ {!this.props.hideAvatar && person.avatar && showAvatars() && (
+ <PictrsImage src={person.avatar} icon />
)}
<span>{displayName}</span>
</Link>
- {isCakeDay(user.published) && <CakeDay creatorName={apubName} />}
+ {isCakeDay(person.published) && <CakeDay creatorName={apubName} />}
</>
);
}
LoginResponse,
DeleteAccount,
GetSiteResponse,
- GetUserDetailsResponse,
+ GetPersonDetailsResponse,
AddAdminResponse,
- GetUserDetails,
+ GetPersonDetails,
CommentResponse,
PostResponse,
- BanUserResponse,
+ BanPersonResponse,
} from "lemmy-js-client";
-import { InitialFetchRequest, UserDetailsView } from "../interfaces";
+import { InitialFetchRequest, PersonDetailsView } from "../interfaces";
import { WebSocketService, UserService } from "../services";
import {
wsJsonToRes,
saveScrollPosition,
restoreScrollPosition,
} from "../utils";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { HtmlTags } from "./html-tags";
import { SortSelect } from "./sort-select";
import { ListingTypeSelect } from "./listing-type-select";
import { MomentTime } from "./moment-time";
import { i18n } from "../i18next";
import moment from "moment";
-import { UserDetails } from "./user-details";
+import { PersonDetails } from "./person-details";
import { MarkdownTextArea } from "./markdown-textarea";
import { Icon, Spinner } from "./icon";
import { ImageUploadForm } from "./image-upload-form";
import { BannerIconHeader } from "./banner-icon-header";
import { CommunityLink } from "./community-link";
-interface UserState {
- userRes: GetUserDetailsResponse;
- userId: number;
+interface PersonState {
+ personRes: GetPersonDetailsResponse;
+ personId: number;
userName: string;
- view: UserDetailsView;
+ view: PersonDetailsView;
sort: SortType;
page: number;
loading: boolean;
siteRes: GetSiteResponse;
}
-interface UserProps {
- view: UserDetailsView;
+interface PersonProps {
+ view: PersonDetailsView;
sort: SortType;
page: number;
- user_id: number | null;
+ person_id: number | null;
username: string;
}
page?: number;
}
-export class User extends Component<any, UserState> {
+export class Person extends Component<any, PersonState> {
private isoData = setIsoData(this.context);
private subscription: Subscription;
- private emptyState: UserState = {
- userRes: undefined,
- userId: getIdFromProps(this.props),
+ private emptyState: PersonState = {
+ personRes: undefined,
+ personId: getIdFromProps(this.props),
userName: getUsernameFromProps(this.props),
loading: true,
- view: User.getViewFromProps(this.props.match.view),
- sort: User.getSortTypeFromProps(this.props.match.sort),
- page: User.getPageFromProps(this.props.match.page),
+ view: Person.getViewFromProps(this.props.match.view),
+ sort: Person.getSortTypeFromProps(this.props.match.sort),
+ page: Person.getPageFromProps(this.props.match.page),
userSettingsForm: {
show_nsfw: null,
theme: null,
// Only fetch the data if coming from another route
if (this.isoData.path == this.context.router.route.match.url) {
- this.state.userRes = this.isoData.routeData[0];
+ this.state.personRes = this.isoData.routeData[0];
this.setUserInfo();
this.state.loading = false;
} else {
}
fetchUserData() {
- let form: GetUserDetails = {
- user_id: this.state.userId,
+ let form: GetPersonDetails = {
+ person_id: this.state.personId,
username: this.state.userName,
sort: this.state.sort,
- saved_only: this.state.view === UserDetailsView.Saved,
+ saved_only: this.state.view === PersonDetailsView.Saved,
page: this.state.page,
limit: fetchLimit,
auth: authField(false),
};
- WebSocketService.Instance.send(wsClient.getUserDetails(form));
+ WebSocketService.Instance.send(wsClient.getPersonDetails(form));
}
get isCurrentUser() {
return (
- UserService.Instance.user &&
- UserService.Instance.user.id == this.state.userRes.user_view.user.id
+ UserService.Instance.localUserView?.person.id ==
+ this.state.personRes.person_view.person.id
);
}
- static getViewFromProps(view: string): UserDetailsView {
- return view ? UserDetailsView[view] : UserDetailsView.Overview;
+ static getViewFromProps(view: string): PersonDetailsView {
+ return view ? PersonDetailsView[view] : PersonDetailsView.Overview;
}
static getSortTypeFromProps(sort: string): SortType {
// It can be /u/me, or /username/1
let idOrName = pathSplit[2];
- let user_id: number;
+ let person_id: number;
let username: string;
if (isNaN(Number(idOrName))) {
username = idOrName;
} else {
- user_id = Number(idOrName);
+ person_id = Number(idOrName);
}
let view = this.getViewFromProps(pathSplit[4]);
let sort = this.getSortTypeFromProps(pathSplit[6]);
let page = this.getPageFromProps(Number(pathSplit[8]));
- let form: GetUserDetails = {
+ let form: GetPersonDetails = {
sort,
- saved_only: view === UserDetailsView.Saved,
+ saved_only: view === PersonDetailsView.Saved,
page,
limit: fetchLimit,
};
setOptionalAuth(form, req.auth);
- this.setIdOrName(form, user_id, username);
- promises.push(req.client.getUserDetails(form));
+ this.setIdOrName(form, person_id, username);
+ promises.push(req.client.getPersonDetails(form));
return promises;
}
static setIdOrName(obj: any, id: number, name_: string) {
if (id) {
- obj.user_id = id;
+ obj.person_id = id;
} else {
obj.username = name_;
}
saveScrollPosition(this.context);
}
- static getDerivedStateFromProps(props: any): UserProps {
+ static getDerivedStateFromProps(props: any): PersonProps {
return {
view: this.getViewFromProps(props.match.params.view),
sort: this.getSortTypeFromProps(props.match.params.sort),
page: this.getPageFromProps(props.match.params.page),
- user_id: Number(props.match.params.id) || null,
+ person_id: Number(props.match.params.id) || null,
username: props.match.params.username,
};
}
}
get documentTitle(): string {
- return `@${this.state.userRes.user_view.user.name} - ${this.state.siteRes.site_view.site.name}`;
+ return `@${this.state.personRes.person_view.person.name} - ${this.state.siteRes.site_view.site.name}`;
}
get bioTag(): string {
- return this.state.userRes.user_view.user.bio
- ? previewLines(this.state.userRes.user_view.user.bio)
+ return this.state.personRes.person_view.person.bio
+ ? previewLines(this.state.personRes.person_view.person.bio)
: undefined;
}
title={this.documentTitle}
path={this.context.router.route.match.url}
description={this.bioTag}
- image={this.state.userRes.user_view.user.avatar}
+ image={this.state.personRes.person_view.person.avatar}
/>
{this.userInfo()}
<hr />
</>
{!this.state.loading && this.selects()}
- <UserDetails
- userRes={this.state.userRes}
+ <PersonDetails
+ personRes={this.state.personRes}
admins={this.state.siteRes.admins}
sort={this.state.sort}
page={this.state.page}
<div class="btn-group btn-group-toggle flex-wrap mb-2">
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Overview && "active"}
+ ${this.state.view == PersonDetailsView.Overview && "active"}
`}
>
<input
type="radio"
- value={UserDetailsView.Overview}
- checked={this.state.view === UserDetailsView.Overview}
+ value={PersonDetailsView.Overview}
+ checked={this.state.view === PersonDetailsView.Overview}
onChange={linkEvent(this, this.handleViewChange)}
/>
{i18n.t("overview")}
</label>
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Comments && "active"}
+ ${this.state.view == PersonDetailsView.Comments && "active"}
`}
>
<input
type="radio"
- value={UserDetailsView.Comments}
- checked={this.state.view == UserDetailsView.Comments}
+ value={PersonDetailsView.Comments}
+ checked={this.state.view == PersonDetailsView.Comments}
onChange={linkEvent(this, this.handleViewChange)}
/>
{i18n.t("comments")}
</label>
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Posts && "active"}
+ ${this.state.view == PersonDetailsView.Posts && "active"}
`}
>
<input
type="radio"
- value={UserDetailsView.Posts}
- checked={this.state.view == UserDetailsView.Posts}
+ value={PersonDetailsView.Posts}
+ checked={this.state.view == PersonDetailsView.Posts}
onChange={linkEvent(this, this.handleViewChange)}
/>
{i18n.t("posts")}
</label>
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Saved && "active"}
+ ${this.state.view == PersonDetailsView.Saved && "active"}
`}
>
<input
type="radio"
- value={UserDetailsView.Saved}
- checked={this.state.view == UserDetailsView.Saved}
+ value={PersonDetailsView.Saved}
+ checked={this.state.view == PersonDetailsView.Saved}
onChange={linkEvent(this, this.handleViewChange)}
/>
{i18n.t("saved")}
}
userInfo() {
- let uv = this.state.userRes?.user_view;
+ let pv = this.state.personRes?.person_view;
return (
<div>
- <BannerIconHeader banner={uv.user.banner} icon={uv.user.avatar} />
+ <BannerIconHeader banner={pv.person.banner} icon={pv.person.avatar} />
<div class="mb-3">
<div class="">
<div class="mb-0 d-flex flex-wrap">
<div>
- {uv.user.preferred_username && (
- <h5 class="mb-0">{uv.user.preferred_username}</h5>
+ {pv.person.preferred_username && (
+ <h5 class="mb-0">{pv.person.preferred_username}</h5>
)}
<ul class="list-inline mb-2">
<li className="list-inline-item">
- <UserListing
- user={uv.user}
+ <PersonListing
+ person={pv.person}
realLink
useApubName
muted
hideAvatar
/>
</li>
- {uv.user.banned && (
+ {pv.person.banned && (
<li className="list-inline-item badge badge-danger">
{i18n.t("banned")}
</li>
</button>
) : (
<>
+ {/* TODO matrix ids aren't currently federated, so don't come back with GetPersonDetails
<a
className={`d-flex align-self-start btn btn-secondary mr-2 ${
- !uv.user.matrix_user_id && "invisible"
+ !pv.local_user.matrix_user_id && "invisible"
}`}
rel="noopener"
- href={`https://matrix.to/#/${uv.user.matrix_user_id}`}
+ href={`https://matrix.to/#/${pv.local_user.matrix_user_id}`}
>
{i18n.t("send_secure_message")}
</a>
+ */}
+
<Link
className={"d-flex align-self-start btn btn-secondary"}
- to={`/create_private_message/recipient/${uv.user.id}`}
+ to={`/create_private_message/recipient/${pv.person.id}`}
>
{i18n.t("send_message")}
</Link>
</>
)}
</div>
- {uv.user.bio && (
+ {pv.person.bio && (
<div className="d-flex align-items-center mb-2">
<div
className="md-div"
- dangerouslySetInnerHTML={mdToHtml(uv.user.bio)}
+ dangerouslySetInnerHTML={mdToHtml(pv.person.bio)}
/>
</div>
)}
<div>
<ul class="list-inline mb-2">
<li className="list-inline-item badge badge-light">
- {i18n.t("number_of_posts", { count: uv.counts.post_count })}
+ {i18n.t("number_of_posts", { count: pv.counts.post_count })}
</li>
<li className="list-inline-item badge badge-light">
{i18n.t("number_of_comments", {
- count: uv.counts.comment_count,
+ count: pv.counts.comment_count,
})}
</li>
</ul>
</div>
<div class="text-muted">
{i18n.t("joined")}{" "}
- <MomentTime data={uv.user} showAgo ignoreUpdated />
+ <MomentTime data={pv.person} showAgo ignoreUpdated />
</div>
<div className="d-flex align-items-center text-muted mb-2">
<Icon icon="cake" />
<span className="ml-2">
{i18n.t("cake_day_title")}{" "}
- {moment.utc(uv.user.published).local().format("MMM DD, YYYY")}
+ {moment.utc(pv.person.published).local().format("MMM DD, YYYY")}
</span>
</div>
</div>
moderates() {
return (
<div>
- {this.state.userRes.moderates.length > 0 && (
+ {this.state.personRes.moderates.length > 0 && (
<div class="card border-secondary mb-3">
<div class="card-body">
<h5>{i18n.t("moderates")}</h5>
<ul class="list-unstyled mb-0">
- {this.state.userRes.moderates.map(cmv => (
+ {this.state.personRes.moderates.map(cmv => (
<li>
<CommunityLink community={cmv.community} />
</li>
follows() {
return (
<div>
- {this.state.userRes.follows.length > 0 && (
+ {this.state.personRes.follows.length > 0 && (
<div class="card border-secondary mb-3">
<div class="card-body">
<h5>{i18n.t("subscribed")}</h5>
<ul class="list-unstyled mb-0">
- {this.state.userRes.follows.map(cfv => (
+ {this.state.personRes.follows.map(cfv => (
<li>
<CommunityLink community={cfv.community} />
</li>
updateUrl(paramUpdates: UrlParams) {
const page = paramUpdates.page || this.state.page;
- const viewStr = paramUpdates.view || UserDetailsView[this.state.view];
+ const viewStr = paramUpdates.view || PersonDetailsView[this.state.view];
const sortStr = paramUpdates.sort || this.state.sort;
let typeView = this.state.userName
? `/u/${this.state.userName}`
- : `/user/${this.state.userId}`;
+ : `/user/${this.state.personId}`;
this.props.history.push(
`${typeView}/view/${viewStr}/sort/${sortStr}/page/${page}`
this.updateUrl({ sort: val, page: 1 });
}
- handleViewChange(i: User, event: any) {
+ handleViewChange(i: Person, event: any) {
i.updateUrl({
- view: UserDetailsView[Number(event.target.value)],
+ view: PersonDetailsView[Number(event.target.value)],
page: 1,
});
}
- handleUserSettingsShowNsfwChange(i: User, event: any) {
+ handleUserSettingsShowNsfwChange(i: Person, event: any) {
i.state.userSettingsForm.show_nsfw = event.target.checked;
i.setState(i.state);
}
- handleUserSettingsShowAvatarsChange(i: User, event: any) {
+ handleUserSettingsShowAvatarsChange(i: Person, event: any) {
i.state.userSettingsForm.show_avatars = event.target.checked;
- UserService.Instance.user.show_avatars = event.target.checked; // Just for instant updates
+ UserService.Instance.localUserView.local_user.show_avatars =
+ event.target.checked; // Just for instant updates
i.setState(i.state);
}
- handleUserSettingsSendNotificationsToEmailChange(i: User, event: any) {
+ handleUserSettingsSendNotificationsToEmailChange(i: Person, event: any) {
i.state.userSettingsForm.send_notifications_to_email = event.target.checked;
i.setState(i.state);
}
- handleUserSettingsThemeChange(i: User, event: any) {
+ handleUserSettingsThemeChange(i: Person, event: any) {
i.state.userSettingsForm.theme = event.target.value;
setTheme(event.target.value, true);
i.setState(i.state);
}
- handleUserSettingsLangChange(i: User, event: any) {
+ handleUserSettingsLangChange(i: Person, event: any) {
i.state.userSettingsForm.lang = event.target.value;
i18n.changeLanguage(getLanguage(i.state.userSettingsForm.lang));
i.setState(i.state);
this.setState(this.state);
}
- handleUserSettingsEmailChange(i: User, event: any) {
+ handleUserSettingsEmailChange(i: Person, event: any) {
i.state.userSettingsForm.email = event.target.value;
i.setState(i.state);
}
this.setState(this.state);
}
- handleUserSettingsPreferredUsernameChange(i: User, event: any) {
+ handleUserSettingsPreferredUsernameChange(i: Person, event: any) {
i.state.userSettingsForm.preferred_username = event.target.value;
i.setState(i.state);
}
- handleUserSettingsMatrixUserIdChange(i: User, event: any) {
+ handleUserSettingsMatrixUserIdChange(i: Person, event: any) {
i.state.userSettingsForm.matrix_user_id = event.target.value;
if (
i.state.userSettingsForm.matrix_user_id == "" &&
- !i.state.userRes.user_view.user.matrix_user_id
+ !UserService.Instance.localUserView.local_user.matrix_user_id
) {
i.state.userSettingsForm.matrix_user_id = undefined;
}
i.setState(i.state);
}
- handleUserSettingsNewPasswordChange(i: User, event: any) {
+ handleUserSettingsNewPasswordChange(i: Person, event: any) {
i.state.userSettingsForm.new_password = event.target.value;
if (i.state.userSettingsForm.new_password == "") {
i.state.userSettingsForm.new_password = undefined;
i.setState(i.state);
}
- handleUserSettingsNewPasswordVerifyChange(i: User, event: any) {
+ handleUserSettingsNewPasswordVerifyChange(i: Person, event: any) {
i.state.userSettingsForm.new_password_verify = event.target.value;
if (i.state.userSettingsForm.new_password_verify == "") {
i.state.userSettingsForm.new_password_verify = undefined;
i.setState(i.state);
}
- handleUserSettingsOldPasswordChange(i: User, event: any) {
+ handleUserSettingsOldPasswordChange(i: Person, event: any) {
i.state.userSettingsForm.old_password = event.target.value;
if (i.state.userSettingsForm.old_password == "") {
i.state.userSettingsForm.old_password = undefined;
i.setState(i.state);
}
- handleUserSettingsSubmit(i: User, event: any) {
+ handleUserSettingsSubmit(i: Person, event: any) {
event.preventDefault();
i.state.userSettingsLoading = true;
i.setState(i.state);
);
}
- handleDeleteAccountShowConfirmToggle(i: User, event: any) {
+ handleDeleteAccountShowConfirmToggle(i: Person, event: any) {
event.preventDefault();
i.state.deleteAccountShowConfirm = !i.state.deleteAccountShowConfirm;
i.setState(i.state);
}
- handleDeleteAccountPasswordChange(i: User, event: any) {
+ handleDeleteAccountPasswordChange(i: Person, event: any) {
i.state.deleteAccountForm.password = event.target.value;
i.setState(i.state);
}
- handleLogoutClick(i: User) {
+ handleLogoutClick(i: Person) {
UserService.Instance.logout();
i.context.router.history.push("/");
}
- handleDeleteAccount(i: User, event: any) {
+ handleDeleteAccount(i: Person, event: any) {
event.preventDefault();
i.state.deleteAccountLoading = true;
i.setState(i.state);
setUserInfo() {
if (this.isCurrentUser) {
this.state.userSettingsForm.show_nsfw =
- UserService.Instance.user.show_nsfw;
- this.state.userSettingsForm.theme = UserService.Instance.user.theme
- ? UserService.Instance.user.theme
+ UserService.Instance.localUserView.local_user.show_nsfw;
+ this.state.userSettingsForm.theme = UserService.Instance.localUserView
+ .local_user.theme
+ ? UserService.Instance.localUserView.local_user.theme
: "browser";
this.state.userSettingsForm.default_sort_type =
- UserService.Instance.user.default_sort_type;
+ UserService.Instance.localUserView.local_user.default_sort_type;
this.state.userSettingsForm.default_listing_type =
- UserService.Instance.user.default_listing_type;
- this.state.userSettingsForm.lang = UserService.Instance.user.lang;
- this.state.userSettingsForm.avatar = UserService.Instance.user.avatar;
- this.state.userSettingsForm.banner = UserService.Instance.user.banner;
+ UserService.Instance.localUserView.local_user.default_listing_type;
+ this.state.userSettingsForm.lang =
+ UserService.Instance.localUserView.local_user.lang;
+ this.state.userSettingsForm.avatar =
+ UserService.Instance.localUserView.person.avatar;
+ this.state.userSettingsForm.banner =
+ UserService.Instance.localUserView.person.banner;
this.state.userSettingsForm.preferred_username =
- UserService.Instance.user.preferred_username;
+ UserService.Instance.localUserView.person.preferred_username;
this.state.userSettingsForm.show_avatars =
- UserService.Instance.user.show_avatars;
- this.state.userSettingsForm.email = UserService.Instance.user.email;
- this.state.userSettingsForm.bio = UserService.Instance.user.bio;
+ UserService.Instance.localUserView.local_user.show_avatars;
+ this.state.userSettingsForm.email =
+ UserService.Instance.localUserView.local_user.email;
+ this.state.userSettingsForm.bio =
+ UserService.Instance.localUserView.person.bio;
this.state.userSettingsForm.send_notifications_to_email =
- UserService.Instance.user.send_notifications_to_email;
+ UserService.Instance.localUserView.local_user.send_notifications_to_email;
this.state.userSettingsForm.matrix_user_id =
- UserService.Instance.user.matrix_user_id;
+ UserService.Instance.localUserView.local_user.matrix_user_id;
}
}
return;
} else if (msg.reconnect) {
this.fetchUserData();
- } else if (op == UserOperation.GetUserDetails) {
- // Since the UserDetails contains posts/comments as well as some general user info we listen here as well
+ } else if (op == UserOperation.GetPersonDetails) {
+ // Since the PersonDetails contains posts/comments as well as some general user info we listen here as well
// and set the parent state if it is not set or differs
// TODO this might need to get abstracted
- let data = wsJsonToRes<GetUserDetailsResponse>(msg).data;
- this.state.userRes = data;
+ let data = wsJsonToRes<GetPersonDetailsResponse>(msg).data;
+ this.state.personRes = data;
this.setUserInfo();
this.state.loading = false;
this.setState(this.state);
} else if (op == UserOperation.SaveUserSettings) {
let data = wsJsonToRes<LoginResponse>(msg).data;
UserService.Instance.login(data);
- this.state.userRes.user_view.user.bio = this.state.userSettingsForm.bio;
- this.state.userRes.user_view.user.preferred_username = this.state.userSettingsForm.preferred_username;
- this.state.userRes.user_view.user.banner = this.state.userSettingsForm.banner;
- this.state.userRes.user_view.user.avatar = this.state.userSettingsForm.avatar;
+ this.state.personRes.person_view.person.bio = this.state.userSettingsForm.bio;
+ this.state.personRes.person_view.person.preferred_username = this.state.userSettingsForm.preferred_username;
+ this.state.personRes.person_view.person.banner = this.state.userSettingsForm.banner;
+ this.state.personRes.person_view.person.avatar = this.state.userSettingsForm.avatar;
this.state.userSettingsLoading = false;
this.setState(this.state);
this.setState(this.state);
} else if (op == UserOperation.CreateCommentLike) {
let data = wsJsonToRes<CommentResponse>(msg).data;
- createCommentLikeRes(data.comment_view, this.state.userRes.comments);
+ createCommentLikeRes(data.comment_view, this.state.personRes.comments);
this.setState(this.state);
} else if (
op == UserOperation.EditComment ||
op == UserOperation.RemoveComment
) {
let data = wsJsonToRes<CommentResponse>(msg).data;
- editCommentRes(data.comment_view, this.state.userRes.comments);
+ editCommentRes(data.comment_view, this.state.personRes.comments);
this.setState(this.state);
} else if (op == UserOperation.CreateComment) {
let data = wsJsonToRes<CommentResponse>(msg).data;
if (
- UserService.Instance.user &&
- data.comment_view.creator.id == UserService.Instance.user.id
+ UserService.Instance.localUserView &&
+ data.comment_view.creator.id ==
+ UserService.Instance.localUserView.person.id
) {
toast(i18n.t("reply_sent"));
}
} else if (op == UserOperation.SaveComment) {
let data = wsJsonToRes<CommentResponse>(msg).data;
- saveCommentRes(data.comment_view, this.state.userRes.comments);
+ saveCommentRes(data.comment_view, this.state.personRes.comments);
this.setState(this.state);
} else if (
op == UserOperation.EditPost ||
op == UserOperation.SavePost
) {
let data = wsJsonToRes<PostResponse>(msg).data;
- editPostFindRes(data.post_view, this.state.userRes.posts);
+ editPostFindRes(data.post_view, this.state.personRes.posts);
this.setState(this.state);
} else if (op == UserOperation.CreatePostLike) {
let data = wsJsonToRes<PostResponse>(msg).data;
- createPostLikeFindRes(data.post_view, this.state.userRes.posts);
+ createPostLikeFindRes(data.post_view, this.state.personRes.posts);
this.setState(this.state);
- } else if (op == UserOperation.BanUser) {
- let data = wsJsonToRes<BanUserResponse>(msg).data;
- this.state.userRes.comments
- .filter(c => c.creator.id == data.user_view.user.id)
+ } else if (op == UserOperation.BanPerson) {
+ let data = wsJsonToRes<BanPersonResponse>(msg).data;
+ this.state.personRes.comments
+ .filter(c => c.creator.id == data.person_view.person.id)
.forEach(c => (c.creator.banned = data.banned));
- this.state.userRes.posts
- .filter(c => c.creator.id == data.user_view.user.id)
+ this.state.personRes.posts
+ .filter(c => c.creator.id == data.person_view.person.id)
.forEach(c => (c.creator.banned = data.banned));
this.setState(this.state);
}
<label
htmlFor="file-upload"
className={`${
- UserService.Instance.user && "pointer"
+ UserService.Instance.localUserView && "pointer"
} d-inline-block float-right text-muted font-weight-bold`}
data-tippy-content={i18n.t("upload_image")}
>
accept="image/*,video/*"
name="file"
class="d-none"
- disabled={!UserService.Instance.user}
+ disabled={!UserService.Instance.localUserView}
onChange={linkEvent(this, this.handleImageUpload)}
/>
</form>
return;
} else if (op == UserOperation.CreatePost) {
let data = wsJsonToRes<PostResponse>(msg).data;
- if (data.post_view.creator.id == UserService.Instance.user.id) {
+ if (
+ data.post_view.creator.id ==
+ UserService.Instance.localUserView.person.id
+ ) {
this.state.loading = false;
this.props.onCreate(data.post_view);
}
} else if (op == UserOperation.EditPost) {
let data = wsJsonToRes<PostResponse>(msg).data;
- if (data.post_view.creator.id == UserService.Instance.user.id) {
+ if (
+ data.post_view.creator.id ==
+ UserService.Instance.localUserView.person.id
+ ) {
this.state.loading = false;
this.props.onEdit(data.post_view);
}
LockPost,
StickyPost,
SavePost,
- UserViewSafe,
+ PersonViewSafe,
BanFromCommunity,
- BanUser,
+ BanPerson,
AddModToCommunity,
AddAdmin,
TransferSite,
import { MomentTime } from "./moment-time";
import { PostForm } from "./post-form";
import { IFramelyCard } from "./iframely-card";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { CommunityLink } from "./community-link";
import { PictrsImage } from "./pictrs-image";
import { Icon } from "./icon";
showCommunity?: boolean;
showBody?: boolean;
moderators?: CommunityModeratorView[];
- admins?: UserViewSafe[];
+ admins?: PersonViewSafe[];
enableDownvotes: boolean;
enableNsfw: boolean;
}
return (
<ul class="list-inline mb-1 text-muted small">
<li className="list-inline-item">
- <UserListing user={post_view.creator} />
+ <PersonListing person={post_view.creator} />
{this.isMod && (
<span className="mx-1 badge badge-light">{i18n.t("mod")}</span>
postActions(mobile = false) {
let post_view = this.props.post_view;
return (
- UserService.Instance.user && (
+ UserService.Instance.localUserView && (
<>
{this.props.showBody && (
<>
private get myPost(): boolean {
return (
- UserService.Instance.user &&
- this.props.post_view.creator.id == UserService.Instance.user.id
+ UserService.Instance.localUserView &&
+ this.props.post_view.creator.id ==
+ UserService.Instance.localUserView.person.id
);
}
return (
this.props.admins &&
isMod(
- this.props.admins.map(a => a.user.id),
+ this.props.admins.map(a => a.person.id),
this.props.post_view.creator.id
)
);
get canMod(): boolean {
if (this.props.admins && this.props.moderators) {
let adminsThenMods = this.props.admins
- .map(a => a.user.id)
+ .map(a => a.person.id)
.concat(this.props.moderators.map(m => m.moderator.id));
return canMod(
- UserService.Instance.user,
+ UserService.Instance.localUserView,
adminsThenMods,
this.props.post_view.creator.id
);
get canModOnSelf(): boolean {
if (this.props.admins && this.props.moderators) {
let adminsThenMods = this.props.admins
- .map(a => a.user.id)
+ .map(a => a.person.id)
.concat(this.props.moderators.map(m => m.moderator.id));
return canMod(
- UserService.Instance.user,
+ UserService.Instance.localUserView,
adminsThenMods,
this.props.post_view.creator.id,
true
return (
this.props.admins &&
canMod(
- UserService.Instance.user,
- this.props.admins.map(a => a.user.id),
+ UserService.Instance.localUserView,
+ this.props.admins.map(a => a.person.id),
this.props.post_view.creator.id
)
);
get amCommunityCreator(): boolean {
return (
this.props.moderators &&
- UserService.Instance.user &&
- this.props.post_view.creator.id != UserService.Instance.user.id &&
- UserService.Instance.user.id == this.props.moderators[0].moderator.id
+ UserService.Instance.localUserView &&
+ this.props.post_view.creator.id !=
+ UserService.Instance.localUserView.person.id &&
+ UserService.Instance.localUserView.person.id ==
+ this.props.moderators[0].moderator.id
);
}
get amSiteCreator(): boolean {
return (
this.props.admins &&
- UserService.Instance.user &&
- this.props.post_view.creator.id != UserService.Instance.user.id &&
- UserService.Instance.user.id == this.props.admins[0].user.id
+ UserService.Instance.localUserView &&
+ this.props.post_view.creator.id !=
+ UserService.Instance.localUserView.person.id &&
+ UserService.Instance.localUserView.person.id ==
+ this.props.admins[0].person.id
);
}
handlePostLike(i: PostListing, event: any) {
event.preventDefault();
- if (!UserService.Instance.user) {
+ if (!UserService.Instance.localUserView) {
this.context.router.history.push(`/login`);
}
handlePostDisLike(i: PostListing, event: any) {
event.preventDefault();
- if (!UserService.Instance.user) {
+ if (!UserService.Instance.localUserView) {
this.context.router.history.push(`/login`);
}
i.state.removeData = false;
}
let form: BanFromCommunity = {
- user_id: i.props.post_view.creator.id,
+ person_id: i.props.post_view.creator.id,
community_id: i.props.post_view.community.id,
ban,
remove_data: i.state.removeData,
if (ban == false) {
i.state.removeData = false;
}
- let form: BanUser = {
- user_id: i.props.post_view.creator.id,
+ let form: BanPerson = {
+ person_id: i.props.post_view.creator.id,
ban,
remove_data: i.state.removeData,
reason: i.state.banReason,
expires: getUnixTime(i.state.banExpires),
auth: authField(),
};
- WebSocketService.Instance.send(wsClient.banUser(form));
+ WebSocketService.Instance.send(wsClient.banPerson(form));
}
i.state.showBanDialog = false;
handleAddModToCommunity(i: PostListing) {
let form: AddModToCommunity = {
- user_id: i.props.post_view.creator.id,
+ person_id: i.props.post_view.creator.id,
community_id: i.props.post_view.community.id,
added: !i.isMod,
auth: authField(),
handleAddAdmin(i: PostListing) {
let form: AddAdmin = {
- user_id: i.props.post_view.creator.id,
+ person_id: i.props.post_view.creator.id,
added: !i.isAdmin,
auth: authField(),
};
handleTransferCommunity(i: PostListing) {
let form: TransferCommunity = {
community_id: i.props.post_view.community.id,
- user_id: i.props.post_view.creator.id,
+ person_id: i.props.post_view.creator.id,
auth: authField(),
};
WebSocketService.Instance.send(wsClient.transferCommunity(form));
handleTransferSite(i: PostListing) {
let form: TransferSite = {
- user_id: i.props.post_view.creator.id,
+ person_id: i.props.post_view.creator.id,
auth: authField(),
};
WebSocketService.Instance.send(wsClient.transferSite(form));
CommentResponse,
CommunityResponse,
BanFromCommunityResponse,
- BanUserResponse,
+ BanPersonResponse,
AddModToCommunityResponse,
AddAdminResponse,
SearchType,
let parent = this.state.postRes.comments.find(
c => found.comment.parent_id == c.comment.id
);
- let parent_user_id = parent
+ let parent_person_id = parent
? parent.creator.id
: this.state.postRes.post_view.creator.id;
if (
- UserService.Instance.user &&
- UserService.Instance.user.id == parent_user_id
+ UserService.Instance.localUserView &&
+ UserService.Instance.localUserView.person.id == parent_person_id
) {
let form: MarkCommentAsRead = {
comment_id: found.comment.id,
} else if (op == UserOperation.BanFromCommunity) {
let data = wsJsonToRes<BanFromCommunityResponse>(msg).data;
this.state.postRes.comments
- .filter(c => c.creator.id == data.user_view.user.id)
+ .filter(c => c.creator.id == data.person_view.person.id)
.forEach(c => (c.creator_banned_from_community = data.banned));
- if (this.state.postRes.post_view.creator.id == data.user_view.user.id) {
+ if (
+ this.state.postRes.post_view.creator.id == data.person_view.person.id
+ ) {
this.state.postRes.post_view.creator_banned_from_community =
data.banned;
}
let data = wsJsonToRes<AddModToCommunityResponse>(msg).data;
this.state.postRes.moderators = data.moderators;
this.setState(this.state);
- } else if (op == UserOperation.BanUser) {
- let data = wsJsonToRes<BanUserResponse>(msg).data;
+ } else if (op == UserOperation.BanPerson) {
+ let data = wsJsonToRes<BanPersonResponse>(msg).data;
this.state.postRes.comments
- .filter(c => c.creator.id == data.user_view.user.id)
+ .filter(c => c.creator.id == data.person_view.person.id)
.forEach(c => (c.creator.banned = data.banned));
- if (this.state.postRes.post_view.creator.id == data.user_view.user.id) {
+ if (
+ this.state.postRes.post_view.creator.id == data.person_view.person.id
+ ) {
this.state.postRes.post_view.creator.banned = data.banned;
}
this.setState(this.state);
EditPrivateMessage,
PrivateMessageView,
PrivateMessageResponse,
- UserSafe,
+ PersonSafe,
UserOperation,
} from "lemmy-js-client";
import { WebSocketService } from "../services";
wsClient,
authField,
} from "../utils";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { MarkdownTextArea } from "./markdown-textarea";
import { Icon, Spinner } from "./icon";
import { i18n } from "../i18next";
import { T } from "inferno-i18next";
interface PrivateMessageFormProps {
- recipient: UserSafe;
+ recipient: PersonSafe;
privateMessage?: PrivateMessageView; // If a pm is given, that means this is an edit
onCancel?(): any;
onCreate?(message: PrivateMessageView): any;
</label>
<div class="col-sm-10 form-control-plaintext">
- <UserListing user={this.props.recipient} />
+ <PersonListing person={this.props.recipient} />
</div>
</div>
)}
PrivateMessageView,
DeletePrivateMessage,
MarkPrivateMessageAsRead,
- UserSafe,
+ PersonSafe,
} from "lemmy-js-client";
import { WebSocketService, UserService } from "../services";
import { authField, mdToHtml, toast, wsClient } from "../utils";
import { MomentTime } from "./moment-time";
import { PrivateMessageForm } from "./private-message-form";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { Icon } from "./icon";
import { i18n } from "../i18next";
get mine(): boolean {
return (
- UserService.Instance.user &&
- UserService.Instance.user.id == this.props.private_message_view.creator.id
+ UserService.Instance.localUserView &&
+ UserService.Instance.localUserView.person.id ==
+ this.props.private_message_view.creator.id
);
}
render() {
let message_view = this.props.private_message_view;
// TODO check this again
- let userOther: UserSafe = this.mine
+ let otherPerson: PersonSafe = this.mine
? message_view.recipient
: message_view.creator;
{this.mine ? i18n.t("to") : i18n.t("from")}
</li>
<li className="list-inline-item">
- <UserListing user={userOther} />
+ <PersonListing person={otherPerson} />
</li>
<li className="list-inline-item">
<span>
</ul>
{this.state.showEdit && (
<PrivateMessageForm
- recipient={userOther}
+ recipient={otherPerson}
privateMessage={message_view}
onEdit={this.handlePrivateMessageEdit}
onCreate={this.handlePrivateMessageCreate}
</div>
{this.state.showReply && (
<PrivateMessageForm
- recipient={userOther}
+ recipient={otherPerson}
onCreate={this.handlePrivateMessageCreate}
/>
)}
handlePrivateMessageCreate(message: PrivateMessageView) {
if (
- UserService.Instance.user &&
- message.creator.id == UserService.Instance.user.id
+ UserService.Instance.localUserView &&
+ message.creator.id == UserService.Instance.localUserView.person.id
) {
this.state.showReply = false;
this.setState(this.state);
PostView,
CommentView,
CommunityView,
- UserViewSafe,
+ PersonViewSafe,
SortType,
Search as SearchForm,
SearchResponse,
import { PostListing } from "./post-listing";
import { HtmlTags } from "./html-tags";
import { Spinner } from "./icon";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { CommunityLink } from "./community-link";
import { SortSelect } from "./sort-select";
import { CommentNodes } from "./comment-nodes";
all() {
let combined: {
type_: string;
- data: CommentView | PostView | CommunityView | UserViewSafe;
+ data: CommentView | PostView | CommunityView | PersonViewSafe;
published: string;
}[] = [];
let comments = this.state.searchResponse.comments.map(e => {
};
});
let users = this.state.searchResponse.users.map(e => {
- return { type_: "users", data: e, published: e.user.published };
+ return { type_: "users", data: e, published: e.person.published };
});
combined.push(...comments);
(a, b) =>
((b.data as CommentView | PostView).counts.score |
(b.data as CommunityView).counts.subscribers |
- (b.data as UserViewSafe).counts.comment_score) -
+ (b.data as PersonViewSafe).counts.comment_score) -
((a.data as CommentView | PostView).counts.score |
(a.data as CommunityView).counts.subscribers |
- (a.data as UserViewSafe).counts.comment_score)
+ (a.data as PersonViewSafe).counts.comment_score)
);
}
<div>{this.communityListing(i.data as CommunityView)}</div>
)}
{i.type_ == "users" && (
- <div>{this.userListing(i.data as UserViewSafe)}</div>
+ <div>{this.userListing(i.data as PersonViewSafe)}</div>
)}
</div>
</div>
);
}
- userListing(user_view: UserViewSafe) {
+ userListing(person_view: PersonViewSafe) {
return [
<span>
- <UserListing user={user_view.user} showApubName />
+ <PersonListing person={person_view.person} showApubName />
</span>,
<span>{` - ${i18n.t("number_of_comments", {
- count: user_view.counts.comment_count,
+ count: person_view.counts.comment_count,
})}`}</span>,
];
}
FollowCommunity,
DeleteCommunity,
RemoveCommunity,
- UserViewSafe,
+ PersonViewSafe,
AddModToCommunity,
} from "lemmy-js-client";
import { WebSocketService, UserService } from "../services";
import { mdToHtml, getUnixTime, wsClient, authField } from "../utils";
import { CommunityForm } from "./community-form";
-import { UserListing } from "./user-listing";
+import { PersonListing } from "./person-listing";
import { CommunityLink } from "./community-link";
import { BannerIconHeader } from "./banner-icon-header";
import { Icon } from "./icon";
interface SidebarProps {
community_view: CommunityView;
moderators: CommunityModeratorView[];
- admins: UserViewSafe[];
+ admins: PersonViewSafe[];
online: number;
enableNsfw: boolean;
showIcon?: boolean;
<li class="list-inline-item">{i18n.t("mods")}: </li>
{this.props.moderators.map(mod => (
<li class="list-inline-item">
- <UserListing user={mod.moderator} />
+ <PersonListing person={mod.moderator} />
</li>
))}
</ul>
handleLeaveModTeamClick(i: Sidebar) {
let form: AddModToCommunity = {
- user_id: UserService.Instance.user.id,
+ person_id: UserService.Instance.localUserView.person.id,
community_id: i.props.community_view.community.id,
added: false,
auth: authField(),
}
private get amCreator(): boolean {
- return this.props.community_view.creator.id == UserService.Instance.user.id;
+ return (
+ this.props.community_view.creator.id ==
+ UserService.Instance.localUserView.person.id
+ );
}
get canMod(): boolean {
return (
- UserService.Instance.user &&
+ UserService.Instance.localUserView &&
this.props.moderators
.map(m => m.moderator.id)
- .includes(UserService.Instance.user.id)
+ .includes(UserService.Instance.localUserView.person.id)
);
}
get canAdmin(): boolean {
return (
- UserService.Instance.user &&
+ UserService.Instance.localUserView &&
this.props.admins
- .map(a => a.user.id)
- .includes(UserService.Instance.user.id)
+ .map(a => a.person.id)
+ .includes(UserService.Instance.localUserView.person.id)
);
}
-import { UserSafeSettings } from "lemmy-js-client";
+import { LocalUserSettingsView } from "lemmy-js-client";
import { Helmet } from "inferno-helmet";
import { Component } from "inferno";
interface Props {
- user: UserSafeSettings | undefined;
+ localUserView: LocalUserSettingsView | undefined;
}
export class Theme extends Component<Props> {
render() {
- const { user } = this.props;
- const hasUserTheme = user && user.theme !== "browser";
+ let user = this.props.localUserView;
+ let hasTheme = user && user.local_user.theme !== "browser";
return (
<Helmet>
- {hasUserTheme ? (
+ {hasTheme ? (
<link
rel="stylesheet"
type="text/css"
- href={`/static/assets/css/themes/${user.theme}.min.css`}
+ href={`/static/assets/css/themes/${user.local_user.theme}.min.css`}
/>
) : (
[
import { getLanguage } from "./utils";
export function initializeSite(site: GetSiteResponse) {
- UserService.Instance.user = site.my_user;
+ UserService.Instance.localUserView = site.my_user;
i18n.changeLanguage(getLanguage());
}
CommentView,
GetSiteResponse,
LemmyHttp,
- UserMentionView,
+ PersonMentionView,
} from "lemmy-js-client";
export interface IsoData {
}
export interface CommentNode {
- comment_view: CommentView | UserMentionView;
+ comment_view: CommentView | PersonMentionView;
children?: CommentNode[];
depth?: number;
}
Site,
}
-export enum UserDetailsView {
+export enum PersonDetailsView {
Overview,
Comments,
Posts,
import { Post } from "./components/post";
import { Community } from "./components/community";
import { Communities } from "./components/communities";
-import { User } from "./components/user";
+import { Person } from "./components/person";
import { Modlog } from "./components/modlog";
import { Setup } from "./components/setup";
import { AdminSettings } from "./components/admin-settings";
},
{
path: `/u/:username/view/:view/sort/:sort/page/:page`,
- component: User,
- fetchInitialData: req => User.fetchInitialData(req),
+ component: Person,
+ fetchInitialData: req => Person.fetchInitialData(req),
},
{
path: `/user/:id/view/:view/sort/:sort/page/:page`,
- component: User,
- fetchInitialData: req => User.fetchInitialData(req),
+ component: Person,
+ fetchInitialData: req => Person.fetchInitialData(req),
},
{
path: `/user/:id`,
- component: User,
- fetchInitialData: req => User.fetchInitialData(req),
+ component: Person,
+ fetchInitialData: req => Person.fetchInitialData(req),
},
{
path: `/u/:username`,
- component: User,
- fetchInitialData: req => User.fetchInitialData(req),
+ component: Person,
+ fetchInitialData: req => Person.fetchInitialData(req),
},
{
path: `/inbox`,
// import Cookies from 'js-cookie';
import IsomorphicCookie from "isomorphic-cookie";
-import { UserSafeSettings, LoginResponse } from "lemmy-js-client";
+import { LocalUserSettingsView, LoginResponse } from "lemmy-js-client";
import jwt_decode from "jwt-decode";
import { Subject, BehaviorSubject } from "rxjs";
interface Claims {
- id: number;
+ local_user_id: number;
iss: string;
}
export class UserService {
private static _instance: UserService;
- public user: UserSafeSettings;
+ public localUserView: LocalUserSettingsView;
public claims: Claims;
public jwtSub: Subject<string> = new Subject<string>();
public unreadCountSub: BehaviorSubject<number> = new BehaviorSubject<number>(
public logout() {
IsomorphicCookie.remove("jwt", { secure: false });
this.claims = undefined;
- this.user = undefined;
+ this.localUserView = undefined;
// setTheme();
this.jwtSub.next();
console.log("Logged out.");
import { wsUri } from "../env";
-import { UserViewSafe, WebSocketJsonResponse } from "lemmy-js-client";
+import { PersonViewSafe, WebSocketJsonResponse } from "lemmy-js-client";
import { isBrowser } from "../utils";
import { Observable } from "rxjs";
import { share } from "rxjs/operators";
};
public subject: Observable<any>;
- public admins: UserViewSafe[];
- public banned: UserViewSafe[];
+ public admins: PersonViewSafe[];
+ public banned: PersonViewSafe[];
private constructor() {
this.ws = new ReconnectingWebSocket(wsUri, [], this.wsOptions);
import {
UserOperation,
CommentView,
- UserSafeSettings,
+ LocalUserSettingsView,
SortType,
ListingType,
SearchType,
PostView,
PrivateMessageView,
LemmyWebsocket,
- UserViewSafe,
+ PersonViewSafe,
CommunityView,
} from "lemmy-js-client";
}
export function canMod(
- user: UserSafeSettings,
+ localUserView: LocalUserSettingsView,
modIds: number[],
creator_id: number,
onSelf = false
): boolean {
// You can do moderator actions only on the mods added after you.
- if (user) {
- let yourIndex = modIds.findIndex(id => id == user.id);
+ if (localUserView) {
+ let yourIndex = modIds.findIndex(id => id == localUserView.person.id);
if (yourIndex == -1) {
return false;
} else {
// TODO
export function getLanguage(override?: string): string {
- let user = UserService.Instance.user;
- let lang = override || (user && user.lang ? user.lang : "browser");
+ let localUserView = UserService.Instance.localUserView;
+ let lang =
+ override ||
+ (localUserView?.local_user.lang
+ ? localUserView.local_user.lang
+ : "browser");
if (lang == "browser" && isBrowser()) {
return getBrowserLanguage();
export function showAvatars(): boolean {
return (
- (UserService.Instance.user && UserService.Instance.user.show_avatars) ||
- !UserService.Instance.user
+ UserService.Instance.localUserView?.local_user.show_avatars ||
+ !UserService.Instance.localUserView
);
}
export function isCakeDay(published: string): boolean {
// moment(undefined) or moment.utc(undefined) returns the current date/time
// moment(null) or moment.utc(null) returns null
- const userCreationDate = moment.utc(published || null).local();
+ const createDate = moment.utc(published || null).local();
const currentDate = moment(new Date());
return (
- userCreationDate.date() === currentDate.date() &&
- userCreationDate.month() === currentDate.month() &&
- userCreationDate.year() !== currentDate.year()
+ createDate.date() === currentDate.date() &&
+ createDate.month() === currentDate.month() &&
+ createDate.year() !== currentDate.year()
);
}
// menuItemLimit: mentionDropdownFetchLimit,
menuShowMinLength: 2,
},
- // Users
+ // Persons
{
trigger: "@",
selectTemplate: (item: any) => {
- let it: UserTribute = item.original;
- return `[${it.key}](${it.view.user.actor_id})`;
+ let it: PersonTribute = item.original;
+ return `[${it.key}](${it.view.person.actor_id})`;
},
- values: (text: string, cb: (users: UserTribute[]) => any) => {
- userSearch(text, (users: UserTribute[]) => cb(users));
+ values: (text: string, cb: (persons: PersonTribute[]) => any) => {
+ personSearch(text, (persons: PersonTribute[]) => cb(persons));
},
allowSpaces: false,
autocompleteMode: true,
}
}
-interface UserTribute {
+interface PersonTribute {
key: string;
- view: UserViewSafe;
+ view: PersonViewSafe;
}
-function userSearch(text: string, cb: (users: UserTribute[]) => any) {
+function personSearch(text: string, cb: (persons: PersonTribute[]) => any) {
if (text) {
let form: Search = {
q: text,
WebSocketService.Instance.send(wsClient.search(form));
- let userSub = WebSocketService.Instance.subject.subscribe(
+ let personSub = WebSocketService.Instance.subject.subscribe(
msg => {
let res = wsJsonToRes(msg);
if (res.op == UserOperation.Search) {
let data = res.data as SearchResponse;
- let users: UserTribute[] = data.users.map(uv => {
- let tribute: UserTribute = {
- key: `@${uv.user.name}@${hostname(uv.user.actor_id)}`,
- view: uv,
+ let persons: PersonTribute[] = data.users.map(pv => {
+ let tribute: PersonTribute = {
+ key: `@${pv.person.name}@${hostname(pv.person.actor_id)}`,
+ view: pv,
};
return tribute;
});
- cb(users);
- userSub.unsubscribe();
+ cb(persons);
+ personSub.unsubscribe();
}
},
err => console.error(err),
export function getListingTypeFromProps(props: any): ListingType {
return props.match.params.listing_type
? routeListingTypeToEnum(props.match.params.listing_type)
- : UserService.Instance.user
- ? Object.values(ListingType)[UserService.Instance.user.default_listing_type]
+ : UserService.Instance.localUserView
+ ? Object.values(ListingType)[
+ UserService.Instance.localUserView.local_user.default_listing_type
+ ]
: ListingType.Local;
}
export function getSortTypeFromProps(props: any): SortType {
return props.match.params.sort
? routeSortTypeToEnum(props.match.params.sort)
- : UserService.Instance.user
- ? Object.values(SortType)[UserService.Instance.user.default_sort_type]
+ : UserService.Instance.localUserView
+ ? Object.values(SortType)[
+ UserService.Instance.localUserView.local_user.default_sort_type
+ ]
: SortType.Active;
}
dependencies:
invert-kv "^1.0.0"
-lemmy-js-client@0.10.0-rc.1:
- version "0.10.0-rc.1"
- resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.10.0-rc.1.tgz#4a9b9db8fcc8229d634920d7e66f63ab5db8b28e"
- integrity sha512-18TQO+EpE+mgCWSwynfFvDCASUjzTkr73/CbneMMHcqexq2R4donE+pNDFFSDHOeYIbdna0f4GZEJhyeh6826g==
+lemmy-js-client@0.10.0-rc.5:
+ version "0.10.0-rc.5"
+ resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.10.0-rc.5.tgz#96b7b34575c7eda6c99a291f4f679bda4c6af6a9"
+ integrity sha512-mLvQgzGTrOFe7KIO8o2oZBPp/8gJ309VO58EaP+7/BgbHD0GPemzqFdeNOMyIe2WyQsXhGrtHOjiTfBXyZDOoQ==
levn@^0.4.1:
version "0.4.1"