From 796ce0c031cadd76789c7b3aa1810f5747f733f3 Mon Sep 17 00:00:00 2001 From: Synox Date: Wed, 14 Sep 2016 17:32:41 +0200 Subject: [PATCH] refactor --- src/index.js | 6 +----- src/mailbox/mail/mail.js | 4 +++- src/mailbox/util.js | 17 +++++++++-------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/index.js b/src/index.js index 9946413..bfef2b1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,6 @@ import angular from "angular"; import "bootstrap/scss/bootstrap.scss"; import "babel-polyfill"; -import angularStickyfill from "angular-stickyfill"; -import "angular-stickyfill/dist/angular-stickyfill.css"; import {cleanUsername, generateRandomUsername} from "./mailbox/util"; import hasher from "hasher"; import Header from "./mailbox/header/header"; @@ -88,9 +86,7 @@ class AppController { } -angular.module('app', [ - List, Mail, angularStickyfill, Header -]) +angular.module('app', [List, Mail, Header]) .component('app', { template: ` diff --git a/src/mailbox/mail/mail.js b/src/mailbox/mail/mail.js index 8ec753e..a620ff3 100644 --- a/src/mailbox/mail/mail.js +++ b/src/mailbox/mail/mail.js @@ -1,6 +1,8 @@ import angular from "angular"; import ngSanitize from "angular-sanitize"; import Autolinker from "autolinker"; +import angularStickyfill from "angular-stickyfill"; +import "angular-stickyfill/dist/angular-stickyfill.css"; import template from "./mail.html"; import "./mail.scss"; @@ -12,7 +14,7 @@ class MailController { } -export default angular.module('mailbox.inbox.mail', [ngSanitize]) +export default angular.module('mailbox.inbox.mail', [ngSanitize, angularStickyfill]) .component('mail', { template, controller: MailController, diff --git a/src/mailbox/util.js b/src/mailbox/util.js index 253c4be..64fd58a 100644 --- a/src/mailbox/util.js +++ b/src/mailbox/util.js @@ -1,17 +1,18 @@ import phonetic from "phonetic"; -export function generateRandomUsername() { - let username = phonetic.generate({syllables: 3, phoneticSimplicity: 1}); - if (Math.random() >= 0.5) { - username += this.getRandomInt(30, 99); - } - return username.toLowerCase(); -} - function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } + +export function generateRandomUsername() { + let username = phonetic.generate({syllables: 3, phoneticSimplicity: 1}); + if (Math.random() >= 0.5) { + username += getRandomInt(30, 99); + } + return username.toLowerCase(); +} + export function cleanUsername(username) { return username.replace(/[@].*$/, ''); } \ No newline at end of file