feat: updated hasOutdatedClient to track last user to send a legacy message

this makes the banner work properlly in closed groups
pull/2660/head
William Grant 3 years ago
parent 84dec94450
commit 93cb972514

@ -255,15 +255,14 @@ export class SessionConversation extends React.Component<Props, State> {
<SessionTheme> <SessionTheme>
<div className="conversation-header"> <div className="conversation-header">
<ConversationHeaderWithDetails /> <ConversationHeaderWithDetails />
{selectedConversation?.hasOutdatedClient && ( {selectedConversation?.hasOutdatedClient &&
<NoticeBanner selectedConversation.hasOutdatedClient.length > 0 && (
text={window.i18n('disappearingMessagesModeOutdated', [ <NoticeBanner
selectedConversation?.nickname || text={window.i18n('disappearingMessagesModeOutdated', [
selectedConversation?.displayNameInProfile || selectedConversation.hasOutdatedClient,
selectedConversation.id, ])}
])} />
/> )}
)}
</div> </div>
{isSelectedConvoInitialLoadingInProgress ? ( {isSelectedConvoInitialLoadingInProgress ? (
<ConvoLoadingSpinner /> <ConvoLoadingSpinner />

@ -35,7 +35,7 @@ export interface ConversationAttributes {
expireTimer: number; expireTimer: number;
lastDisappearingMessageChangeTimestamp: number; lastDisappearingMessageChangeTimestamp: number;
hasOutdatedClient: boolean; hasOutdatedClient?: string;
mentionedUs: boolean; mentionedUs: boolean;
unreadCount: number; unreadCount: number;
@ -96,7 +96,6 @@ export const fillConvoAttributesWithDefaults = (
expireTimer: 0, expireTimer: 0,
lastDisappearingMessageChangeTimestamp: 0, lastDisappearingMessageChangeTimestamp: 0,
hasOutdatedClient: false,
active_at: 0, active_at: 0,
lastMessageStatus: undefined, lastMessageStatus: undefined,

@ -134,7 +134,6 @@ export function formatRowOfConversation(row?: Record<string, any>): Conversation
convo.readCapability = Boolean(convo.readCapability); convo.readCapability = Boolean(convo.readCapability);
convo.writeCapability = Boolean(convo.writeCapability); convo.writeCapability = Boolean(convo.writeCapability);
convo.uploadCapability = Boolean(convo.uploadCapability); convo.uploadCapability = Boolean(convo.uploadCapability);
convo.hasOutdatedClient = Boolean(convo.hasOutdatedClient);
if (!convo.conversationIdOrigin) { if (!convo.conversationIdOrigin) {
convo.conversationIdOrigin = undefined; convo.conversationIdOrigin = undefined;

@ -1223,16 +1223,13 @@ function updateToSessionSchemaVersion30(currentVersion: number, db: BetterSqlite
`ALTER TABLE ${CONVERSATIONS_TABLE} ADD COLUMN lastDisappearingMessageChangeTimestamp INTEGER DEFAULT 0;` `ALTER TABLE ${CONVERSATIONS_TABLE} ADD COLUMN lastDisappearingMessageChangeTimestamp INTEGER DEFAULT 0;`
).run(); ).run();
db.prepare( db.prepare(`ALTER TABLE ${CONVERSATIONS_TABLE} ADD COLUMN hasOutdatedClient TEXT;`).run();
`ALTER TABLE ${CONVERSATIONS_TABLE} ADD COLUMN hasOutdatedClient BOOLEAN DEFAULT false;`
).run();
// same value in ts/util/releaseFeature.ts but we cannot import since window doesn't exist yet.
// TODO update to agreed value between platforms // TODO update to agreed value between platforms
const featureReleaseTimestamp = 1677574800000; // unix 28/02/2023 09:00 const disappearingMessagesV2ReleaseTimestamp = 1677488400000; // unix 27/02/2023 09:00
// support disppearing messages legacy mode until after the platform agreed timestamp // support disppearing messages legacy mode until after the platform agreed timestamp
if (Date.now() < featureReleaseTimestamp) { if (Date.now() < disappearingMessagesV2ReleaseTimestamp) {
db.prepare( db.prepare(
`UPDATE ${CONVERSATIONS_TABLE} SET `UPDATE ${CONVERSATIONS_TABLE} SET
expirationType = $expirationType expirationType = $expirationType

@ -561,7 +561,7 @@ function saveConversation(data: ConversationAttributes, instance?: BetterSqlite3
expirationType, expirationType,
expireTimer, expireTimer,
lastDisappearingMessageChangeTimestamp, lastDisappearingMessageChangeTimestamp,
hasOutdatedClient: toSqliteBoolean(hasOutdatedClient), hasOutdatedClient,
mentionedUs: toSqliteBoolean(mentionedUs), mentionedUs: toSqliteBoolean(mentionedUs),
unreadCount, unreadCount,
lastMessageStatus, lastMessageStatus,
@ -2356,7 +2356,6 @@ function fillWithTestData(numConvosToAdd: number, numMsgsToAdd: number) {
expirationType: 'off', expirationType: 'off',
expireTimer: 0, expireTimer: 0,
lastDisappearingMessageChangeTimestamp: 0, lastDisappearingMessageChangeTimestamp: 0,
hasOutdatedClient: false,
groupAdmins: [], groupAdmins: [],
groupModerators: [], groupModerators: [],
isApproved: false, isApproved: false,

@ -446,15 +446,22 @@ export async function innerHandleSwarmContentMessage(
if (isLegacyMessage) { if (isLegacyMessage) {
// trigger notice banner // trigger notice banner
if (!conversationModelForUIUpdate.get('hasOutdatedClient')) { const outdatedSender =
conversationModelForUIUpdate.set({ hasOutdatedClient: true }); senderConversationModel.get('nickname') ||
conversationModelForUIUpdate.commit(); senderConversationModel.get('displayNameInProfile') ||
} senderConversationModel.get('id');
} else {
if (conversationModelForUIUpdate.get('hasOutdatedClient')) { if (conversationModelForUIUpdate.get('hasOutdatedClient')) {
conversationModelForUIUpdate.set({ hasOutdatedClient: false }); conversationModelForUIUpdate.set({
conversationModelForUIUpdate.commit(); hasOutdatedClient:
conversationModelForUIUpdate.get('hasOutdatedClient') === outdatedSender
? outdatedSender
: undefined,
});
} else {
conversationModelForUIUpdate.set({ hasOutdatedClient: outdatedSender });
} }
conversationModelForUIUpdate.commit();
} }
await handleSwarmDataMessage( await handleSwarmDataMessage(

@ -262,7 +262,7 @@ export interface ReduxConversationType {
expirationType?: DisappearingMessageConversationType; expirationType?: DisappearingMessageConversationType;
expireTimer?: number; expireTimer?: number;
lastDisappearingMessageChangeTimestamp?: number; lastDisappearingMessageChangeTimestamp?: number;
hasOutdatedClient?: boolean; hasOutdatedClient?: string;
isTyping?: boolean; isTyping?: boolean;
isBlocked?: boolean; isBlocked?: boolean;
isKickedFromGroup?: boolean; isKickedFromGroup?: boolean;

Loading…
Cancel
Save