ref(polls) Convert files to TS (#12296)
This commit is contained in:
parent
7d7bf987a1
commit
c35d1d8d4b
|
@ -1,5 +1,3 @@
|
|||
// @flow
|
||||
|
||||
import {
|
||||
CHANGE_VOTE,
|
||||
CLEAR_POLLS,
|
||||
|
@ -9,7 +7,7 @@ import {
|
|||
RESET_NB_UNREAD_POLLS,
|
||||
RETRACT_VOTE
|
||||
} from './actionTypes';
|
||||
import type { Answer, Poll } from './types';
|
||||
import { Answer, Poll } from './types';
|
||||
|
||||
/**
|
||||
* Action to signal that existing polls needs to be cleared from state.
|
|
@ -1,4 +1,4 @@
|
|||
// @flow
|
||||
import { IState } from '../app/types';
|
||||
|
||||
/**
|
||||
* Selector creator for determining if poll results should be displayed or not.
|
||||
|
@ -7,7 +7,7 @@
|
|||
* @returns {Function}
|
||||
*/
|
||||
export function shouldShowResults(id: string) {
|
||||
return function(state: Object) {
|
||||
return function(state: IState) {
|
||||
return Boolean(state['features/polls']?.polls[id].showResults);
|
||||
};
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export function shouldShowResults(id: string) {
|
|||
* @returns {Function}
|
||||
*/
|
||||
export function getPoll(pollId: string) {
|
||||
return function(state: Object) {
|
||||
return function(state: IState) {
|
||||
return state['features/polls'].polls[pollId];
|
||||
};
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ export function getPoll(pollId: string) {
|
|||
/**
|
||||
* Selector for calculating the number of unread poll messages.
|
||||
*
|
||||
* @param {Object} state - The redux state.
|
||||
* @param {IState} state - The redux state.
|
||||
* @returns {number} The number of unread messages.
|
||||
*/
|
||||
export function getUnreadPollCount(state: Object) {
|
||||
export function getUnreadPollCount(state: IState) {
|
||||
const { nbUnreadPolls } = state['features/polls'];
|
||||
|
||||
return nbUnreadPolls;
|
|
@ -1,16 +1,13 @@
|
|||
// @flow
|
||||
|
||||
import { getCurrentConference } from '../base/conference';
|
||||
import { IStore } from '../app/types';
|
||||
import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
|
||||
import { getCurrentConference } from '../base/conference/functions';
|
||||
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
||||
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
|
||||
import { playSound } from '../base/sounds';
|
||||
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
||||
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
|
||||
import { playSound } from '../base/sounds/actions';
|
||||
import { INCOMING_MSG_SOUND_ID } from '../chat/constants';
|
||||
import {
|
||||
NOTIFICATION_TIMEOUT_TYPE,
|
||||
NOTIFICATION_TYPE,
|
||||
showNotification
|
||||
} from '../notifications';
|
||||
import { showNotification } from '../notifications/actions';
|
||||
import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../notifications/constants';
|
||||
|
||||
import { RECEIVE_POLL } from './actionTypes';
|
||||
import { clearPolls, receiveAnswer, receivePoll } from './actions';
|
||||
|
@ -19,7 +16,7 @@ import {
|
|||
COMMAND_NEW_POLL,
|
||||
COMMAND_OLD_POLLS
|
||||
} from './constants';
|
||||
import type { Answer, Poll } from './types';
|
||||
import { Answer, Poll, PollData } from './types';
|
||||
|
||||
/**
|
||||
* Set up state change listener to perform maintenance tasks when the conference
|
||||
|
@ -36,7 +33,7 @@ StateListenerRegistry.register(
|
|||
}
|
||||
});
|
||||
|
||||
const parsePollData = (pollData): Poll | null => {
|
||||
const parsePollData = (pollData: PollData): Poll | null => {
|
||||
if (typeof pollData !== 'object' || pollData === null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -84,9 +81,9 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
|||
const { conference } = action;
|
||||
|
||||
conference.on(JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
||||
(_, data) => _handleReceivePollsMessage(data, dispatch));
|
||||
(_: any, data: any) => _handleReceivePollsMessage(data, dispatch));
|
||||
conference.on(JitsiConferenceEvents.NON_PARTICIPANT_MESSAGE_RECEIVED,
|
||||
(_, data) => _handleReceivePollsMessage(data, dispatch));
|
||||
(_: any, data: any) => _handleReceivePollsMessage(data, dispatch));
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -118,7 +115,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
|||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function _handleReceivePollsMessage(data, dispatch) {
|
||||
function _handleReceivePollsMessage(data: any, dispatch: IStore['dispatch']) {
|
||||
switch (data.type) {
|
||||
case COMMAND_NEW_POLL: {
|
||||
const { question, answers, pollId, senderId, senderName } = data;
|
||||
|
@ -130,7 +127,7 @@ function _handleReceivePollsMessage(data, dispatch) {
|
|||
showResults: false,
|
||||
lastVote: null,
|
||||
question,
|
||||
answers: answers.map(answer => {
|
||||
answers: answers.map((answer: Answer) => {
|
||||
return {
|
||||
name: answer,
|
||||
voters: new Map()
|
|
@ -1,4 +1,4 @@
|
|||
export type Answer = {
|
||||
export interface Answer {
|
||||
|
||||
/**
|
||||
* An array of boolean: true if the answer was chosen by the responder, else false.
|
||||
|
@ -19,9 +19,9 @@ export type Answer = {
|
|||
* Name of the voter.
|
||||
*/
|
||||
voterName: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type Poll = {
|
||||
export interface Poll {
|
||||
|
||||
/**
|
||||
* An array of answers:
|
||||
|
@ -60,4 +60,8 @@ export type Poll = {
|
|||
* Whether the results should be shown instead of the answer form.
|
||||
*/
|
||||
showResults: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PollData extends Poll {
|
||||
id: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue