summaryrefslogtreecommitdiffstats
path: root/ui/src
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-22 22:29:11 -0500
committerDessalines <tyhou13@gmx.com>2020-01-22 22:29:11 -0500
commit3b4258096c3c3dc160090436c9205e1ecf2e8e75 (patch)
treef07264d3de3b169c6140b2bf303ff7732d908b0a /ui/src
parent66af9623d90aadd47c9cf37faeac4f60f1d818d4 (diff)
Adding a toaster to replace alerts. Fixes #457
Diffstat (limited to 'ui/src')
-rw-r--r--ui/src/components/comment-form.tsx3
-rw-r--r--ui/src/components/communities.tsx4
-rw-r--r--ui/src/components/community-form.tsx15
-rw-r--r--ui/src/components/community.tsx3
-rw-r--r--ui/src/components/create-private-message.tsx3
-rw-r--r--ui/src/components/inbox.tsx12
-rw-r--r--ui/src/components/login.tsx16
-rw-r--r--ui/src/components/main.tsx3
-rw-r--r--ui/src/components/modlog.tsx15
-rw-r--r--ui/src/components/moment-time.tsx2
-rw-r--r--ui/src/components/navbar.tsx3
-rw-r--r--ui/src/components/password_change.tsx13
-rw-r--r--ui/src/components/post-form.tsx5
-rw-r--r--ui/src/components/post.tsx4
-rw-r--r--ui/src/components/private-message-form.tsx3
-rw-r--r--ui/src/components/private-message.tsx9
-rw-r--r--ui/src/components/search.tsx3
-rw-r--r--ui/src/components/setup.tsx13
-rw-r--r--ui/src/components/user.tsx7
-rw-r--r--ui/src/index.html1
-rw-r--r--ui/src/services/WebSocketService.ts3
-rw-r--r--ui/src/translations/en.ts1
-rw-r--r--ui/src/utils.ts9
23 files changed, 69 insertions, 81 deletions
diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx
index f5816899..6fbdc5de 100644
--- a/ui/src/components/comment-form.tsx
+++ b/ui/src/components/comment-form.tsx
@@ -16,6 +16,7 @@ import {
mdToHtml,
randomStr,
markdownHelpUrl,
+ toast,
} from '../utils';
import { WebSocketService, UserService } from '../services';
import autosize from 'autosize';
@@ -293,7 +294,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
.catch(error => {
i.state.imageLoading = false;
i.setState(i.state);
- alert(error);
+ toast(error, 'danger');
});
}
diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx
index 598a5dad..129051fb 100644
--- a/ui/src/components/communities.tsx
+++ b/ui/src/components/communities.tsx
@@ -12,7 +12,7 @@ import {
SortType,
} from '../interfaces';
import { WebSocketService } from '../services';
-import { msgOp } from '../utils';
+import { msgOp, toast } from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -235,7 +235,7 @@ export class Communities extends Component<any, CommunitiesState> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
return;
} else if (op == UserOperation.ListCommunities) {
let res: ListCommunitiesResponse = msg;
diff --git a/ui/src/components/community-form.tsx b/ui/src/components/community-form.tsx
index 2085da28..ec58b010 100644
--- a/ui/src/components/community-form.tsx
+++ b/ui/src/components/community-form.tsx
@@ -10,8 +10,8 @@ import {
GetSiteResponse,
} from '../interfaces';
import { WebSocketService } from '../services';
-import { msgOp, capitalizeFirstLetter } from '../utils';
-import * as autosize from 'autosize';
+import { msgOp, capitalizeFirstLetter, toast } from '../utils';
+import autosize from 'autosize';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -67,14 +67,7 @@ export class CommunityForm extends Component<
}
this.subscription = WebSocketService.Instance.subject
- .pipe(
- retryWhen(errors =>
- errors.pipe(
- delay(3000),
- take(10)
- )
- )
- )
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
msg => this.parseMessage(msg),
err => console.error(err),
@@ -250,7 +243,7 @@ export class CommunityForm extends Component<
let op: UserOperation = msgOp(msg);
console.log(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state.loading = false;
this.setState(this.state);
return;
diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx
index 873b5a8a..dfd4d6b3 100644
--- a/ui/src/components/community.tsx
+++ b/ui/src/components/community.tsx
@@ -24,6 +24,7 @@ import {
routeSortTypeToEnum,
fetchLimit,
postRefetchSeconds,
+ toast,
} from '../utils';
import { T } from 'inferno-i18next';
import { i18n } from '../i18next';
@@ -257,7 +258,7 @@ export class Community extends Component<any, State> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.context.router.history.push('/');
return;
} else if (op == UserOperation.GetCommunity) {
diff --git a/ui/src/components/create-private-message.tsx b/ui/src/components/create-private-message.tsx
index f74d5e9f..7160bc52 100644
--- a/ui/src/components/create-private-message.tsx
+++ b/ui/src/components/create-private-message.tsx
@@ -2,6 +2,7 @@ import { Component } from 'inferno';
import { PrivateMessageForm } from './private-message-form';
import { WebSocketService } from '../services';
import { PrivateMessageFormParams } from '../interfaces';
+import { toast } from '../utils';
import { i18n } from '../i18next';
export class CreatePrivateMessage extends Component<any, any> {
@@ -44,7 +45,7 @@ export class CreatePrivateMessage extends Component<any, any> {
}
handlePrivateMessageCreate() {
- alert(i18n.t('message_sent'));
+ toast(i18n.t('message_sent'));
// Navigate to the front
this.props.history.push(`/`);
diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx
index 6a426bcc..bf090179 100644
--- a/ui/src/components/inbox.tsx
+++ b/ui/src/components/inbox.tsx
@@ -18,7 +18,7 @@ import {
PrivateMessageResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp, fetchLimit, isCommentType } from '../utils';
+import { msgOp, fetchLimit, isCommentType, toast } from '../utils';
import { CommentNodes } from './comment-nodes';
import { PrivateMessage } from './private-message';
import { SortSelect } from './sort-select';
@@ -198,11 +198,7 @@ export class Inbox extends Component<any, InboxState> {
<div>
{combined.map(i =>
isCommentType(i) ? (
- <CommentNodes
- nodes={[{ comment: i }]}
- noIndent
- markable
- />
+ <CommentNodes nodes={[{ comment: i }]} noIndent markable />
) : (
<PrivateMessage privateMessage={i} />
)
@@ -328,7 +324,7 @@ export class Inbox extends Component<any, InboxState> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
return;
} else if (op == UserOperation.GetReplies) {
let res: GetRepliesResponse = msg;
@@ -423,7 +419,7 @@ export class Inbox extends Component<any, InboxState> {
this.setState(this.state);
} else if (op == UserOperation.CreateComment) {
// let res: CommentResponse = msg;
- alert(i18n.t('reply_sent'));
+ toast(i18n.t('reply_sent'));
// this.state.replies.unshift(res.comment); // TODO do this right
// this.setState(this.state);
} else if (op == UserOperation.SaveComment) {
diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx
index 53b7a22f..0c8350aa 100644
--- a/ui/src/components/login.tsx
+++ b/ui/src/components/login.tsx
@@ -10,7 +10,7 @@ import {
GetSiteResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp, validEmail } from '../utils';
+import { msgOp, validEmail, toast } from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -48,14 +48,7 @@ export class Login extends Component<any, State> {
this.state = this.emptyState;
this.subscription = WebSocketService.Instance.subject
- .pipe(
- retryWhen(errors =>
- errors.pipe(
- delay(3000),
- take(10)
- )
- )
- )
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
msg => this.parseMessage(msg),
err => console.error(err),
@@ -302,7 +295,7 @@ export class Login extends Component<any, State> {
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state = this.emptyState;
this.setState(this.state);
return;
@@ -312,6 +305,7 @@ export class Login extends Component<any, State> {
this.setState(this.state);
let res: LoginResponse = msg;
UserService.Instance.login(res);
+ toast(i18n.t('logged_in'));
this.props.history.push('/');
} else if (op == UserOperation.Register) {
this.state = this.emptyState;
@@ -320,7 +314,7 @@ export class Login extends Component<any, State> {
UserService.Instance.login(res);
this.props.history.push('/communities');
} else if (op == UserOperation.PasswordReset) {
- alert(i18n.t('reset_password_mail_sent'));
+ toast(i18n.t('reset_password_mail_sent'));
} else if (op == UserOperation.GetSite) {
let res: GetSiteResponse = msg;
this.state.enable_nsfw = res.site.enable_nsfw;
diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx
index 5fdf23bb..b244ce66 100644
--- a/ui/src/components/main.tsx
+++ b/ui/src/components/main.tsx
@@ -33,6 +33,7 @@ import {
postRefetchSeconds,
pictshareAvatarThumbnail,
showAvatars,
+ toast,
} from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -566,7 +567,7 @@ export class Main extends Component<any, MainState> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
return;
} else if (op == UserOperation.GetFollowedCommunities) {
let res: GetFollowedCommunitiesResponse = msg;
diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx
index 425710dd..6c35bce9 100644
--- a/ui/src/components/modlog.tsx
+++ b/ui/src/components/modlog.tsx
@@ -17,9 +17,9 @@ import {
ModAdd,
} from '../interfaces';
import { WebSocketService } from '../services';
-import { msgOp, addTypeInfo, fetchLimit } from '../utils';
+import { msgOp, addTypeInfo, fetchLimit, toast } from '../utils';
import { MomentTime } from './moment-time';
-import * as moment from 'moment';
+import moment from 'moment';
import { i18n } from '../i18next';
interface ModlogState {
@@ -55,14 +55,7 @@ export class Modlog extends Component<any, ModlogState> {
? Number(this.props.match.params.community_id)
: undefined;
this.subscription = WebSocketService.Instance.subject
- .pipe(
- retryWhen(errors =>
- errors.pipe(
- delay(3000),
- take(10)
- )
- )
- )
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
msg => this.parseMessage(msg),
err => console.error(err),
@@ -433,7 +426,7 @@ export class Modlog extends Component<any, ModlogState> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
return;
} else if (op == UserOperation.GetModlog) {
let res: GetModlogResponse = msg;
diff --git a/ui/src/components/moment-time.tsx b/ui/src/components/moment-time.tsx
index 6bb4d99c..fd2a7efa 100644
--- a/ui/src/components/moment-time.tsx
+++ b/ui/src/components/moment-time.tsx
@@ -1,5 +1,5 @@
import { Component } from 'inferno';
-import * as moment from 'moment';
+import moment from 'moment';
import { getMomentLanguage } from '../utils';
import { i18n } from '../i18next';
diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx
index 85a54987..81124f77 100644
--- a/ui/src/components/navbar.tsx
+++ b/ui/src/components/navbar.tsx
@@ -22,6 +22,7 @@ import {
showAvatars,
fetchLimit,
isCommentType,
+ toast,
} from '../utils';
import { version } from '../version';
import { i18n } from '../i18next';
@@ -318,7 +319,7 @@ export class Navbar extends Component<any, NavbarState> {
if (UserService.Instance.user) {
document.addEventListener('DOMContentLoaded', function() {
if (!Notification) {
- alert(i18n.t('notifications_error'));
+ toast(i18n.t('notifications_error'), 'danger');
return;
}
diff --git a/ui/src/components/password_change.tsx b/ui/src/components/password_change.tsx
index 3e542f7b..76b4fb01 100644
--- a/ui/src/components/password_change.tsx
+++ b/ui/src/components/password_change.tsx
@@ -7,7 +7,7 @@ import {
PasswordChangeForm,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp, capitalizeFirstLetter } from '../utils';
+import { msgOp, capitalizeFirstLetter, toast } from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -34,14 +34,7 @@ export class PasswordChange extends Component<any, State> {
this.state = this.emptyState;
this.subscription = WebSocketService.Instance.subject
- .pipe(
- retryWhen(errors =>
- errors.pipe(
- delay(3000),
- take(10)
- )
- )
- )
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
msg => this.parseMessage(msg),
err => console.error(err),
@@ -143,7 +136,7 @@ export class PasswordChange extends Component<any, State> {
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state.loading = false;
this.setState(this.state);
return;
diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx
index fe633a01..97a44094 100644
--- a/ui/src/components/post-form.tsx
+++ b/ui/src/components/post-form.tsx
@@ -28,6 +28,7 @@ import {
mdToHtml,
debounce,
isImage,
+ toast,
} from '../utils';
import autosize from 'autosize';
import { i18n } from '../i18next';
@@ -453,14 +454,14 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
.catch(error => {
i.state.imageLoading = false;
i.setState(i.state);
- alert(error);
+ toast(error, 'danger');
});
}
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state.loading = false;
this.setState(this.state);
return;
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index 2005cc17..308fce85 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -28,7 +28,7 @@ import {
GetCommunityResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp, hotRank } from '../utils';
+import { msgOp, hotRank, toast } from '../utils';
import { PostListing } from './post-listing';
import { PostListings } from './post-listings';
import { Sidebar } from './sidebar';
@@ -345,7 +345,7 @@ export class Post extends Component<any, PostState> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
return;
} else if (op == UserOperation.GetPost) {
let res: GetPostResponse = msg;
diff --git a/ui/src/components/private-message-form.tsx b/ui/src/components/private-message-form.tsx
index c628bf71..96bd807d 100644
--- a/ui/src/components/private-message-form.tsx
+++ b/ui/src/components/private-message-form.tsx
@@ -22,6 +22,7 @@ import {
mdToHtml,
showAvatars,
pictshareAvatarThumbnail,
+ toast,
} from '../utils';
import autosize from 'autosize';
import { i18n } from '../i18next';
@@ -268,7 +269,7 @@ export class PrivateMessageForm extends Component<
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state.loading = false;
this.setState(this.state);
return;
diff --git a/ui/src/components/private-message.tsx b/ui/src/components/private-message.tsx
index 524b1a9d..409dce4d 100644
--- a/ui/src/components/private-message.tsx
+++ b/ui/src/components/private-message.tsx
@@ -5,7 +5,12 @@ import {
EditPrivateMessageForm,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { mdToHtml, pictshareAvatarThumbnail, showAvatars } from '../utils';
+import {
+ mdToHtml,
+ pictshareAvatarThumbnail,
+ showAvatars,
+ toast,
+} from '../utils';
import { MomentTime } from './moment-time';
import { PrivateMessageForm } from './private-message-form';
import { i18n } from '../i18next';
@@ -244,6 +249,6 @@ export class PrivateMessage extends Component<
handlePrivateMessageCreate() {
this.state.showReply = false;
this.setState(this.state);
- alert(i18n.t('message_sent'));
+ toast(i18n.t('message_sent'), 'danger');
}
}
diff --git a/ui/src/components/search.tsx b/ui/src/components/search.tsx
index 94bbbdb9..d2280cb2 100644
--- a/ui/src/components/search.tsx
+++ b/ui/src/components/search.tsx
@@ -23,6 +23,7 @@ import {
routeSortTypeToEnum,
pictshareAvatarThumbnail,
showAvatars,
+ toast,
} from '../utils';
import { PostListing } from './post-listing';
import { SortSelect } from './sort-select';
@@ -480,7 +481,7 @@ export class Search extends Component<any, SearchState> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
return;
} else if (op == UserOperation.Search) {
let res: SearchResponse = msg;
diff --git a/ui/src/components/setup.tsx b/ui/src/components/setup.tsx
index d421e46f..d06a9a58 100644
--- a/ui/src/components/setup.tsx
+++ b/ui/src/components/setup.tsx
@@ -3,7 +3,7 @@ import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import { RegisterForm, LoginResponse, UserOperation } from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp } from '../utils';
+import { msgOp, toast } from '../utils';
import { SiteForm } from './site-form';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -35,14 +35,7 @@ export class Setup extends Component<any, State> {
this.state = this.emptyState;
this.subscription = WebSocketService.Instance.subject
- .pipe(
- retryWhen(errors =>
- errors.pipe(
- delay(3000),
- take(10)
- )
- )
- )
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
msg => this.parseMessage(msg),
err => console.error(err),
@@ -191,7 +184,7 @@ export class Setup extends Component<any, State> {
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state.userLoading = false;
this.setState(this.state);
return;
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index 19bd5fb9..89bc4785 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -30,6 +30,7 @@ import {
setTheme,
languages,
showAvatars,
+ toast,
} from '../utils';
import { PostListing } from './post-listing';
import { SortSelect } from './sort-select';
@@ -975,7 +976,7 @@ export class User extends Component<any, UserState> {
.catch(error => {
i.state.avatarLoading = false;
i.setState(i.state);
- alert(error);
+ toast(error, 'danger');
});
}
@@ -1015,7 +1016,7 @@ export class User extends Component<any, UserState> {
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state.deleteAccountLoading = false;
this.state.avatarLoading = false;
this.state.userSettingsLoading = false;
@@ -1069,7 +1070,7 @@ export class User extends Component<any, UserState> {
this.setState(this.state);
} else if (op == UserOperation.CreateComment) {
// let res: CommentResponse = msg;
- alert(i18n.t('reply_sent'));
+ toast(i18n.t('reply_sent'));
// this.state.comments.unshift(res.comment); // TODO do this right
// this.setState(this.state);
} else if (op == UserOperation.SaveComment) {
diff --git a/ui/src/index.html b/ui/src/index.html
index 933cdc68..122783d4 100644
--- a/ui/src/index.html
+++ b/ui/src/index.html
@@ -13,6 +13,7 @@
<!-- Styles -->
<link rel="stylesheet" type="text/css" href="/static/assets/css/tribute.css" />
+ <link rel="stylesheet" type="text/css" href="/static/assets/css/toastify.css" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/themes/darkly.min.css" id="darkly" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/main.css" />
diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts
index 146a9abf..e72a2871 100644
--- a/ui/src/services/WebSocketService.ts
+++ b/ui/src/services/WebSocketService.ts
@@ -41,6 +41,7 @@ import { Subject } from 'rxjs';
import { retryWhen, delay } from 'rxjs/operators';
import { UserService } from './';
import { i18n } from '../i18next';
+import { toast } from '../utils';
export class WebSocketService {
private static _instance: WebSocketService;
@@ -318,7 +319,7 @@ export class WebSocketService {
private setAuth(obj: any, throwErr: boolean = true) {
obj.auth = UserService.Instance.auth;
if (obj.auth == null && throwErr) {
- alert(i18n.t('not_logged_in'));
+ toast(i18n.t('not_logged_in'), 'danger');
throw 'Not logged in';
}
}
diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts
index ecd293b5..c932014f 100644
--- a/ui/src/translations/en.ts
+++ b/ui/src/translations/en.ts
@@ -191,6 +191,7 @@ export const en = {
landing_0:
"Lemmy is a <1>link aggregator</1> / reddit alternative, intended to work in the <2>fediverse</2>.<3></3>It's self-hostable, has live-updating comment threads, and is tiny (<4>~80kB</4>). Federation into the ActivityPub network is on the roadmap. <5></5>This is a <6>very early beta version</6>, and a lot of features are currently broken or missing. <7></7>Suggest new features or report bugs <8>here.</8><9></9>Made with <10>Rust</10>, <11>Actix</11>, <12>Inferno</12>, <13>Typescript</13>.",
not_logged_in: 'Not logged in.',
+ logged_in: 'Logged in.',
community_ban: 'You have been banned from this community.',
site_ban: 'You have been banned from the site',
couldnt_create_comment: "Couldn't create comment.",
diff --git a/ui/src/utils.ts b/ui/src/utils.ts
index dce746e2..a3aab09d 100644
--- a/ui/src/utils.ts
+++ b/ui/src/utils.ts
@@ -23,6 +23,7 @@ import markdownitEmoji from 'markdown-it-emoji/light';
import markdown_it_container from 'markdown-it-container';
import * as twemoji from 'twemoji';
import * as emojiShortName from 'emoji-short-name';
+import Toastify from 'toastify-js';
export const repoUrl = 'https://github.com/dessalines/lemmy';
export const markdownHelpUrl = 'https://commonmark.org/help/';
@@ -366,3 +367,11 @@ export function imageThumbnailer(url: string): string {
export function isCommentType(item: Comment | PrivateMessage): item is Comment {
return (item as Comment).community_id !== undefined;
}
+
+export function toast(text: string, background: string = 'success') {
+ let backgroundColor = `var(--${background})`;
+ Toastify({
+ text: text,
+ backgroundColor: backgroundColor,
+ }).showToast();
+}