|
|
@ -1,5 +1,5 @@ |
|
|
|
import { InputMedia } from "../../layer"; |
|
|
|
import { InputMedia } from "../../layer"; |
|
|
|
import { logger, LogLevels } from "../logger"; |
|
|
|
import { logger } from "../logger"; |
|
|
|
import apiManager from "../mtproto/mtprotoworker"; |
|
|
|
import apiManager from "../mtproto/mtprotoworker"; |
|
|
|
import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config"; |
|
|
|
import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config"; |
|
|
|
import { RichTextProcessor } from "../richtextprocessor"; |
|
|
|
import { RichTextProcessor } from "../richtextprocessor"; |
|
|
@ -74,7 +74,7 @@ class AppPollsManager { |
|
|
|
public polls: {[id: string]: Poll} = {}; |
|
|
|
public polls: {[id: string]: Poll} = {}; |
|
|
|
public results: {[id: string]: PollResults} = {}; |
|
|
|
public results: {[id: string]: PollResults} = {}; |
|
|
|
|
|
|
|
|
|
|
|
private log = logger('POLLS', LogLevels.error); |
|
|
|
private log = logger('POLLS'/* , LogLevels.error */); |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
$rootScope.$on('apiUpdate', (e) => { |
|
|
|
$rootScope.$on('apiUpdate', (e) => { |
|
|
@ -89,7 +89,7 @@ class AppPollsManager { |
|
|
|
case 'updateMessagePoll': { // when someone voted, we too
|
|
|
|
case 'updateMessagePoll': { // when someone voted, we too
|
|
|
|
this.log('updateMessagePoll:', update); |
|
|
|
this.log('updateMessagePoll:', update); |
|
|
|
|
|
|
|
|
|
|
|
let poll: Poll = /* this.polls[update.poll_id] || */update.poll; |
|
|
|
let poll: Poll = update.poll || this.polls[update.poll_id]; |
|
|
|
if(!poll) { |
|
|
|
if(!poll) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -124,13 +124,15 @@ class AppPollsManager { |
|
|
|
public saveResults(poll: Poll, results: PollResults) { |
|
|
|
public saveResults(poll: Poll, results: PollResults) { |
|
|
|
this.results[poll.id] = results; |
|
|
|
this.results[poll.id] = results; |
|
|
|
|
|
|
|
|
|
|
|
poll.chosenIndexes.length = 0; |
|
|
|
if(!results.pFlags.min) { // ! https://core.telegram.org/constructor/pollResults - min
|
|
|
|
if(results?.results?.length) { |
|
|
|
poll.chosenIndexes.length = 0; |
|
|
|
results.results.forEach((answer, idx) => { |
|
|
|
if(results?.results?.length) { |
|
|
|
if(answer.pFlags?.chosen) { |
|
|
|
results.results.forEach((answer, idx) => { |
|
|
|
poll.chosenIndexes.push(idx); |
|
|
|
if(answer.pFlags?.chosen) { |
|
|
|
} |
|
|
|
poll.chosenIndexes.push(idx); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|