Remove NSCoding for InstalledSticker/StickerPack
This commit is contained in:
parent
939abc30e6
commit
482d48c167
@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@class DBReadTransaction;
|
||||
@class TSThread;
|
||||
|
||||
@interface OWSDisappearingMessagesConfiguration : BaseModel
|
||||
@interface OWSDisappearingMessagesConfiguration : BaseModel <NSCoding, NSCopying>
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder:coder];
|
||||
[self encodeIdsWithCoder:coder];
|
||||
[coder encodeObject:[self valueForKey:@"durationSeconds"] forKey:@"durationSeconds"];
|
||||
[coder encodeObject:[self valueForKey:@"enabled"] forKey:@"enabled"];
|
||||
[coder encodeObject:[self valueForKey:@"timerVersion"] forKey:@"timerVersion"];
|
||||
@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone
|
||||
{
|
||||
OWSDisappearingMessagesConfiguration *result = [super copyWithZone:zone];
|
||||
OWSDisappearingMessagesConfiguration *result = [self copyAndAssignIdsWithZone:zone];
|
||||
result->_durationSeconds = self.durationSeconds;
|
||||
result->_enabled = self.enabled;
|
||||
result->_timerVersion = self.timerVersion;
|
||||
|
||||
@ -33,7 +33,7 @@ typedef NS_CLOSED_ENUM(NSUInteger, TSThreadStoryViewMode) {
|
||||
/**
|
||||
* TSThread is the superclass of TSContactThread, TSGroupThread, and TSPrivateStoryThread
|
||||
*/
|
||||
@interface TSThread : BaseModel
|
||||
@interface TSThread : BaseModel <NSCoding, NSCopying>
|
||||
|
||||
@property (nonatomic) TSThreadStoryViewMode storyViewMode;
|
||||
@property (nonatomic, nullable) NSNumber *lastSentStoryTimestamp;
|
||||
|
||||
@ -111,7 +111,7 @@ lastVisibleSortIdOnScreenPercentageObsolete:(double)lastVisibleSortIdOnScreenPer
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder:coder];
|
||||
[self encodeIdsWithCoder:coder];
|
||||
NSString *conversationColorNameObsolete = self.conversationColorNameObsolete;
|
||||
if (conversationColorNameObsolete != nil) {
|
||||
[coder encodeObject:conversationColorNameObsolete forKey:@"conversationColorNameObsolete"];
|
||||
@ -329,7 +329,7 @@ lastVisibleSortIdOnScreenPercentageObsolete:(double)lastVisibleSortIdOnScreenPer
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone
|
||||
{
|
||||
TSThread *result = [super copyWithZone:zone];
|
||||
TSThread *result = [self copyAndAssignIdsWithZone:zone];
|
||||
result->_conversationColorNameObsolete = self.conversationColorNameObsolete;
|
||||
result->_creationDate = self.creationDate;
|
||||
result->_editTargetTimestamp = self.editTargetTimestamp;
|
||||
|
||||
@ -35,7 +35,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface TSInteraction : BaseModel
|
||||
@interface TSInteraction : BaseModel <NSCoding, NSCopying>
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@ -127,7 +127,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder:coder];
|
||||
[self encodeIdsWithCoder:coder];
|
||||
[coder encodeObject:[self valueForKey:@"receivedAtTimestamp"] forKey:@"receivedAtTimestamp"];
|
||||
[coder encodeObject:[self valueForKey:@"sortId"] forKey:@"sortId"];
|
||||
[coder encodeObject:[self valueForKey:@"timestamp"] forKey:@"timestamp"];
|
||||
@ -206,7 +206,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone
|
||||
{
|
||||
TSInteraction *result = [super copyWithZone:zone];
|
||||
TSInteraction *result = [self copyAndAssignIdsWithZone:zone];
|
||||
result->_receivedAtTimestamp = self.receivedAtTimestamp;
|
||||
result->_sortId = self.sortId;
|
||||
result->_timestamp = self.timestamp;
|
||||
|
||||
@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DBReadTransaction;
|
||||
|
||||
@interface InstalledSticker : BaseModel
|
||||
@interface InstalledSticker : BaseModel <NSCopying>
|
||||
|
||||
@property (nonatomic, readonly) StickerInfo *info;
|
||||
@property (nonatomic, readonly, nullable) NSString *emojiString;
|
||||
@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
|
||||
- (instancetype)initWithUniqueId:(NSString *)uniqueId NS_UNAVAILABLE;
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId uniqueId:(NSString *)uniqueId NS_UNAVAILABLE;
|
||||
|
||||
|
||||
@ -10,35 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation InstalledSticker
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder:coder];
|
||||
NSString *contentType = self.contentType;
|
||||
if (contentType != nil) {
|
||||
[coder encodeObject:contentType forKey:@"contentType"];
|
||||
}
|
||||
NSString *emojiString = self.emojiString;
|
||||
if (emojiString != nil) {
|
||||
[coder encodeObject:emojiString forKey:@"emojiString"];
|
||||
}
|
||||
StickerInfo *info = self.info;
|
||||
if (info != nil) {
|
||||
[coder encodeObject:info forKey:@"info"];
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
self->_contentType = [coder decodeObjectOfClass:[NSString class] forKey:@"contentType"];
|
||||
self->_emojiString = [coder decodeObjectOfClass:[NSString class] forKey:@"emojiString"];
|
||||
self->_info = [coder decodeObjectOfClass:[StickerInfo class] forKey:@"info"];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
NSUInteger result = [super hash];
|
||||
@ -68,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone
|
||||
{
|
||||
InstalledSticker *result = [super copyWithZone:zone];
|
||||
InstalledSticker *result = [self copyAndAssignIdsWithZone:zone];
|
||||
result->_contentType = self.contentType;
|
||||
result->_emojiString = self.emojiString;
|
||||
result->_info = self.info;
|
||||
|
||||
@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface StickerPack : BaseModel
|
||||
@interface StickerPack : BaseModel <NSCopying>
|
||||
|
||||
@property (nonatomic, readonly) StickerPackInfo *info;
|
||||
|
||||
@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
|
||||
- (instancetype)initWithUniqueId:(NSString *)uniqueId NS_UNAVAILABLE;
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId uniqueId:(NSString *)uniqueId NS_UNAVAILABLE;
|
||||
|
||||
|
||||
@ -109,53 +109,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation StickerPack
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder:coder];
|
||||
NSString *author = self.author;
|
||||
if (author != nil) {
|
||||
[coder encodeObject:author forKey:@"author"];
|
||||
}
|
||||
StickerPackItem *cover = self.cover;
|
||||
if (cover != nil) {
|
||||
[coder encodeObject:cover forKey:@"cover"];
|
||||
}
|
||||
NSDate *dateCreated = self.dateCreated;
|
||||
if (dateCreated != nil) {
|
||||
[coder encodeObject:dateCreated forKey:@"dateCreated"];
|
||||
}
|
||||
StickerPackInfo *info = self.info;
|
||||
if (info != nil) {
|
||||
[coder encodeObject:info forKey:@"info"];
|
||||
}
|
||||
[coder encodeObject:[self valueForKey:@"isInstalled"] forKey:@"isInstalled"];
|
||||
NSArray *items = self.items;
|
||||
if (items != nil) {
|
||||
[coder encodeObject:items forKey:@"items"];
|
||||
}
|
||||
NSString *title = self.title;
|
||||
if (title != nil) {
|
||||
[coder encodeObject:title forKey:@"title"];
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
self->_author = [coder decodeObjectOfClass:[NSString class] forKey:@"author"];
|
||||
self->_cover = [coder decodeObjectOfClass:[StickerPackItem class] forKey:@"cover"];
|
||||
self->_dateCreated = [coder decodeObjectOfClass:[NSDate class] forKey:@"dateCreated"];
|
||||
self->_info = [coder decodeObjectOfClass:[StickerPackInfo class] forKey:@"info"];
|
||||
self->_isInstalled = [(NSNumber *)[coder decodeObjectOfClass:[NSNumber class] forKey:@"isInstalled"] boolValue];
|
||||
self->_items = [coder decodeObjectOfClasses:[NSSet setWithArray:@[ [NSArray class], [StickerPackItem class] ]]
|
||||
forKey:@"items"];
|
||||
self->_title = [coder decodeObjectOfClass:[NSString class] forKey:@"title"];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
NSUInteger result = [super hash];
|
||||
@ -201,7 +154,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone
|
||||
{
|
||||
StickerPack *result = [super copyWithZone:zone];
|
||||
StickerPack *result = [self copyAndAssignIdsWithZone:zone];
|
||||
result->_author = self.author;
|
||||
result->_cover = self.cover;
|
||||
result->_dateCreated = self.dateCreated;
|
||||
|
||||
@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// without an associated interaction.
|
||||
// * Interactions might be deleted, but we need to maintain records of
|
||||
// all payments.
|
||||
@interface TSPaymentModel : BaseModel
|
||||
@interface TSPaymentModel : BaseModel <NSCoding, NSCopying>
|
||||
|
||||
// Incoming, outgoing, etc.
|
||||
//
|
||||
|
||||
@ -95,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder:coder];
|
||||
[self encodeIdsWithCoder:coder];
|
||||
NSString *addressUuidString = self.addressUuidString;
|
||||
if (addressUuidString != nil) {
|
||||
[coder encodeObject:addressUuidString forKey:@"addressUuidString"];
|
||||
@ -237,7 +237,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone
|
||||
{
|
||||
TSPaymentModel *result = [super copyWithZone:zone];
|
||||
TSPaymentModel *result = [self copyAndAssignIdsWithZone:zone];
|
||||
result->_addressUuidString = self.addressUuidString;
|
||||
result->_createdTimestamp = self.createdTimestamp;
|
||||
result->_interactionUniqueId = self.interactionUniqueId;
|
||||
|
||||
@ -9,7 +9,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface BaseModel : TSYapDatabaseObject
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
#pragma mark -
|
||||
|
||||
// TODO: Rename and/or merge with BaseModel.
|
||||
@interface TSYapDatabaseObject : NSObject <NSCoding, NSCopying, SDSRecordDelegate>
|
||||
@interface TSYapDatabaseObject : NSObject <SDSRecordDelegate>
|
||||
|
||||
+ (NSString *)generateUniqueId;
|
||||
|
||||
@ -46,6 +46,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/// Encode the grdbId and uniqueId.
|
||||
- (void)encodeIdsWithCoder:(NSCoder *)coder;
|
||||
|
||||
/// Creates a copy and assigns the grdbId and uniqueId.
|
||||
- (id)copyAndAssignIdsWithZone:(nullable NSZone *)zone;
|
||||
|
||||
// These methods should only ever be called within a GRDB write transaction.
|
||||
- (void)clearRowId;
|
||||
// This method is used to facilitate a database object replacement. See:
|
||||
|
||||
@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
- (void)encodeIdsWithCoder:(NSCoder *)coder
|
||||
{
|
||||
NSNumber *grdbId = self.grdbId;
|
||||
if (grdbId != nil) {
|
||||
@ -117,7 +117,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone
|
||||
- (id)copyAndAssignIdsWithZone:(nullable NSZone *)zone
|
||||
{
|
||||
TSYapDatabaseObject *result = [[[self class] allocWithZone:zone] init];
|
||||
result->_grdbId = self.grdbId;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user