Verified Commit 617bc84b authored by Adam Parák's avatar Adam Parák 💬
Browse files

v7

parent 9563c3e6
Loading
Loading
Loading
Loading
Compare f9294b13 to e3879174
Original line number Diff line number Diff line
Subproject commit f9294b13a2b57a9f49f69bbb4d2f2a46a1d9e5ac
Subproject commit e3879174c07ab4a24cd3b09fdd7260a85e90d668
+1 −1
Original line number Diff line number Diff line
@@ -6,13 +6,13 @@ import {
  SectionCard,
} from '@blueprintjs/core'
import { css, cx } from '@emotion/css'
import { useHost } from '@inject/graphql'
import {
  authenticatedFetch,
  changePasswordUrl,
  ErrorMessage,
  notifyNoncommmit,
  setSessionId,
  useHost,
  useWiggle,
  wiggleClass,
} from '@inject/shared'
+18 −1
Original line number Diff line number Diff line
import { getSessionId } from '@inject/shared'
import UrqlWorker from '@inject/webworker/worker?sharedworker&url'
import type { WorkerData } from '@inject/webworker/workerTyping'
import type { Exchange, OperationResult } from 'urql'
@@ -30,7 +31,19 @@ const keyMap = new Set<number>()

const operationTabNonce = generateTabNonce()

const awaitReadiness = () =>
  new Promise(resolve => {
    setTimeout(async function fn() {
      if ((await getSessionId()) === '') {
        setTimeout(fn, 500)
      } else {
        resolve(true)
      }
    }, 500)
  })

export const multitab: Exchange = () => op$ => {
  let isSessionIdReady = false
  pipe(
    op$,
    filter(
@@ -41,8 +54,12 @@ export const multitab: Exchange = () => op$ => {
        op.context.requestPolicy === 'network-only' ||
        op.context.requestPolicy === 'cache-and-network'
    ),
    tap(op => {
    tap(async op => {
      keyMap.add(op.key)
      if (!isSessionIdReady) {
        await awaitReadiness()
        isSessionIdReady = true
      }
      const tabWorker = new SharedWorker(UrqlWorker, {
        type: 'module',
        name: 'urqlWorker',
+0 −15
Original line number Diff line number Diff line
import type { EntityTable } from 'dexie'
import { Dexie } from 'dexie'
import 'dexie-syncable'

export const db = new Dexie('storage') as Dexie & {
  actionLogs: EntityTable<
@@ -49,17 +48,3 @@ db.version(1).stores({
  questionnaires: '&id',
  emailThreads: '&id',
})

Dexie.Syncable.registerSyncProtocol('ixp-syncable', {
  sync(context, exerciseId, options, baseRevision, syncedRevision, changes, partial, applyRemoteChanges, onChangesAccepted, onSuccess, onError) {
      changes.forEach(change => {
        if (change.type === 'insert' || change.type === 'update') {
          context.table(change.table).put(change.value)
        } else if (change.type === 'delete') {
          context.table(change.table).delete(change.key)
        }
      }
  },
})

db.syncable.connect({})
+4 −0
Original line number Diff line number Diff line
@@ -884,6 +884,7 @@ export const Question = graphql(
        }
      }
      note
      ...QuestionAnswerable
    }
  `,
  [
@@ -891,6 +892,7 @@ export const Question = graphql(
    RadioQuestionDetails,
    FreeFormQuestionDetails,
    AutoFreeFormQuestionDetails,
    QuestionAnswerable,
    MultipleChoiceQuestionDetailsType,
  ]
)
@@ -952,6 +954,7 @@ export const Questionnaire = graphql(
      }
      questions {
        ...Question
        ...QuestionAnswerable
      }
      postExerciseSubmission
      repeatable {
@@ -966,6 +969,7 @@ export const Questionnaire = graphql(
    Question,
    Team,
    QuestionnaireAnswer,
    QuestionAnswerable,
    QuestionRelatedMilestones,
    Repeatable,
  ]
Loading