Cleanup unused imports and compiler warnings

This commit is contained in:
Joey Yakimowich-Payne 2020-02-15 18:53:09 -07:00
commit 66fbb7c44d
17 changed files with 38 additions and 44 deletions

2
.gitignore vendored
View file

@ -12,3 +12,5 @@ nimcache/
forum
createdb
editdb
.vscode

View file

@ -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

View file

@ -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"))

View file

@ -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():

View file

@ -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

View file

@ -7,7 +7,6 @@ type
when defined(js):
import json
include karax/prelude
import karax / [vstyles, kajax, kdom]
import karaxutils

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -1,4 +1,4 @@
import strformat, options
import options
import user, threadlist

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -6,7 +6,7 @@ when defined(js):
include karax/prelude
import karax / [kajax, kdom]
import error, replybox, threadlist, post
import error
import karaxutils
type

View file

@ -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

View file

@ -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})):