From 66fbb7c44d4b3d4631de56987cfccca3631e86a8 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sat, 15 Feb 2020 18:53:09 -0700 Subject: [PATCH] Cleanup unused imports and compiler warnings --- .gitignore | 2 ++ src/frontend/about.nim | 6 +++--- src/frontend/activateemail.nim | 9 ++------- src/frontend/category.nim | 4 +--- src/frontend/categorypicker.nim | 4 ++-- src/frontend/error.nim | 1 - src/frontend/forum.nim | 2 +- src/frontend/header.nim | 4 ++-- src/frontend/karaxutils.nim | 2 +- src/frontend/newthread.nim | 2 +- src/frontend/post.nim | 2 +- src/frontend/postlist.nim | 12 ++++++------ src/frontend/profile.nim | 6 +++--- src/frontend/profilesettings.nim | 2 +- src/frontend/resetpassword.nim | 2 +- src/frontend/search.nim | 2 +- src/frontend/threadlist.nim | 20 ++++++++++---------- 17 files changed, 38 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index b209f11..55c0cb9 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ nimcache/ forum createdb editdb + +.vscode diff --git a/src/frontend/about.nim b/src/frontend/about.nim index a805a12..2ceb1d0 100644 --- a/src/frontend/about.nim +++ b/src/frontend/about.nim @@ -1,11 +1,11 @@ when defined(js): - import sugar, httpcore, options, json + import sugar, httpcore import dom except Event include karax/prelude - import karax / [kajax, kdom] + import karax / [kajax] - import error, replybox, threadlist, post + import error import karaxutils type diff --git a/src/frontend/activateemail.nim b/src/frontend/activateemail.nim index 4b049da..607bd4f 100644 --- a/src/frontend/activateemail.nim +++ b/src/frontend/activateemail.nim @@ -5,7 +5,7 @@ when defined(js): include karax/prelude import karax / [kajax, kdom] - import error, replybox, threadlist, post + import error import karaxutils type @@ -13,17 +13,12 @@ when defined(js): loading: bool status: HttpCode error: Option[PostError] - newPassword: kstring proc newActivateEmail*(): ActivateEmail = ActivateEmail( - status: Http200, - newPassword: "" + status: Http200 ) - proc onPassChange(e: Event, n: VNode, state: ActivateEmail) = - state.newPassword = n.value - proc onPost(httpStatus: int, response: kstring, state: ActivateEmail) = postFinished: navigateTo(makeUri("/activateEmail/success")) diff --git a/src/frontend/category.nim b/src/frontend/category.nim index de2d248..b1a68d2 100644 --- a/src/frontend/category.nim +++ b/src/frontend/category.nim @@ -14,9 +14,7 @@ proc cmpNames*(cat1: Category, cat2: Category): int = when defined(js): include karax/prelude - import karax / [vstyles, kajax, kdom] - - import karaxutils + import karax / [vstyles] proc render*(category: Category): VNode = result = buildHtml(): diff --git a/src/frontend/categorypicker.nim b/src/frontend/categorypicker.nim index 98adde1..32a107b 100644 --- a/src/frontend/categorypicker.nim +++ b/src/frontend/categorypicker.nim @@ -4,9 +4,9 @@ when defined(js): import jsffi except `&` include karax/prelude - import karax / [kajax, kdom, vstyles, vdom] + import karax / [kajax, kdom, vdom] - import error, replybox, threadlist, post, category, user + import error, category, user import category, karaxutils type diff --git a/src/frontend/error.nim b/src/frontend/error.nim index 06a8d07..27f1e7c 100644 --- a/src/frontend/error.nim +++ b/src/frontend/error.nim @@ -7,7 +7,6 @@ type when defined(js): import json include karax/prelude - import karax / [vstyles, kajax, kdom] import karaxutils diff --git a/src/frontend/forum.nim b/src/frontend/forum.nim index efb072e..ed62870 100644 --- a/src/frontend/forum.nim +++ b/src/frontend/forum.nim @@ -1,4 +1,4 @@ -import strformat, times, options, json, tables, sugar, httpcore, uri +import options, tables, sugar, httpcore from dom import window, Location, document, decodeURI include karax/prelude diff --git a/src/frontend/header.nim b/src/frontend/header.nim index fc16941..edd1ade 100644 --- a/src/frontend/header.nim +++ b/src/frontend/header.nim @@ -1,6 +1,6 @@ import options, times, httpcore, json, sugar -import threadlist, user +import user type UserStatus* = object user*: Option[User] @@ -63,7 +63,7 @@ when defined(js): proc getStatus(logout: bool=false) = if state.loading: return let diff = getTime() - state.lastUpdate - if diff.minutes < 5: + if diff.inMinutes < 5: return state.loading = true diff --git a/src/frontend/karaxutils.nim b/src/frontend/karaxutils.nim index 2aa9d39..8b2fe8f 100644 --- a/src/frontend/karaxutils.nim +++ b/src/frontend/karaxutils.nim @@ -1,4 +1,4 @@ -import strutils, options, strformat, parseutils, tables +import strutils, strformat, parseutils, tables proc parseIntSafe*(s: string, value: var int) {.noSideEffect.} = ## parses `s` into an integer in the range `validRange`. If successful, diff --git a/src/frontend/newthread.nim b/src/frontend/newthread.nim index fe4e619..d314985 100644 --- a/src/frontend/newthread.nim +++ b/src/frontend/newthread.nim @@ -6,7 +6,7 @@ when defined(js): include karax/prelude import karax / [kajax, kdom] - import error, replybox, threadlist, post, category, user + import error, replybox, threadlist, post, user import karaxutils, categorypicker type diff --git a/src/frontend/post.nim b/src/frontend/post.nim index 5ca0d5f..7c27dec 100644 --- a/src/frontend/post.nim +++ b/src/frontend/post.nim @@ -1,4 +1,4 @@ -import strformat, options +import options import user, threadlist diff --git a/src/frontend/postlist.nim b/src/frontend/postlist.nim index 46dee9a..a516a9f 100644 --- a/src/frontend/postlist.nim +++ b/src/frontend/postlist.nim @@ -1,6 +1,6 @@ import system except Thread -import options, json, times, httpcore, strformat, sugar, math, strutils +import options, json, times, httpcore, sugar, strutils import sequtils import threadlist, category, post, user @@ -18,7 +18,7 @@ when defined(js): import jsffi except `&` include karax/prelude - import karax / [vstyles, kajax, kdom] + import karax / [kajax, kdom] import karaxutils, error, replybox, editbox, postbutton, delete import categorypicker @@ -326,12 +326,12 @@ when defined(js): ] var diffStr = tmpl[0] let diff = latestTime - prevPost.info.creation.fromUnix() - if diff.weeks > 48: - let years = diff.weeks div 48 + if diff.inWeeks > 48: + let years = diff.inWeeks div 48 diffStr = (if years == 1: tmpl[1] else: tmpl[2]) % $years - elif diff.weeks > 4: - let months = diff.weeks div 4 + elif diff.inWeeks > 4: + let months = diff.inWeeks div 4 diffStr = (if months == 1: tmpl[3] else: tmpl[4]) % $months else: diff --git a/src/frontend/profile.nim b/src/frontend/profile.nim index 60f9daf..fbfea68 100644 --- a/src/frontend/profile.nim +++ b/src/frontend/profile.nim @@ -1,12 +1,12 @@ -import options, httpcore, json, sugar, times, strformat, strutils +import options, httpcore, json, sugar, times, strutils -import threadlist, post, category, error, user +import threadlist, post, error, user when defined(js): from dom import document include karax/prelude import karax/[kajax, kdom] - import karaxutils, postbutton, delete, profilesettings + import karaxutils, profilesettings type ProfileTab* = enum diff --git a/src/frontend/profilesettings.nim b/src/frontend/profilesettings.nim index 5c2e1eb..8d7fda3 100644 --- a/src/frontend/profilesettings.nim +++ b/src/frontend/profilesettings.nim @@ -5,7 +5,7 @@ when defined(js): include karax/prelude import karax/[kajax, kdom] - import replybox, post, karaxutils, postbutton, error, delete, user + import post, karaxutils, postbutton, error, delete, user type ProfileSettings* = ref object diff --git a/src/frontend/resetpassword.nim b/src/frontend/resetpassword.nim index d8f2446..497af98 100644 --- a/src/frontend/resetpassword.nim +++ b/src/frontend/resetpassword.nim @@ -6,7 +6,7 @@ when defined(js): include karax/prelude import karax / [kajax, kdom] - import error, replybox, threadlist, post + import error import karaxutils type diff --git a/src/frontend/search.nim b/src/frontend/search.nim index 2edb90e..a1ef3fa 100644 --- a/src/frontend/search.nim +++ b/src/frontend/search.nim @@ -20,7 +20,7 @@ when defined(js): from dom import nil include karax/prelude - import karax / [vstyles, kajax, kdom] + import karax / [kajax] import karaxutils, error, threadlist, sugar diff --git a/src/frontend/threadlist.nim b/src/frontend/threadlist.nim index b3b3d81..776c5ca 100644 --- a/src/frontend/threadlist.nim +++ b/src/frontend/threadlist.nim @@ -1,4 +1,4 @@ -import strformat, times, options, json, httpcore, sugar +import strformat, times, options, json, httpcore import category, user @@ -98,19 +98,19 @@ when defined(js): let duration = currentTime - activityTime if currentTime.local().year != activityTime.local().year: return activityTime.local().format("MMM yyyy") - elif duration.days > 30 and duration.days < 300: + elif duration.inDays > 30 and duration.inDays < 300: return activityTime.local().format("MMM dd") - elif duration.days != 0: - return $duration.days & "d" - elif duration.hours != 0: - return $duration.hours & "h" - elif duration.minutes != 0: - return $duration.minutes & "m" + elif duration.inDays != 0: + return $duration.inDays & "d" + elif duration.inHours != 0: + return $duration.inHours & "h" + elif duration.inMinutes != 0: + return $duration.inMinutes & "m" else: - return $duration.seconds & "s" + return $duration.inSeconds & "s" proc genThread(thread: Thread, isNew: bool, noBorder: bool): VNode = - let isOld = (getTime() - thread.creation.fromUnix).weeks > 2 + let isOld = (getTime() - thread.creation.fromUnix).inWeeks > 2 let isBanned = thread.author.rank.isBanned() result = buildHtml(): tr(class=class({"no-border": noBorder, "banned": isBanned})):