diff --git a/client/webapp/auto-verifier-with-args.ts b/client/webapp/auto-verifier-with-args.ts index c064df7..bb9521f 100644 --- a/client/webapp/auto-verifier-with-args.ts +++ b/client/webapp/auto-verifier-with-args.ts @@ -40,17 +40,17 @@ export class AutoVerifierWithArg { query => primaryFunc(query), query => trustedFunc(query), async (query: PartialMessageListQuery, primaryResult: T[] | null, trustedResult: T[] | null) => { - LOG.debug('messages verify: ', { - query, - // primaryResult: primaryResult?.map((e: any) => e.sent).sort(), - // trustedResult: trustedResult?.map((e: any) => e.sent).sort(), - zipped: primaryResult && trustedResult && primaryResult.length === trustedResult.length && Q.zip( - primaryResult?.sort((a: any, b: any) => a.sent.getTime() - b.sent.getTime()).map((e: any) => e.text), - trustedResult?.sort((a: any, b: any) => a.sent.getTime() - b.sent.getTime()).map((e: any) => e.text) - ) - }); + // LOG.debug('messages verify: ', { + // query, + // // primaryResult: primaryResult?.map((e: any) => e.sent).sort(), + // // trustedResult: trustedResult?.map((e: any) => e.sent).sort(), + // zipped: primaryResult && trustedResult && primaryResult.length === trustedResult.length && Q.zip( + // primaryResult?.sort((a: any, b: any) => a.sent.getTime() - b.sent.getTime()).map((e: any) => e.text), + // trustedResult?.sort((a: any, b: any) => a.sent.getTime() - b.sent.getTime()).map((e: any) => e.text) + // ) + // }); let changes = AutoVerifier.getChanges(primaryResult, trustedResult); - LOG.debug('changes:', { changes }); + //LOG.debug('changes:', { changes }); let changesType = AutoVerifier.getListChangesType(primaryResult, trustedResult, changes); await changesFunc(query, changesType, changes); } diff --git a/client/webapp/elements/events-infinite-scroll.ts b/client/webapp/elements/events-infinite-scroll.ts index cdadd54..47d6642 100644 --- a/client/webapp/elements/events-infinite-scroll.ts +++ b/client/webapp/elements/events-infinite-scroll.ts @@ -1,3 +1,8 @@ +import * as electronRemote from '@electron/remote'; +const electronConsole = electronRemote.getGlobal('console') as Console; +import Logger from '../../../logger/logger'; +const LOG = Logger.create(__filename, electronConsole); + import Actions from "../actions"; import Q from "../q-module"; import UI from "../ui"; @@ -11,16 +16,31 @@ export default function bindInfiniteScrollEvents(q: Q, ui: UI): void { let scrollHeight = q.$('#channel-feed-content-wrapper').scrollHeight; let clientHeight = q.$('#channel-feed-content-wrapper').clientHeight; + // WARNING + // There's likely an inconsistency between browsers on this so have fun when you're working + // on the cross-platform implementation of this + // scrollTop apparantly is negative for column-reverse divs (this actually kindof makes sense if you flip your head upside down) + // have to reverse this + // I expect this was a change with some version of chromium. + // MDN documentation issue: https://github.com/mdn/content/issues/10968 + + let distToTop = -(clientHeight - scrollHeight - scrollTop); // keep in mind scrollTop is negative >:] + let distToBottom = -scrollTop; + + //LOG.debug('update infinite scroll', { scrollTop, scrollHeight, clientHeight, distToTop, distToBottom, loadingBefore, loadingAfter }); + if (ui.activeGuild === null) return; if (ui.activeChannel === null) return; - if (!loadingBefore && !ui.messagesAtTop && scrollTop < 600) { // Approaching the unloaded top of the page + if (!loadingBefore && !ui.messagesAtTop && distToTop < 600) { // Approaching the unloaded top of the page // Fetch more messages to add above + LOG.debug('fetching messages before', { loadingBefore, messagesAtTop: ui.messagesAtTop, distToTop }); loadingBefore = true; await Actions.fetchAndUpdateMessagesBefore(q, ui, ui.activeGuild, ui.activeChannel); loadingBefore = false; - } else if (!loadingAfter && !ui.messagesAtBottom && scrollHeight - clientHeight - scrollTop < 600) { // Approaching the unloaded bottom of the page + } else if (!loadingAfter && !ui.messagesAtBottom && distToBottom < 600) { // Approaching the unloaded bottom of the page // Fetch more messages to add below + LOG.debug('fetching messages after', { loadingAfter, messagesAtBottom: ui.messagesAtBottom, distToBottom: distToBottom }); loadingAfter = true; await Actions.fetchAndUpdateMessagesAfter(q, ui, ui.activeGuild, ui.activeChannel); loadingAfter = false; diff --git a/makefile b/makefile index 9f8aa75..a54023a 100644 --- a/makefile +++ b/makefile @@ -34,7 +34,7 @@ reset-server: create-invite: node ./dist/server/scripts/create-cordis-file.js -create-exmaple-roles: +create-example-roles: node ./dist/server/scripts/example-roles.js create-memes-messages: diff --git a/server/scripts/example-roles.ts b/server/scripts/example-roles.ts index 858f40f..460b8dc 100644 --- a/server/scripts/example-roles.ts +++ b/server/scripts/example-roles.ts @@ -25,7 +25,7 @@ process.on('unhandledRejection', async (reason, promise) => { await DB.assignRoleToMember(targetGuild.id, roleId, targetMember.id); LOG.info('role created and assigned'); } catch (e) { - LOG.error('error creating permissions'); + LOG.error('error creating permissions', e); } await DB.end(); })(); \ No newline at end of file diff --git a/server/sql/init.sql b/server/sql/init.sql index ec6e6d6..08fa6c2 100644 --- a/server/sql/init.sql +++ b/server/sql/init.sql @@ -104,7 +104,7 @@ CREATE TABLE "messages" ( , "guild_id" UUID NOT NULL REFERENCES "guilds"("id") ON DELETE CASCADE , "channel_id" UUID NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE , "member_id" UUID NOT NULL REFERENCES "members"("id") -- probably want set null - , "sent_dtg" TIMESTAMP(3) WITH TIME ZONE NOT NULL + , "sent_dtg" TIMESTAMP WITH TIME ZONE NOT NULL , "text" TEXT , "resource_id" UUID REFERENCES "resources"("id") , "resource_name" VARCHAR(256)