<commit_before>import { actionTypes } from "../actions/actions.js";
import Immutable from "immutable";
import won from "../won-es6.js";
import { getIn, generateIdString } from "../utils.js";

const initialState = Immutable.fromJS({});

export default function(allToasts = initialState, action = {}) {
  switch (action.type) {
    case actionTypes.toasts.test:
      allToasts = pushNewToast(allToasts, "Error Toast", won.WON.errorToast);
      allToasts = pushNewToast(allToasts, "Warning Toast", won.WON.warnToast);
      allToasts = pushNewToast(allToasts, "Info Toast", won.WON.infoToast);
      return allToasts;

    case actionTypes.logout:
      return initialState;

    case actionTypes.connections.sendChatMessageFailed: {
      const msg = getIn(action, ["payload", "message"]);
      return pushNewToast(
        allToasts,
        "Error while processing chat message: \n\n" + msg,
        won.WON.errorToast,
        {}
      );
    }

    case actionTypes.registerFailed: {
      const privateId = getIn(action, ["payload", "privateId"]);
      if (privateId) {
        return pushNewToast(
          allToasts,
          "Sorry, something failed when posting/generating a new private-ID (the one in " +
            "your url-bar). Copy the text you've written somewhere safe, then log out / remove " +
            "the ID, then refresh the page and try posting again.",
          won.WON.errorToast,
          {}
        );
      } else {
        return allToasts;
      }
    }

    case actionTypes.loginFailed:
      if (getIn(action, ["payload", "loginError"]) === "invalid privateId") {
        return pushNewToast(
          allToasts,
          "Sorry, we couldn't find the private ID (the one in your url-bar). If " +
            "you copied this address make sure you <strong>copied everything</strong> and try " +
            "<strong>reloading the page</strong>. " +
            "If this doesn't work you can try " +
            '<a href="#">' +
            "removing it" +
            "</a> to start fresh.",
          won.WON.errorToast,
          { unsafeHtmlEnabled: true }
        );
      } else {
        return allToasts;
      }

    case actionTypes.geoLocationDenied:
      return pushNewToast(
        allToasts,
        'Sorry, we were unable to create your "What\'s Around"-Post, ' +
          "because you have denied us accesss to your current location. " +
          'To enable it, reload the page and click on "allow access". If' +
          "you've disabled it permanently you can find instructions here for  " +
          '<a href="https://support.google.com/chrome/answer/142065">Chrome</a>, ' +
          '<a href="https://www.mozilla.org/en-US/firefox/geolocation/">Firefox</a>, ' +
          '<a href="https://support.apple.com/en-us/HT204690">Safari</a> and ' +
          '<a href="https://privacy.microsoft.com/en-us/windows-10-location-and-privacy">Internet Explorer Edge</a>.',
        won.WON.warnToast,
        { unsafeHtmlEnabled: true }
      );

    case actionTypes.lostConnection:
      return pushNewToast(
        allToasts,
        "Lost connection - progress " +
          "can't be saved any more. Make sure your " +
          'internet-connection is working, then click "Reconnect"',
        won.WON.warnToast
      );
    //INFO TOASTS: won.WON.infoToast

    //WARN TOASTS: won.WON.warnToast
    //ERROR TOASTS: won.WON.errorToast
    case actionTypes.messages.closeNeed.failed:
      return pushNewToast(
        allToasts,
        "Failed to close posting",
        won.WON.errorToast
      );

    case actionTypes.messages.reopenNeed.failed:
      return pushNewToast(
        allToasts,
        "Failed to reopen posting",
        won.WON.errorToast
      );<commit_msg>remove lost-connection toast, as we will show the message within the slide-in anyway and do not need the redundancy here<commit_after>import { actionTypes } from "../actions/actions.js";
import Immutable from "immutable";
import won from "../won-es6.js";
import { getIn, generateIdString } from "../utils.js";

const initialState = Immutable.fromJS({});

export default function(allToasts = initialState, action = {}) {
  switch (action.type) {
    case actionTypes.toasts.test:
      allToasts = pushNewToast(allToasts, "Error Toast", won.WON.errorToast);
      allToasts = pushNewToast(allToasts, "Warning Toast", won.WON.warnToast);
      allToasts = pushNewToast(allToasts, "Info Toast", won.WON.infoToast);
      return allToasts;

    case actionTypes.logout:
      return initialState;

    case actionTypes.connections.sendChatMessageFailed: {
      const msg = getIn(action, ["payload", "message"]);
      return pushNewToast(
        allToasts,
        "Error while processing chat message: \n\n" + msg,
        won.WON.errorToast,
        {}
      );
    }

    case actionTypes.registerFailed: {
      const privateId = getIn(action, ["payload", "privateId"]);
      if (privateId) {
        return pushNewToast(
          allToasts,
          "Sorry, something failed when posting/generating a new private-ID (the one in " +
            "your url-bar). Copy the text you've written somewhere safe, then log out / remove " +
            "the ID, then refresh the page and try posting again.",
          won.WON.errorToast,
          {}
        );
      } else {
        return allToasts;
      }
    }

    case actionTypes.loginFailed:
      if (getIn(action, ["payload", "loginError"]) === "invalid privateId") {
        return pushNewToast(
          allToasts,
          "Sorry, we couldn't find the private ID (the one in your url-bar). If " +
            "you copied this address make sure you <strong>copied everything</strong> and try " +
            "<strong>reloading the page</strong>. " +
            "If this doesn't work you can try " +
            '<a href="#">' +
            "removing it" +
            "</a> to start fresh.",
          won.WON.errorToast,
          { unsafeHtmlEnabled: true }
        );
      } else {
        return allToasts;
      }

    case actionTypes.geoLocationDenied:
      return pushNewToast(
        allToasts,
        'Sorry, we were unable to create your "What\'s Around"-Post, ' +
          "because you have denied us accesss to your current location. " +
          'To enable it, reload the page and click on "allow access". If' +
          "you've disabled it permanently you can find instructions here for  " +
          '<a href="https://support.google.com/chrome/answer/142065">Chrome</a>, ' +
          '<a href="https://www.mozilla.org/en-US/firefox/geolocation/">Firefox</a>, ' +
          '<a href="https://support.apple.com/en-us/HT204690">Safari</a> and ' +
          '<a href="https://privacy.microsoft.com/en-us/windows-10-location-and-privacy">Internet Explorer Edge</a>.',
        won.WON.warnToast,
        { unsafeHtmlEnabled: true }
      );

    /*case actionTypes.lostConnection:
      return pushNewToast(
        allToasts,
        "Lost connection - progress " +
          "can't be saved any more. Make sure your " +
          'internet-connection is working, then click "Reconnect"',
        won.WON.warnToast
      );*/
    //INFO TOASTS: won.WON.infoToast

    //WARN TOASTS: won.WON.warnToast
    //ERROR TOASTS: won.WON.errorToast
    case actionTypes.messages.closeNeed.failed:
      return pushNewToast(
        allToasts,
        "Failed to close posting",
        won.WON.errorToast
      );

    case actionTypes.messages.reopenNeed.failed:
      return pushNewToast(
        allToasts,
        "Failed to reopen posting",
        won.WON.errorToast
      );
{'fraction_non_alphanumeric': 0.11827391132745692, 'fraction_numerical': 0.003946849098802789, 'mean_word_length': 2.288062283737024, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1375299', 'n_tokens_mistral': 2303, 'n_tokens_neox': 2244, 'n_words': 597}