mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 08:13:37 +01:00
Fix megaphone check for dontShowBeforeEpochMs
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
@@ -194,6 +194,7 @@ export function isMegaphoneShowable(
|
||||
): megaphone is VisibleRemoteMegaphoneType {
|
||||
const nowMs = Date.now();
|
||||
const {
|
||||
dontShowBeforeEpochMs,
|
||||
dontShowAfterEpochMs,
|
||||
isFinished,
|
||||
snoozedAt,
|
||||
@@ -201,7 +202,11 @@ export function isMegaphoneShowable(
|
||||
secondaryCtaId,
|
||||
} = megaphone;
|
||||
|
||||
if (isFinished || nowMs > dontShowAfterEpochMs) {
|
||||
if (
|
||||
isFinished ||
|
||||
nowMs < dontShowBeforeEpochMs ||
|
||||
nowMs > dontShowAfterEpochMs
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,13 @@ describe('megaphone service', () => {
|
||||
assert.strictEqual(isMegaphoneShowable(megaphone), true);
|
||||
});
|
||||
|
||||
it('handles megaphone with dontShowBeforeEpochMs in the future', () => {
|
||||
const megaphone = getMegaphone({
|
||||
dontShowBeforeEpochMs: Date.now() + 1 * DAY,
|
||||
});
|
||||
assert.strictEqual(isMegaphoneShowable(megaphone), false);
|
||||
});
|
||||
|
||||
it('handles megaphone expired past dontShowAfterEpochMs', () => {
|
||||
const megaphone = getMegaphone({
|
||||
dontShowAfterEpochMs: Date.now() - 1 * DAY,
|
||||
|
||||
Reference in New Issue
Block a user