OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-store / store / notification / notification-test.saga.js

39 lines · javascript ref:
import { put as e, delay as o } from "redux-saga/effects"
import { taskErrorSaga as t } from "../error"
import { NOTIFICATION_CODE as a, NOTIFICATION_TYPE as r } from "./notification.constants"
import {
  userCustomNotification as i,
  userErrorNotification as n,
  userInfoNotification as s,
  userSuccessNotification as c,
} from "./notification.reducer"
export function* generateRandomNotificationsSaga() {
  try {
    for (;;) {
      const t = Object.keys(r),
        l = r[t[Math.floor(Math.random() * t.length)]],
        m = Object.keys(a),
        d = a[m[Math.floor(Math.random() * m.length)]]
      switch (l) {
        case r.SUCCESS:
          yield e(c({ title: "Success title", message: "All is good" }))
          break
        case r.ERROR:
          yield e(n({ title: "Error title", message: "Some error happens" }))
          break
        case r.INFO:
          yield e(s({ title: "Info", message: "Information message goes here" }))
          break
        case r.CUSTOM:
          d === a.ROOM_ACTIVITY
            ? yield e(i({ code: d, roomTitle: "Development room" }))
            : d === a.PAYMENT_RECEIVED &&
              (yield e(i({ code: d, amount: 700, description: "cache back" })))
      }
      yield o(Math.floor(1500 * Math.random()))
    }
  } catch (e) {
    yield t("generateRandomNotificationsSaga", e, { logOnly: !0 })
  }
}