]> Untitled Git - lemmy.git/blobdiff - ui/src/utils.ts
Updating code url references to https://github.com/LemmyNet/lemmy
[lemmy.git] / ui / src / utils.ts
index cab1fd5b093bb89143c44ce8f3d7865f934682cf..ceb05764d27e389f3047a34f62987f21cdef11f6 100644 (file)
@@ -12,6 +12,7 @@ import 'moment/locale/ca';
 import 'moment/locale/fa';
 import 'moment/locale/pt-br';
 import 'moment/locale/ja';
+import 'moment/locale/ka';
 
 import {
   UserOperation,
@@ -43,7 +44,7 @@ import emojiShortName from 'emoji-short-name';
 import Toastify from 'toastify-js';
 import tippy from 'tippy.js';
 
-export const repoUrl = 'https://github.com/dessalines/lemmy';
+export const repoUrl = 'https://github.com/LemmyNet/lemmy';
 export const helpGuideUrl = '/docs/about_guide.html';
 export const markdownHelpUrl = `${helpGuideUrl}#markdown-guide`;
 export const sortingHelpUrl = `${helpGuideUrl}#sorting`;
@@ -59,6 +60,7 @@ export const languages = [
   { code: 'eo', name: 'Esperanto' },
   { code: 'es', name: 'Español' },
   { code: 'de', name: 'Deutsch' },
+  { code: 'ka', name: 'ქართული ენა' },
   { code: 'fa', name: 'فارسی' },
   { code: 'ja', name: '日本語' },
   { code: 'pt_BR', name: 'Português Brasileiro' },
@@ -353,6 +355,8 @@ export function getMomentLanguage(): string {
     lang = 'pt-br';
   } else if (lang.startsWith('ja')) {
     lang = 'ja';
+  } else if (lang.startsWith('ka')) {
+    lang = 'ka';
   } else {
     lang = 'en';
   }
@@ -444,7 +448,8 @@ export function messageToastify(
   router: any
 ) {
   let backgroundColor = `var(--light)`;
-  Toastify({
+
+  let toast = Toastify({
     text: `${body}<br />${creator}`,
     avatar: avatar,
     backgroundColor: backgroundColor,
@@ -453,7 +458,10 @@ export function messageToastify(
     position: 'right',
     duration: 0,
     onClick: () => {
-      router.history.push(link);
+      if (toast) {
+        toast.hideToast();
+        router.history.push(link);
+      }
     },
   }).showToast();
 }
@@ -815,3 +823,11 @@ function hsl(num: number) {
 function randomHsl() {
   return `hsla(${Math.random() * 360}, 100%, 50%, 1)`;
 }
+
+export function previewLines(text: string, lines: number = 3): string {
+  // Use lines * 2 because markdown requires 2 lines
+  return text
+    .split('\n')
+    .slice(0, lines * 2)
+    .join('\n');
+}