How to use the selectors.getUiState function in selectors

To help you get started, we’ve selected a few selectors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github web-pal / chronos-timetracker / app / sagas / storage.js View on Github external
export function* getFromStorage(key: string): Generator<*, mixed, *> {
  const host: URL | null = yield select(getUiState('host'));
  const userData = yield select(getUserData);
  // $FlowFixMe: array methods buggy with Enums
  if (prefixedKeys.includes(key) && !host && !userData) {
    throw new Error('Need to fill host before getting prefixed keys from storage');
  }
  const data = yield call(
    storageGetPromise,
    // $FlowFixMe: array methods buggy with Enums
    prefixedKeys.includes(key) ? `${host}_${userData.accountId}_${key}` : key,
  );
  return data;
}
github web-pal / chronos-timetracker / app / sagas / storage.js View on Github external
export function* setToStorage(key: string, data: *): Generator<*, Promise, *> {
  const host: URL | null = yield select(getUiState('host'));
  const userData = yield select(getUserData);
  // $FlowFixMe: array methods buggy with Enums
  if (prefixedKeys.includes(key) && !host && !userData) {
    throw new Error('Can\'t set prefixed variable to storage if no host provided');
  }
  return storageSetPromise(
    // $FlowFixMe: array methods buggy with Enums
    prefixedKeys.includes(key) ? `${host}_${userData.accountId}_${key}` : key,
    data,
  );
}
github web-pal / chronos-timetracker / app / renderer / sagas / timer.js View on Github external
function* handleTick({
  timerChannel,
  screenshotsEnabled,
}) {
  let idleWindowTask = null;
  let prevScreenshotId = null;
  const screenshotsPeriod = yield eff.select(getUiState('screenshotsPeriod'));
  while (true) {
    yield eff.take(timerChannel);
    const bufferSeconds = yield eff.flush(timerChannel);

    yield eff.put(timerActions.tick(
      1 + bufferSeconds.length,
    ));
    const time = yield eff.select(getTimerState('time'));

    if (bufferSeconds.length) {
      console.log('!!!!!!!!!!!!!!!!!');
      Sentry.captureMessage(`bufferSeconds is ${bufferSeconds.length}`);
    }
    yield eff.call(setTimeToTray);
    const [
      showIdleWindow,
github web-pal / chronos-timetracker / app / renderer / sagas / helpers.js View on Github external
export function* savePersistStorage() {
  const persistUiState = yield eff.select(
    getUiState(Object.keys(persistInitialUiState)),
  );
  const hostname = yield eff.select(
    getUiState('hostname'),
  );
  yield eff.call(
    setElectronStorage,
    `persistUiState_${hostname}`,
    persistUiState,
  );

  const accounts = yield eff.select(
    getUiState('accounts'),
  );
  yield eff.call(
    setElectronStorage,
    'accounts',
    accounts,
  );
}
github web-pal / chronos-timetracker / app / renderer / sagas / settings.js View on Github external
{
      type: 'warning',
      buttons: ['YES', 'NO'],
      defaultId: 0,
      message: 'Are you sure',
      detail: clearAppDataMessage,
    },
  );
  if (response === 0) {
    yield eff.call(
      setElectronStorage,
      'accounts',
      [],
    );
    const hostname = yield eff.select(
      getUiState('hostname'),
    );
    yield eff.call(
      setElectronStorage,
      `persistUiState_${hostname}`,
      {},
    );
    yield eff.put(uiActions.setUiState({
      readyToQuit: true,
    }));
    if (process.env.NODE_ENV === 'development') {
      yield eff.call(
        remote.session.defaultSession.clearCache,
        () => {},
      );
      yield eff.call(remote.session.defaultSession.clearStorageData);
      remote.getCurrentWindow().webContents.reload();
github web-pal / chronos-timetracker / app / renderer / sagas / worklogs.js View on Github external
...(
            adjustEstimate === 'manual'
              ? {
                reduceBy,
              } : {}
          ),
        },
        body: {
          started,
          timeSpentSeconds,
          comment,
        },
      },
    );
    if (isAuto) {
      const hostname = yield eff.select(getUiState('hostname'));
      const isCloud = hostname.endsWith('.atlassian.net');
      let screenshots = yield eff.select(getUiState('screenshots'));
      yield eff.all(
        screenshots
          .filter(s => s.status === 'offline')
          .map(s => (
            eff.call(
              uploadScreenshots,
              {
                isCloud,
                filenameImage: s.filename,
                filenameThumb: s.filenameThumb,
                imagePath: s.imagePath,
                imageThumbPath: s.imageThumbPath,
              },
            )
github web-pal / chronos-timetracker / app / renderer / containers / Sidebar / Sidebar.jsx View on Github external
function mapStateToProps(state) {
  return {
    sidebarType: getUiState('sidebarType')(state),
  };
}
github web-pal / chronos-timetracker / app / renderer / containers / IssueView / TrackingBar / TrackingBar.jsx View on Github external
function mapStateToProps(state) {
  return {
    time: getTimerState('time')(state),
    report: getTrackingIssueReport(state),
    screenshotUploading: false,
    screenshotsAllowed: false,
    trackingIssue: getTrackingIssue(state),
    worklogComment: getUiState('worklogComment')(state),
    remainingEstimateValue: getUiState('remainingEstimateValue')(state),
    remainingEstimateNewValue: getUiState('remainingEstimateNewValue')(state),
    remainingEstimateReduceByValue: getUiState('remainingEstimateReduceByValue')(state),
    isCommentDialogOpen: getUiState('isCommentDialogOpen')(state),
    showLoggedOnStop: getUiState('showLoggedOnStop')(state),
  };
}
github web-pal / chronos-timetracker / app / renderer / containers / IssueView / IssueComments / IssueComments.jsx View on Github external
function mapStateToProps(state) {
  const selectedIssueId = getUiState('selectedIssueId')(state);
  return {
    comments: getResourceMappedList(
      'issuesComments',
      `issue_${selectedIssueId}`,
    )(state),
    commentsFetching: getResourceStatus(
      state,
      `issuesComments.requests.issue_${selectedIssueId}.status`,
    ).pending,
    selectedIssueId,
    adding: getUiState('commentAdding')(state),
    self: getUserData(state),
  };
}
github web-pal / chronos-timetracker / app / containers / IssueView / IssueWorklogs / IssueWorklogs.jsx View on Github external
function mapStateToProps(state) {
  return {
    worklogs: getSelectedIssueWorklogs(state),
    issue: getSelectedIssue(state),
    selectedWorklogId: getUiState('selectedWorklogId')(state),
    selectedIssue: getSelectedIssue(state),
    scrollToIndex: getUiState('issueViewWorklogsScrollToIndex')(state),
  };
}

selectors

Immutable JSON selectors...

MIT
Latest version published 9 years ago

Package Health Score

42 / 100
Full package analysis

Popular selectors functions