AudioPlayer: Logging when changing playback or queue

This commit is contained in:
Scott Nonnenberg 2023-04-11 10:28:04 -07:00 committed by GitHub
parent 5574b08f4c
commit ea2083cd11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 11 deletions

View file

@ -311,19 +311,19 @@ export function reducer(
} }
const { playbackRate, startPosition, ...content } = payload; const { playbackRate, startPosition, ...content } = payload;
log.info(
`audioPlayer/SET_MESSAGE_AUDIO: Starting playback for conversation ${content.conversationId}`
);
return { return {
...state, ...state,
active: active: {
payload === undefined currentTime: 0,
? undefined duration: undefined,
: { playing: true,
currentTime: 0, playbackRate,
duration: undefined, content,
playing: true, startPosition,
playbackRate, },
content,
startPosition,
},
}; };
} }
@ -446,8 +446,14 @@ export function reducer(
// insert a new voice note // insert a new voice note
if (voiceNote) { if (voiceNote) {
if (idx === -1) { if (idx === -1) {
log.info(
`audioPlayer/MESSAGES_ADDED: Adding voice note ${voiceNote.messageIdForLogging} to end of queue`
);
updatedQueue.push(voiceNote); updatedQueue.push(voiceNote);
} else { } else {
log.info(
`audioPlayer/MESSAGES_ADDED: Adding voice note ${voiceNote.messageIdForLogging} to queue at index ${idx}`
);
updatedQueue.splice(idx, 0, voiceNote); updatedQueue.splice(idx, 0, voiceNote);
} }
} }
@ -480,6 +486,9 @@ export function reducer(
} }
if (AudioPlayerContent.isDraft(content)) { if (AudioPlayerContent.isDraft(content)) {
log.info(
'audioPlayer/MESSAGE_AUDIO_ENDED: Voice note was draft, stopping playback'
);
return { return {
...state, ...state,
active: undefined, active: undefined,
@ -491,6 +500,9 @@ export function reducer(
const [nextVoiceNote, ...newQueue] = queue; const [nextVoiceNote, ...newQueue] = queue;
if (nextVoiceNote) { if (nextVoiceNote) {
log.info(
`audioPlayer/MESSAGE_AUDIO_ENDED: Starting next voice note ${nextVoiceNote.messageIdForLogging}`
);
return { return {
...state, ...state,
active: { active: {
@ -506,6 +518,7 @@ export function reducer(
}; };
} }
log.info('audioPlayer/MESSAGE_AUDIO_ENDED: Stopping playback');
return { return {
...state, ...state,
active: undefined, active: undefined,
@ -535,12 +548,18 @@ export function reducer(
const [next, ...rest] = content.queue; const [next, ...rest] = content.queue;
if (!next) { if (!next) {
log.info(
'audioPlayer/MESSAGE_DELETED: Removed currently-playing message, stopping playback'
);
return { return {
...state, ...state,
active: undefined, active: undefined,
}; };
} }
log.info(
'audioPlayer/MESSAGE_DELETED: Removed currently-playing message, moving to next in queue'
);
return { return {
...state, ...state,
active: { active: {
@ -558,6 +577,7 @@ export function reducer(
// just update the queue // just update the queue
const message = content.queue.find(el => el.id === id); const message = content.queue.find(el => el.id === id);
if (message) { if (message) {
log.info('audioPlayer/MESSAGE_DELETED: Removed message from the queue');
return { return {
...state, ...state,
active: { active: {
@ -611,6 +631,9 @@ export function reducer(
content.current.url === undefined && content.current.url === undefined &&
data.id data.id
) { ) {
log.info(
'audioPlayer/MESSAGE_CHANGED: Adding content url to current-playing message'
);
return { return {
...state, ...state,
active: { active: {
@ -629,6 +652,9 @@ export function reducer(
// if it's in the queue // if it's in the queue
const idx = content.queue.findIndex(v => v.id === id); const idx = content.queue.findIndex(v => v.id === id);
if (idx !== -1) { if (idx !== -1) {
log.info(
'audioPlayer/MESSAGE_CHANGED: Adding content url to message in queue'
);
const updatedQueue = [...content.queue]; const updatedQueue = [...content.queue];
updatedQueue[idx] = { updatedQueue[idx] = {
...updatedQueue[idx], ...updatedQueue[idx],

View file

@ -55,6 +55,8 @@ export async function sendReceipts({
return; return;
} }
log.info(`Starting receipt send of type ${type}`);
const receiptsBySenderId: Map<string, Array<Receipt>> = receipts.reduce( const receiptsBySenderId: Map<string, Array<Receipt>> = receipts.reduce(
(result, receipt) => { (result, receipt) => {
const { senderE164, senderUuid } = receipt; const { senderE164, senderUuid } = receipt;
@ -116,6 +118,8 @@ export async function sendReceipts({
return; return;
} }
log.info(`Sending receipt of type ${type} to ${sender.idForLogging()}`);
const sendOptions = await getSendOptions(sender.attributes); const sendOptions = await getSendOptions(sender.attributes);
const batches = chunk(receiptsForSender, CHUNK_SIZE); const batches = chunk(receiptsForSender, CHUNK_SIZE);