FROM node:14-alpine as builder\r
-RUN apk update && apk add yarn curl bash && rm -rf /var/cache/apk/*\r
+RUN apk add yarn curl bash --no-cache\r
\r
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin\r
\r
\r
# Pruning\r
# RUN npm prune --production\r
-RUN /usr/local/bin/node-prune\r
+RUN node-prune\r
\r
FROM node:14-alpine as runner\r
COPY --from=builder /usr/src/app/dist /app/dist\r
import { initializeSite } from '../shared/initialize';
import { httpUri } from '../shared/env';
import { IncomingHttpHeaders } from 'http';
+import { setOptionalAuth } from '../shared/utils';
const server = express();
const port = 1234;
const context = {} as any;
let auth: string = IsomorphicCookie.load('jwt', req);
- let getSiteForm: GetSite = { auth };
+ let getSiteForm: GetSite = {};
+ setOptionalAuth(getSiteForm, auth);
let promises: Promise<any>[] = [];
GetSiteConfigResponse,
GetSiteConfig,
} from 'lemmy-js-client';
-import { UserService, WebSocketService } from '../services';
+import { WebSocketService } from '../services';
import {
wsJsonToRes,
capitalizeFirstLetter,
wsSubscribe,
isBrowser,
wsUserOp,
+ wsClient,
+ authField,
} from '../utils';
import autosize from 'autosize';
import { SiteForm } from './site-form';
siteRes: this.isoData.site_res,
siteConfigForm: {
config_hjson: null,
- auth: UserService.Instance.authField(),
+ auth: authField(),
},
siteConfigRes: {
config_hjson: null,
this.state.siteConfigLoading = false;
this.state.loading = false;
} else {
- WebSocketService.Instance.client.getSiteConfig({
- auth: UserService.Instance.authField(),
- });
+ WebSocketService.Instance.send(
+ wsClient.getSiteConfig({
+ auth: authField(),
+ })
+ );
}
}
handleSiteConfigSubmit(i: AdminSettings, event: any) {
event.preventDefault();
i.state.siteConfigLoading = true;
- WebSocketService.Instance.client.saveSiteConfig(i.state.siteConfigForm);
+ WebSocketService.Instance.send(
+ wsClient.saveSiteConfig(i.state.siteConfigForm)
+ );
i.setState(i.state);
}
<div>
<Theme user={siteRes.my_user} />
{siteRes &&
- siteRes.site_view.site &&
+ siteRes.site_view &&
this.props.siteRes.site_view.site.icon && (
<Helmet>
<link
} from 'lemmy-js-client';
import { CommentNode as CommentNodeI } from '../interfaces';
import {
+ authField,
capitalizeFirstLetter,
+ wsClient,
wsJsonToRes,
wsSubscribe,
wsUserOp,
interface CommentFormProps {
postId?: number;
- node?: CommentNodeI;
- onReplyCancel?(): any;
+ node?: CommentNodeI; // Can either be the parent, or the editable comment
edit?: boolean;
disabled?: boolean;
focus?: boolean;
+ onReplyCancel?(): any;
}
interface CommentFormState {
{UserService.Instance.user ? (
<MarkdownTextArea
initialContent={
- this.props.node
+ this.props.edit
? this.props.node.comment_view.comment.content
: null
}
content,
form_id: this.state.formId,
edit_id: node.comment_view.comment.id,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.editComment(form);
+ WebSocketService.Instance.send(wsClient.editComment(form));
} else {
let form: CreateComment = {
content,
form_id: this.state.formId,
post_id: node ? node.comment_view.post.id : this.props.postId,
- parent_id: node ? node.comment_view.comment.parent_id : null,
- auth: UserService.Instance.authField(),
+ parent_id: node ? node.comment_view.comment.id : null,
+ auth: authField(),
};
- WebSocketService.Instance.client.createComment(form);
+ WebSocketService.Instance.send(wsClient.createComment(form));
}
this.setState(this.state);
}
isMod,
setupTippy,
colorList,
+ wsClient,
+ authField,
} from '../utils';
import moment from 'moment';
import { MomentTime } from './moment-time';
let deleteForm: DeleteComment = {
edit_id: comment.id,
deleted: !comment.deleted,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.deleteComment(deleteForm);
+ WebSocketService.Instance.send(wsClient.deleteComment(deleteForm));
}
handleSaveCommentClick(i: CommentNode) {
let form: SaveComment = {
comment_id: cv.comment.id,
save,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.saveComment(form);
+ WebSocketService.Instance.send(wsClient.saveComment(form));
i.state.saveLoading = true;
i.setState(this.state);
let form: CreateCommentLike = {
comment_id: i.comment_view.comment.id,
score: this.state.my_vote,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.likeComment(form);
+ WebSocketService.Instance.send(wsClient.likeComment(form));
this.setState(this.state);
setupTippy();
}
let form: CreateCommentLike = {
comment_id: i.comment_view.comment.id,
score: this.state.my_vote,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.likeComment(form);
+ WebSocketService.Instance.send(wsClient.likeComment(form));
this.setState(this.state);
setupTippy();
}
edit_id: comment.id,
removed: !comment.removed,
reason: i.state.removeReason,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.removeComment(form);
+ WebSocketService.Instance.send(wsClient.removeComment(form));
i.state.showRemoveDialog = false;
i.setState(i.state);
let form: MarkUserMentionAsRead = {
user_mention_id: i.props.node.comment_view.user_mention.id,
read: !i.props.node.comment_view.user_mention.read,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.markUserMentionAsRead(form);
+ WebSocketService.Instance.send(wsClient.markUserMentionAsRead(form));
} else {
let form: MarkCommentAsRead = {
comment_id: i.props.node.comment_view.comment.id,
read: !i.props.node.comment_view.comment.read,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.markCommentAsRead(form);
+ WebSocketService.Instance.send(wsClient.markCommentAsRead(form));
}
i.state.readLoading = true;
remove_data: i.state.removeData,
reason: i.state.banReason,
expires: getUnixTime(i.state.banExpires),
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.banFromCommunity(form);
+ WebSocketService.Instance.send(wsClient.banFromCommunity(form));
} else {
// If its an unban, restore all their data
let ban = !cv.creator.banned;
remove_data: i.state.removeData,
reason: i.state.banReason,
expires: getUnixTime(i.state.banExpires),
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.banUser(form);
+ WebSocketService.Instance.send(wsClient.banUser(form));
}
i.state.showBanDialog = false;
user_id: cv.creator.id,
community_id: cv.community.id,
added: !i.isMod,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.addModToCommunity(form);
+ WebSocketService.Instance.send(wsClient.addModToCommunity(form));
i.state.showConfirmAppointAsMod = false;
i.setState(i.state);
}
let form: AddAdmin = {
user_id: i.props.node.comment_view.creator.id,
added: !i.isAdmin,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.addAdmin(form);
+ WebSocketService.Instance.send(wsClient.addAdmin(form));
i.state.showConfirmAppointAsAdmin = false;
i.setState(i.state);
}
let form: TransferCommunity = {
community_id: cv.community.id,
user_id: cv.creator.id,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.transferCommunity(form);
+ WebSocketService.Instance.send(wsClient.transferCommunity(form));
i.state.showConfirmTransferCommunity = false;
i.setState(i.state);
}
handleTransferSite(i: CommentNode) {
let form: TransferSite = {
user_id: i.props.node.comment_view.creator.id,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.transferSite(form);
+ WebSocketService.Instance.send(wsClient.transferSite(form));
i.state.showConfirmTransferSite = false;
i.setState(i.state);
}
SortType,
SiteView,
} from 'lemmy-js-client';
-import { UserService, WebSocketService } from '../services';
+import { WebSocketService } from '../services';
import {
wsJsonToRes,
toast,
setIsoData,
wsSubscribe,
wsUserOp,
+ wsClient,
+ authField,
+ setOptionalAuth,
} from '../utils';
import { CommunityLink } from './community-link';
import { i18n } from '../i18next';
let form: FollowCommunity = {
community_id: communityId,
follow: false,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.followCommunity(form);
+ WebSocketService.Instance.send(wsClient.followCommunity(form));
}
handleSubscribe(communityId: number) {
let form: FollowCommunity = {
community_id: communityId,
follow: true,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.followCommunity(form);
+ WebSocketService.Instance.send(wsClient.followCommunity(form));
}
refetch() {
sort: SortType.TopAll,
limit: communityLimit,
page: this.state.page,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.listCommunities(listCommunitiesForm);
+ WebSocketService.Instance.send(
+ wsClient.listCommunities(listCommunitiesForm)
+ );
}
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
sort: SortType.TopAll,
limit: communityLimit,
page,
- auth: req.auth,
};
+ setOptionalAuth(listCommunitiesForm, req.auth);
return [req.client.listCommunities(listCommunitiesForm)];
}
CommunityResponse,
CommunityView,
} from 'lemmy-js-client';
-import { UserService, WebSocketService } from '../services';
+import { WebSocketService } from '../services';
import {
wsJsonToRes,
capitalizeFirstLetter,
randomStr,
wsSubscribe,
wsUserOp,
+ wsClient,
+ authField,
} from '../utils';
import { i18n } from '../i18next';
nsfw: false,
icon: null,
banner: null,
- auth: UserService.Instance.authField(),
+ auth: authField(),
},
loading: false,
};
nsfw: cv.community.nsfw,
icon: cv.community.icon,
banner: cv.community.banner,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
}
...i.state.communityForm,
edit_id: i.props.community_view.community.id,
};
- WebSocketService.Instance.client.editCommunity(form);
+ WebSocketService.Instance.send(wsClient.editCommunity(form));
} else {
- WebSocketService.Instance.client.createCommunity(i.state.communityForm);
+ WebSocketService.Instance.send(
+ wsClient.createCommunity(i.state.communityForm)
+ );
}
i.setState(i.state);
}
isBrowser,
communityRSSUrl,
wsUserOp,
+ wsClient,
+ authField,
+ setOptionalAuth,
} from '../utils';
import { i18n } from '../i18next';
} else {
this.fetchCommunity();
this.fetchData();
- WebSocketService.Instance.client.listCategories();
+ WebSocketService.Instance.send(wsClient.listCategories());
}
setupTippy();
}
let form: GetCommunity = {
id: this.state.communityId ? this.state.communityId : null,
name: this.state.communityName ? this.state.communityName : null,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getCommunity(form);
+ WebSocketService.Instance.send(wsClient.getCommunity(form));
}
componentWillUnmount() {
}
let communityForm: GetCommunity = id ? { id } : { name: name_ };
- communityForm.auth = req.auth;
+ setOptionalAuth(communityForm, req.auth);
promises.push(req.client.getCommunity(communityForm));
let dataType: DataType = pathSplit[4]
limit: fetchLimit,
sort,
type_: ListingType.Community,
- auth: req.auth,
};
+ setOptionalAuth(getPostsForm, req.auth);
this.setIdOrName(getPostsForm, id, name_);
promises.push(req.client.getPosts(getPostsForm));
} else {
limit: fetchLimit,
sort,
type_: ListingType.Community,
- auth: req.auth,
};
+ setOptionalAuth(getCommentsForm, req.auth);
this.setIdOrName(getCommentsForm, id, name_);
promises.push(req.client.getComments(getCommentsForm));
}
}
render() {
- let cv = this.state.communityRes.community_view;
+ let cv = this.state.communityRes?.community_view;
return (
<div class="container">
{this.state.communityLoading ? (
type_: ListingType.Community,
community_id: this.state.communityId,
community_name: this.state.communityName,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getPosts(form);
+ WebSocketService.Instance.send(wsClient.getPosts(form));
} else {
let form: GetComments = {
page: this.state.page,
type_: ListingType.Community,
community_id: this.state.communityId,
community_name: this.state.communityName,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getComments(form);
+ WebSocketService.Instance.send(wsClient.getComments(form));
}
}
this.context.router.history.push('/');
return;
} else if (msg.reconnect) {
- WebSocketService.Instance.client.communityJoin({
- community_id: this.state.communityRes.community_view.community.id,
- });
+ WebSocketService.Instance.send(
+ wsClient.communityJoin({
+ community_id: this.state.communityRes.community_view.community.id,
+ })
+ );
this.fetchData();
} else if (op == UserOperation.GetCommunity) {
let data = wsJsonToRes<GetCommunityResponse>(msg).data;
this.state.communityLoading = false;
this.setState(this.state);
// TODO why is there no auth in this form?
- WebSocketService.Instance.client.communityJoin({
- community_id: data.community_view.community.id,
- });
+ WebSocketService.Instance.send(
+ wsClient.communityJoin({
+ community_id: data.community_view.community.id,
+ })
+ );
} else if (
op == UserOperation.EditCommunity ||
op == UserOperation.DeleteCommunity ||
wsSubscribe,
isBrowser,
wsUserOp,
+ wsClient,
} from '../utils';
import { WebSocketService, UserService } from '../services';
import { i18n } from '../i18next';
this.state.categories = this.isoData.routeData[0].categories;
this.state.loading = false;
} else {
- WebSocketService.Instance.client.listCategories();
+ WebSocketService.Instance.send(wsClient.listCategories());
}
}
import { PostForm } from './post-form';
import { HtmlTags } from './html-tags';
import {
+ authField,
isBrowser,
setIsoData,
+ setOptionalAuth,
toast,
+ wsClient,
wsJsonToRes,
wsSubscribe,
wsUserOp,
let listCommunitiesForm: ListCommunities = {
sort: SortType.TopAll,
limit: 9999,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.listCommunities(listCommunitiesForm);
+ WebSocketService.Instance.send(
+ wsClient.listCommunities(listCommunitiesForm)
+ );
}
componentWillUnmount() {
let listCommunitiesForm: ListCommunities = {
sort: SortType.TopAll,
limit: 9999,
- auth: req.auth,
};
+ setOptionalAuth(listCommunitiesForm, req.auth);
return [req.client.listCommunities(listCommunitiesForm)];
}
GetUserDetails,
} from 'lemmy-js-client';
import {
+ authField,
getRecipientIdFromProps,
isBrowser,
setIsoData,
toast,
+ wsClient,
wsJsonToRes,
wsSubscribe,
wsUserOp,
user_id: this.state.recipient_id,
sort: SortType.New,
saved_only: false,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getUserDetails(form);
+ WebSocketService.Instance.send(wsClient.getUserDetails(form));
}
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
wsSubscribe,
isBrowser,
wsUserOp,
+ wsClient,
+ authField,
} from '../utils';
import { CommentNodes } from './comment-nodes';
import { PrivateMessage } from './private-message';
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
page: this.state.page,
limit: fetchLimit,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.getReplies(repliesForm);
+ WebSocketService.Instance.send(wsClient.getReplies(repliesForm));
let userMentionsForm: GetUserMentions = {
sort: this.state.sort,
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
page: this.state.page,
limit: fetchLimit,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.getUserMentions(userMentionsForm);
+ WebSocketService.Instance.send(wsClient.getUserMentions(userMentionsForm));
let privateMessagesForm: GetPrivateMessages = {
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
page: this.state.page,
limit: fetchLimit,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.getPrivateMessages(privateMessagesForm);
+ WebSocketService.Instance.send(
+ wsClient.getPrivateMessages(privateMessagesForm)
+ );
}
handleSortChange(val: SortType) {
}
markAllAsRead(i: Inbox) {
- WebSocketService.Instance.client.markAllAsRead({
- auth: UserService.Instance.authField(),
- });
+ WebSocketService.Instance.send(
+ wsClient.markAllAsRead({
+ auth: authField(),
+ })
+ );
i.state.replies = [];
i.state.mentions = [];
i.state.messages = [];
isBrowser,
setIsoData,
wsUserOp,
+ wsClient,
+ authField,
} from '../utils';
import { i18n } from '../i18next';
import { HtmlTags } from './html-tags';
this.subscription = wsSubscribe(this.parseMessage);
if (isBrowser()) {
- WebSocketService.Instance.client.getCaptcha();
+ WebSocketService.Instance.send(wsClient.getCaptcha());
}
}
event.preventDefault();
i.state.loginLoading = true;
i.setState(i.state);
- WebSocketService.Instance.client.login(i.state.loginForm);
+ WebSocketService.Instance.send(wsClient.login(i.state.loginForm));
}
handleLoginUsernameChange(i: Login, event: any) {
event.preventDefault();
i.state.registerLoading = true;
i.setState(i.state);
- WebSocketService.Instance.client.register(i.state.registerForm);
+ WebSocketService.Instance.send(wsClient.register(i.state.registerForm));
}
handleRegisterUsernameChange(i: Login, event: any) {
handleRegenCaptcha(_i: Login, event: any) {
event.preventDefault();
- WebSocketService.Instance.client.getCaptcha();
+ WebSocketService.Instance.send(wsClient.getCaptcha());
}
handlePasswordReset(i: Login, event: any) {
let resetForm: PasswordReset = {
email: i.state.loginForm.username_or_email,
};
- WebSocketService.Instance.client.passwordReset(resetForm);
+ WebSocketService.Instance.send(wsClient.passwordReset(resetForm));
}
handleCaptchaPlay(i: Login, event: any) {
this.state = this.emptyState;
this.state.registerForm.captcha_answer = undefined;
// Refetch another captcha
- WebSocketService.Instance.client.getCaptcha();
+ WebSocketService.Instance.send(wsClient.getCaptcha());
this.setState(this.state);
return;
} else {
this.state = this.emptyState;
this.setState(this.state);
UserService.Instance.login(data);
- WebSocketService.Instance.client.userJoin({
- auth: UserService.Instance.authField(),
- });
+ WebSocketService.Instance.send(
+ wsClient.userJoin({
+ auth: authField(),
+ })
+ );
toast(i18n.t('logged_in'));
this.props.history.push('/');
} else if (op == UserOperation.Register) {
this.state = this.emptyState;
this.setState(this.state);
UserService.Instance.login(data);
- WebSocketService.Instance.client.userJoin({
- auth: UserService.Instance.authField(),
- });
+ WebSocketService.Instance.send(
+ wsClient.userJoin({
+ auth: authField(),
+ })
+ );
this.props.history.push('/communities');
} else if (op == UserOperation.GetCaptcha) {
let data = wsJsonToRes<GetCaptchaResponse>(msg).data;
wsSubscribe,
isBrowser,
wsUserOp,
+ setOptionalAuth,
+ wsClient,
+ authField,
} from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
this.fetchTrendingCommunities();
this.fetchData();
if (UserService.Instance.user) {
- WebSocketService.Instance.client.getFollowedCommunities({
- auth: UserService.Instance.authField(),
- });
+ WebSocketService.Instance.send(
+ wsClient.getFollowedCommunities({
+ auth: authField(),
+ })
+ );
}
}
let listCommunitiesForm: ListCommunities = {
sort: SortType.Hot,
limit: 6,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.listCommunities(listCommunitiesForm);
+ WebSocketService.Instance.send(
+ wsClient.listCommunities(listCommunitiesForm)
+ );
}
componentDidMount() {
this.context.router.history.push('/setup');
}
- WebSocketService.Instance.client.communityJoin({ community_id: 0 });
+ WebSocketService.Instance.send(wsClient.communityJoin({ community_id: 0 }));
}
componentWillUnmount() {
limit: fetchLimit,
sort,
type_,
- auth: req.auth,
};
+ setOptionalAuth(getPostsForm, req.auth);
promises.push(req.client.getPosts(getPostsForm));
} else {
let getCommentsForm: GetComments = {
limit: fetchLimit,
sort,
type_,
- auth: req.auth,
};
+ setOptionalAuth(getCommentsForm, req.auth);
promises.push(req.client.getComments(getCommentsForm));
}
limit: fetchLimit,
sort: this.state.sort,
type_: this.state.listingType,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getPosts(getPostsForm);
+ WebSocketService.Instance.send(wsClient.getPosts(getPostsForm));
} else {
let getCommentsForm: GetComments = {
page: this.state.page,
limit: fetchLimit,
sort: this.state.sort,
type_: this.state.listingType,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getComments(getCommentsForm);
+ WebSocketService.Instance.send(wsClient.getComments(getCommentsForm));
}
}
toast(i18n.t(msg.error), 'danger');
return;
} else if (msg.reconnect) {
- WebSocketService.Instance.client.communityJoin({ community_id: 0 });
+ WebSocketService.Instance.send(
+ wsClient.communityJoin({ community_id: 0 })
+ );
this.fetchData();
} else if (op == UserOperation.GetFollowedCommunities) {
let data = wsJsonToRes<GetFollowedCommunitiesResponse>(msg).data;
wsSubscribe,
isBrowser,
wsUserOp,
+ wsClient,
} from '../utils';
import { MomentTime } from './moment-time';
import { HtmlTags } from './html-tags';
page: this.state.page,
limit: fetchLimit,
};
- WebSocketService.Instance.client.getModlog(modlogForm);
+ WebSocketService.Instance.send(wsClient.getModlog(modlogForm));
}
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
wsSubscribe,
supportLemmyUrl,
wsUserOp,
+ wsClient,
+ authField,
} from '../utils';
import { i18n } from '../i18next';
import { PictrsImage } from './pictrs-image';
// i18n.changeLanguage('de');
} else {
this.requestNotificationPermission();
- WebSocketService.Instance.client.userJoin({
- auth: UserService.Instance.authField(),
- });
+ WebSocketService.Instance.send(
+ wsClient.userJoin({
+ auth: authField(),
+ })
+ );
this.fetchUnreads();
}
// A login
if (res !== undefined) {
this.requestNotificationPermission();
- WebSocketService.Instance.client.getSite();
+ WebSocketService.Instance.send(
+ wsClient.getSite({ auth: authField() })
+ );
} else {
this.setState({ isLoggedIn: false });
}
// TODO class active corresponding to current page
navbar() {
- let user = this.props.site_res.my_user;
+ let user = this.props.site_res.my_user || UserService.Instance.user;
return (
<nav class="navbar navbar-expand-lg navbar-light shadow-sm p-0 px-3">
<div class="container">
}
return;
} else if (msg.reconnect) {
- WebSocketService.Instance.client.userJoin({
- auth: UserService.Instance.authField(),
- });
+ WebSocketService.Instance.send(
+ wsClient.userJoin({
+ auth: authField(),
+ })
+ );
this.fetchUnreads();
} else if (op == UserOperation.GetReplies) {
let data = wsJsonToRes<GetRepliesResponse>(msg).data;
} else if (op == UserOperation.GetSite) {
// 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);
i18n.changeLanguage(getLanguage());
unread_only: true,
page: 1,
limit: fetchLimit,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
let userMentionsForm: GetUserMentions = {
unread_only: true,
page: 1,
limit: fetchLimit,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
let privateMessagesForm: GetPrivateMessages = {
unread_only: true,
page: 1,
limit: fetchLimit,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
if (this.currentLocation !== '/inbox') {
- WebSocketService.Instance.client.getReplies(repliesForm);
- WebSocketService.Instance.client.getUserMentions(userMentionsForm);
- WebSocketService.Instance.client.getPrivateMessages(privateMessagesForm);
+ WebSocketService.Instance.send(wsClient.getReplies(repliesForm));
+ WebSocketService.Instance.send(
+ wsClient.getUserMentions(userMentionsForm)
+ );
+ WebSocketService.Instance.send(
+ wsClient.getPrivateMessages(privateMessagesForm)
+ );
}
}
isBrowser,
wsSubscribe,
wsUserOp,
+ wsClient,
} from '../utils';
import { i18n } from '../i18next';
import { HtmlTags } from './html-tags';
i.state.loading = true;
i.setState(i.state);
- WebSocketService.Instance.client.passwordChange(i.state.passwordChangeForm);
+ WebSocketService.Instance.send(
+ wsClient.passwordChange(i.state.passwordChangeForm)
+ );
}
parseMessage(msg: any) {
wsSubscribe,
isBrowser,
wsUserOp,
+ wsClient,
+ authField,
} from '../utils';
var Choices;
community_id: null,
name: null,
nsfw: false,
- auth: UserService.Instance.authField(),
+ auth: authField(),
},
loading: false,
imageLoading: false,
community_id: this.props.post_view.community.id,
url: this.props.post_view.post.url,
nsfw: this.props.post_view.post.nsfw,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
}
...i.state.postForm,
edit_id: i.props.post_view.post.id,
};
- WebSocketService.Instance.client.editPost(form);
+ WebSocketService.Instance.send(wsClient.editPost(form));
} else {
- WebSocketService.Instance.client.createPost(i.state.postForm);
+ WebSocketService.Instance.send(wsClient.createPost(i.state.postForm));
}
i.state.loading = true;
i.setState(i.state);
sort: SortType.TopAll,
page: 1,
limit: 6,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.search(form);
+ WebSocketService.Instance.send(wsClient.search(form));
// Fetch the page title
getPageTitle(this.state.postForm.url).then(d => {
community_id: this.state.postForm.community_id,
page: 1,
limit: 6,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
if (this.state.postForm.name !== '') {
- WebSocketService.Instance.client.search(form);
+ WebSocketService.Instance.send(wsClient.search(form));
} else {
this.state.suggestedPosts = [];
}
setupTippy,
hostname,
previewLines,
+ wsClient,
+ authField,
} from '../utils';
import { i18n } from '../i18next';
import { externalHost } from '../env';
let form: CreatePostLike = {
post_id: i.props.post_view.post.id,
score: i.state.my_vote,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.likePost(form);
+ WebSocketService.Instance.send(wsClient.likePost(form));
i.setState(i.state);
setupTippy();
}
let form: CreatePostLike = {
post_id: i.props.post_view.post.id,
score: i.state.my_vote,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.likePost(form);
+ WebSocketService.Instance.send(wsClient.likePost(form));
i.setState(i.state);
setupTippy();
}
let deleteForm: DeletePost = {
edit_id: i.props.post_view.post.id,
deleted: !i.props.post_view.post.deleted,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.deletePost(deleteForm);
+ WebSocketService.Instance.send(wsClient.deletePost(deleteForm));
}
handleSavePostClick(i: PostListing) {
let form: SavePost = {
post_id: i.props.post_view.post.id,
save: saved,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.savePost(form);
+ WebSocketService.Instance.send(wsClient.savePost(form));
}
get crossPostParams(): string {
edit_id: i.props.post_view.post.id,
removed: !i.props.post_view.post.removed,
reason: i.state.removeReason,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.removePost(form);
+ WebSocketService.Instance.send(wsClient.removePost(form));
i.state.showRemoveDialog = false;
i.setState(i.state);
let form: LockPost = {
edit_id: i.props.post_view.post.id,
locked: !i.props.post_view.post.locked,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.lockPost(form);
+ WebSocketService.Instance.send(wsClient.lockPost(form));
}
handleModSticky(i: PostListing) {
let form: StickyPost = {
edit_id: i.props.post_view.post.id,
stickied: !i.props.post_view.post.stickied,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.stickyPost(form);
+ WebSocketService.Instance.send(wsClient.stickyPost(form));
}
handleModBanFromCommunityShow(i: PostListing) {
remove_data: i.state.removeData,
reason: i.state.banReason,
expires: getUnixTime(i.state.banExpires),
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.banFromCommunity(form);
+ WebSocketService.Instance.send(wsClient.banFromCommunity(form));
} else {
// If its an unban, restore all their data
let ban = !i.props.post_view.creator.banned;
remove_data: i.state.removeData,
reason: i.state.banReason,
expires: getUnixTime(i.state.banExpires),
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.banUser(form);
+ WebSocketService.Instance.send(wsClient.banUser(form));
}
i.state.showBanDialog = false;
user_id: i.props.post_view.creator.id,
community_id: i.props.post_view.community.id,
added: !i.isMod,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.addModToCommunity(form);
+ WebSocketService.Instance.send(wsClient.addModToCommunity(form));
i.setState(i.state);
}
let form: AddAdmin = {
user_id: i.props.post_view.creator.id,
added: !i.isAdmin,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.addAdmin(form);
+ WebSocketService.Instance.send(wsClient.addAdmin(form));
i.setState(i.state);
}
let form: TransferCommunity = {
community_id: i.props.post_view.community.id,
user_id: i.props.post_view.creator.id,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.transferCommunity(form);
+ WebSocketService.Instance.send(wsClient.transferCommunity(form));
i.state.showConfirmTransferCommunity = false;
i.setState(i.state);
}
handleTransferSite(i: PostListing) {
let form: TransferSite = {
user_id: i.props.post_view.creator.id,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.transferSite(form);
+ WebSocketService.Instance.send(wsClient.transferSite(form));
i.state.showConfirmTransferSite = false;
i.setState(i.state);
}
previewLines,
isImage,
wsUserOp,
+ wsClient,
+ authField,
+ setOptionalAuth,
} from '../utils';
import { PostListing } from './post-listing';
import { Sidebar } from './sidebar';
}
} else {
this.fetchPost();
- WebSocketService.Instance.client.listCategories();
+ WebSocketService.Instance.send(wsClient.listCategories());
}
}
fetchPost() {
let form: GetPost = {
id: this.state.postId,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getPost(form);
+ WebSocketService.Instance.send(wsClient.getPost(form));
}
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
let postForm: GetPost = {
id,
- auth: req.auth,
};
+ setOptionalAuth(postForm, req.auth);
promises.push(req.client.getPost(postForm));
promises.push(req.client.listCategories());
}
componentDidMount() {
- WebSocketService.Instance.client.postJoin({ post_id: this.state.postId });
+ WebSocketService.Instance.send(
+ wsClient.postJoin({ post_id: this.state.postId })
+ );
autosize(document.querySelectorAll('textarea'));
}
let form: MarkCommentAsRead = {
comment_id: found.creator.id,
read: true,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.markCommentAsRead(form);
+ WebSocketService.Instance.send(wsClient.markCommentAsRead(form));
UserService.Instance.unreadCountSub.next(
UserService.Instance.unreadCountSub.value - 1
);
}
render() {
- let pv = this.state.postRes.post_view;
+ let pv = this.state.postRes?.post_view;
return (
<div class="container">
{this.state.loading ? (
return;
} else if (msg.reconnect) {
let postId = Number(this.props.match.params.id);
- WebSocketService.Instance.client.postJoin({ post_id: postId });
- WebSocketService.Instance.client.getPost({
- id: postId,
- auth: UserService.Instance.authField(false),
- });
+ WebSocketService.Instance.send(wsClient.postJoin({ post_id: postId }));
+ WebSocketService.Instance.send(
+ wsClient.getPost({
+ id: postId,
+ auth: authField(false),
+ })
+ );
} else if (op == UserOperation.GetPost) {
let data = wsJsonToRes<GetPostResponse>(msg).data;
this.state.postRes = data;
sort: SortType.TopAll,
page: 1,
limit: 6,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.search(form);
+ WebSocketService.Instance.send(wsClient.search(form));
}
this.setState(this.state);
UserSafe,
UserOperation,
} from 'lemmy-js-client';
-import { UserService, WebSocketService } from '../services';
+import { WebSocketService } from '../services';
import {
capitalizeFirstLetter,
wsJsonToRes,
wsSubscribe,
isBrowser,
wsUserOp,
+ wsClient,
+ authField,
} from '../utils';
import { UserListing } from './user-listing';
import { MarkdownTextArea } from './markdown-textarea';
privateMessageForm: {
content: null,
recipient_id: this.props.recipient.id,
- auth: UserService.Instance.authField(),
+ auth: authField(),
},
loading: false,
previewMode: false,
let form: EditPrivateMessage = {
edit_id: i.props.privateMessage.private_message.id,
content: i.state.privateMessageForm.content,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.editPrivateMessage(form);
+ WebSocketService.Instance.send(wsClient.editPrivateMessage(form));
} else {
- WebSocketService.Instance.client.createPrivateMessage(
- i.state.privateMessageForm
+ WebSocketService.Instance.send(
+ wsClient.createPrivateMessage(i.state.privateMessageForm)
);
}
i.state.loading = true;
UserSafe,
} from 'lemmy-js-client';
import { WebSocketService, UserService } from '../services';
-import { mdToHtml, toast } from '../utils';
+import { authField, mdToHtml, toast, wsClient } from '../utils';
import { MomentTime } from './moment-time';
import { PrivateMessageForm } from './private-message-form';
import { UserListing } from './user-listing';
let form: DeletePrivateMessage = {
edit_id: i.props.private_message_view.private_message.id,
deleted: !i.props.private_message_view.private_message.deleted,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.deletePrivateMessage(form);
+ WebSocketService.Instance.send(wsClient.deletePrivateMessage(form));
}
handleReplyCancel() {
let form: MarkPrivateMessageAsRead = {
edit_id: i.props.private_message_view.private_message.id,
read: !i.props.private_message_view.private_message.read,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.markPrivateMessageAsRead(form);
+ WebSocketService.Instance.send(wsClient.markPrivateMessageAsRead(form));
}
handleMessageCollapse(i: PrivateMessage) {
CommentResponse,
Site,
} from 'lemmy-js-client';
-import { UserService, WebSocketService } from '../services';
+import { WebSocketService } from '../services';
import {
wsJsonToRes,
fetchLimit,
setIsoData,
wsSubscribe,
wsUserOp,
+ wsClient,
+ authField,
+ setOptionalAuth,
} from '../utils';
import { PostListing } from './post-listing';
import { HtmlTags } from './html-tags';
sort: this.getSortTypeFromProps(pathSplit[7]),
page: this.getPageFromProps(pathSplit[9]),
limit: fetchLimit,
- auth: req.auth,
};
+ setOptionalAuth(form, req.auth);
if (form.q != '') {
promises.push(req.client.search(form));
sort: this.state.sort,
page: this.state.page,
limit: fetchLimit,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
if (this.state.q != '') {
- WebSocketService.Instance.client.search(form);
+ WebSocketService.Instance.send(wsClient.search(form));
}
}
import { retryWhen, delay, take } from 'rxjs/operators';
import { Register, LoginResponse, UserOperation } from 'lemmy-js-client';
import { WebSocketService, UserService } from '../services';
-import { wsUserOp, wsJsonToRes, toast } from '../utils';
+import { wsUserOp, wsJsonToRes, toast, wsClient } from '../utils';
import { SiteForm } from './site-form';
import { i18n } from '../i18next';
i.state.userLoading = true;
i.setState(i.state);
event.preventDefault();
- WebSocketService.Instance.client.register(i.state.userForm);
+ WebSocketService.Instance.send(wsClient.register(i.state.userForm));
}
handleRegisterUsernameChange(i: Setup, event: any) {
Category,
} from 'lemmy-js-client';
import { WebSocketService, UserService } from '../services';
-import { mdToHtml, getUnixTime } from '../utils';
+import { mdToHtml, getUnixTime, wsClient, authField } from '../utils';
import { CommunityForm } from './community-form';
import { UserListing } from './user-listing';
import { CommunityLink } from './community-link';
let deleteForm: DeleteCommunity = {
edit_id: i.props.community_view.community.id,
deleted: !i.props.community_view.community.deleted,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.deleteCommunity(deleteForm);
+ WebSocketService.Instance.send(wsClient.deleteCommunity(deleteForm));
}
handleShowConfirmLeaveModTeamClick(i: Sidebar) {
user_id: UserService.Instance.user.id,
community_id: i.props.community_view.community.id,
added: false,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.addModToCommunity(form);
+ WebSocketService.Instance.send(wsClient.addModToCommunity(form));
i.state.showConfirmLeaveModTeam = false;
i.setState(i.state);
}
let form: FollowCommunity = {
community_id: communityId,
follow: false,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.followCommunity(form);
+ WebSocketService.Instance.send(wsClient.followCommunity(form));
}
handleSubscribe(communityId: number, event: any) {
let form: FollowCommunity = {
community_id: communityId,
follow: true,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.followCommunity(form);
+ WebSocketService.Instance.send(wsClient.followCommunity(form));
}
private get amCreator(): boolean {
removed: !i.props.community_view.community.removed,
reason: i.state.removeReason,
expires: getUnixTime(i.state.removeExpires),
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
- WebSocketService.Instance.client.removeCommunity(removeForm);
+ WebSocketService.Instance.send(wsClient.removeCommunity(removeForm));
i.state.showRemoveDialog = false;
i.setState(i.state);
import { MarkdownTextArea } from './markdown-textarea';
import { ImageUploadForm } from './image-upload-form';
import { Site, EditSite } from 'lemmy-js-client';
-import { UserService, WebSocketService } from '../services';
-import { capitalizeFirstLetter, randomStr } from '../utils';
+import { WebSocketService } from '../services';
+import {
+ authField,
+ capitalizeFirstLetter,
+ randomStr,
+ wsClient,
+} from '../utils';
import { i18n } from '../i18next';
interface SiteFormProps {
name: null,
icon: null,
banner: null,
- auth: UserService.Instance.authField(),
+ auth: authField(),
},
loading: false,
};
enable_nsfw: this.props.site.enable_nsfw,
icon: this.props.site.icon,
banner: this.props.site.banner,
- auth: UserService.Instance.authField(),
+ auth: authField(),
};
}
}
event.preventDefault();
i.state.loading = true;
if (i.props.site) {
- WebSocketService.Instance.client.editSite(i.state.siteForm);
+ WebSocketService.Instance.send(wsClient.editSite(i.state.siteForm));
} else {
- WebSocketService.Instance.client.createSite(i.state.siteForm);
+ WebSocketService.Instance.send(wsClient.createSite(i.state.siteForm));
}
i.setState(i.state);
}
previewLines,
editPostFindRes,
wsUserOp,
+ wsClient,
+ authField,
+ setOptionalAuth,
} from '../utils';
import { UserListing } from './user-listing';
import { HtmlTags } from './html-tags';
send_notifications_to_email: null,
bio: null,
preferred_username: null,
- auth: UserService.Instance.authField(),
+ auth: authField(),
},
userSettingsLoading: null,
deleteAccountLoading: null,
deleteAccountShowConfirm: false,
deleteAccountForm: {
password: null,
- auth: UserService.Instance.authField(),
+ auth: authField(),
},
siteRes: this.isoData.site_res,
};
saved_only: this.state.view === UserDetailsView.Saved,
page: this.state.page,
limit: fetchLimit,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.getUserDetails(form);
+ WebSocketService.Instance.send(wsClient.getUserDetails(form));
}
get isCurrentUser() {
saved_only: view === UserDetailsView.Saved,
page,
limit: fetchLimit,
- auth: req.auth,
};
+ setOptionalAuth(form, req.auth);
this.setIdOrName(form, user_id, username);
promises.push(req.client.getUserDetails(form));
return promises;
i.state.userSettingsLoading = true;
i.setState(i.state);
- WebSocketService.Instance.client.saveUserSettings(i.state.userSettingsForm);
+ WebSocketService.Instance.send(
+ wsClient.saveUserSettings(i.state.userSettingsForm)
+ );
}
handleDeleteAccountShowConfirmToggle(i: User, event: any) {
i.state.deleteAccountLoading = true;
i.setState(i.state);
- WebSocketService.Instance.client.deleteAccount(i.state.deleteAccountForm);
+ WebSocketService.Instance.send(
+ wsClient.deleteAccount(i.state.deleteAccountForm)
+ );
i.handleLogoutClick(i);
}
const host = isBrowser() ? externalHost : internalHost;
const httpBase = `http://${host}`; // Don't use secure here
-export const wsUri = `ws${secure}://${host}/api/v1/ws`;
-export const httpUri = `${httpBase}/api/v1`;
+export const wsUri = `ws${secure}://${host}/api/v2/ws`;
+export const httpUri = `${httpBase}/api/v2`;
export const pictrsUri = `http${secure}://${host}/pictrs/image`;
console.log(`httpbase: ${httpBase}`);
import { User_, LoginResponse } from 'lemmy-js-client';
import jwt_decode from 'jwt-decode';
import { Subject, BehaviorSubject } from 'rxjs';
-import { i18n } from '../i18next';
-import { toast } from '../utils';
interface Claims {
id: number;
return IsomorphicCookie.load('jwt');
}
- public authField(throwErr: boolean = true): string {
- if (this.auth == null && throwErr) {
- toast(i18n.t('not_logged_in'), 'danger');
- throw 'Not logged in';
- } else {
- return this.auth;
- }
- }
-
private setClaims(jwt: string) {
this.claims = jwt_decode(jwt);
this.jwtSub.next(jwt);
import { wsUri } from '../env';
-import {
- LemmyWebsocket,
- UserViewSafe,
- WebSocketJsonResponse,
-} from 'lemmy-js-client';
+import { UserViewSafe, WebSocketJsonResponse } from 'lemmy-js-client';
import { isBrowser } from '../utils';
import { Observable } from 'rxjs';
import { share } from 'rxjs/operators';
export class WebSocketService {
private static _instance: WebSocketService;
- public ws: ReconnectingWebSocket;
+ private ws: ReconnectingWebSocket;
public wsOptions: WSOptions = {
connectionTimeout: 5000,
maxRetries: 10,
public admins: UserViewSafe[];
public banned: UserViewSafe[];
- public client = new LemmyWebsocket();
private constructor() {
this.ws = new ReconnectingWebSocket(wsUri, [], this.wsOptions);
firstConnect = false;
};
}).pipe(share());
+
+ if (isBrowser()) {
+ window.onbeforeunload = () => {
+ this.ws.close();
+ };
+ }
+ }
+
+ public send(data: string) {
+ this.ws.send(data);
}
public static get Instance() {
return this._instance || (this._instance = new this());
}
}
-
-if (isBrowser()) {
- window.onbeforeunload = () => {
- WebSocketService.Instance.ws.close();
- };
-}
SearchResponse,
PostView,
PrivateMessageView,
+ LemmyWebsocket,
} from 'lemmy-js-client';
import {
import moment from 'moment';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
+import { i18n } from './i18next';
+
+export const wsClient = new LemmyWebsocket();
export const favIconUrl = '/static/assets/favicon.svg';
export const favIconPngUrl = '/static/assets/apple-touch-icon.png';
sort: SortType.TopAll,
page: 1,
limit: mentionDropdownFetchLimit,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.search(form);
+ WebSocketService.Instance.send(wsClient.search(form));
let userSub = WebSocketService.Instance.subject.subscribe(
msg => {
sort: SortType.TopAll,
page: 1,
limit: mentionDropdownFetchLimit,
- auth: UserService.Instance.authField(false),
+ auth: authField(false),
};
- WebSocketService.Instance.client.search(form);
+ WebSocketService.Instance.send(wsClient.search(form));
let communitySub = WebSocketService.Instance.subject.subscribe(
msg => {
}
}
+export function setOptionalAuth(obj: any, auth = UserService.Instance.auth) {
+ if (auth) {
+ obj.auth = auth;
+ }
+}
+
+export function authField(
+ throwErr: boolean = true,
+ auth = UserService.Instance.auth
+): string {
+ if (auth == null && throwErr) {
+ toast(i18n.t('not_logged_in'), 'danger');
+ throw 'Not logged in';
+ } else {
+ return auth;
+ }
+}
+
moment.updateLocale('en', {
relativeTime: {
future: 'in %s',