Skip to content

Commit

Permalink
0.19 Non-Breaking Compatibility and Deprecation Comments (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews authored Dec 5, 2023
1 parent e5dbbda commit 77b9cd0
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Mlem/API/Models/APIErrorResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import Foundation

// TODO: 0.19 support add all the error types (https://github.com/LemmyNet/lemmy-js-client/blob/b2edfeeaffd189a51150362cc8ead03c65ee2652/src/types/LemmyErrorType.ts)

struct APIErrorResponse: Decodable {
let error: String
}
Expand Down
2 changes: 2 additions & 0 deletions Mlem/API/Models/Comments/APICommentReplyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct APICommentReplyView: Decodable {
let recipient: APIPerson
let counts: APICommentAggregates
let creatorBannedFromCommunity: Bool
let creatorIsModerator: Bool? // TODO: 0.18 deprecation make this field non-optional
let creatorIsAdmin: Bool? // TODO: 0.18 deprecation make this field non-optional
let subscribed: APISubscribedStatus
let saved: Bool
let creatorBlocked: Bool
Expand Down
2 changes: 2 additions & 0 deletions Mlem/API/Models/Comments/APICommentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct APICommentView: Decodable, APIContentViewProtocol {
let community: APICommunity
let counts: APICommentAggregates
let creatorBannedFromCommunity: Bool
let creatorIsModerator: Bool? // TODO: 0.18 deprecation make this field non-optional
let creatorIsAdmin: Bool? // TODO: 0.18 deprecation make this field non-optional
let subscribed: APISubscribedStatus
let saved: Bool
let creatorBlocked: Bool
Expand Down
2 changes: 1 addition & 1 deletion Mlem/API/Models/Person/APIPerson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct APIPerson: Decodable, Identifiable, Hashable {
let deleted: Bool
let sharedInboxUrl: String?
let matrixUserId: String?
let admin: Bool? // this is no longer returned on beehaw...
let admin: Bool? // TODO: 0.18 deprecation remove this field
let botAccount: Bool
let banExpires: Date?
let instanceId: Int
Expand Down
2 changes: 2 additions & 0 deletions Mlem/API/Models/Person/APIPersonMentionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct APIPersonMentionView: Decodable {
let recipient: APIPerson
let counts: APICommentAggregates
let creatorBannedFromCommunity: Bool
let creatorIsModerator: Bool? // TODO: 0.18 deprecation make this field non-optional
let creatorIsAdmin: Bool? // TODO: 0.18 deprecation make this field non-optional
let subscribed: APISubscribedStatus
let saved: Bool
let creatorBlocked: Bool
Expand Down
2 changes: 1 addition & 1 deletion Mlem/API/Models/Person/APIPersonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import Foundation
struct APIPersonView: Decodable {
let person: APIPerson
let counts: APIPersonAggregates
let isAdmin: Bool?
let isAdmin: Bool? // TODO: 0.18 deprecation make this field non-optional
}
4 changes: 2 additions & 2 deletions Mlem/API/Models/Posts/APIPostView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ struct APIPostView: Decodable, APIContentViewProtocol {
let creator: APIPerson
let community: APICommunity
let creatorBannedFromCommunity: Bool
// TODO: 0.18 Deprecation make this field non-optional
let creatorIsModerator: Bool?
let creatorIsModerator: Bool? // TODO: 0.18 deprecation make this field non-optional
let creatorIsAdmin: Bool? // TODO: 0.18 deprecation make this field non-optional
var counts: APIPostAggregates
let subscribed: APISubscribedStatus
let saved: Bool
Expand Down
1 change: 1 addition & 0 deletions Mlem/API/Models/Site/APILocalSiteRateLimit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ struct APILocalSiteRateLimit: Decodable {
let searchPerSecond: Int
let published: Date
let updated: Date?
// TODO: 0.19 support add import_user_settings and import_user_settings_per_second
}
4 changes: 2 additions & 2 deletions Mlem/API/Requests/Comment/CreateComment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CreateCommentRequest: APIPostRequest {
let post_id: Int
let parent_id: Int?
let language_id: Int?
let form_id: String?
let form_id: String? // TODO: 0.18 deprecation remove this field
let auth: String
}

Expand All @@ -47,5 +47,5 @@ struct CreateCommentRequest: APIPostRequest {
struct CommentResponse: Decodable {
let commentView: APICommentView
let recipientIds: [Int]
let formId: String?
let formId: String? // TODO: 0.18 deprecation remove this field
}
1 change: 1 addition & 0 deletions Mlem/API/Requests/Comment/GetComments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct GetCommentsRequest: APIGetRequest {
communityName: String?,
parentId: Int?,
savedOnly: Bool?
// TODO: 0.19 support add liked_only and disliked_only query params
) throws {
self.instanceURL = try session.instanceUrl
var queryItems: [URLQueryItem] = [
Expand Down
5 changes: 3 additions & 2 deletions Mlem/API/Requests/Messages/GetPrivateMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ struct GetPrivateMessagesRequest: APIGetRequest {
page: Int?,
limit: Int?,
unreadOnly: Bool
// TODO: 0.19 support add creator_id? field
) throws {
self.instanceURL = try session.instanceUrl
self.queryItems = [
.init(name: "auth", value: try session.token),
self.queryItems = try [
.init(name: "auth", value: session.token),
.init(name: "page", value: page?.description),
.init(name: "limit", value: limit?.description),
.init(name: "unread_only", value: String(unreadOnly))
Expand Down
1 change: 1 addition & 0 deletions Mlem/API/Requests/Post/GetPosts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct GetPostsRequest: APIGetRequest {
limit: Int? = nil,
savedOnly: Bool? = nil,
communityName: String? = nil
// TODO: 0.19 support add liked_only and disliked_only fields
) throws {
self.instanceURL = try session.instanceUrl
var queryItems: [URLQueryItem] = [
Expand Down
1 change: 1 addition & 0 deletions Mlem/API/Requests/Post/MarkPostRead.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct MarkPostReadRequest: APIPostRequest {
let post_id: Int
let read: Bool
let auth: String
// TODO: 0.19 support add post_ids? field
}

init(
Expand Down
3 changes: 2 additions & 1 deletion Mlem/API/Requests/User/DeleteUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation

// TODO: 0.18 deprecation remove this struct
struct LegacyDeleteAccountRequest: APIPostRequest {
typealias Response = DeleteAccountResponse

Expand All @@ -33,7 +34,7 @@ struct LegacyDeleteAccountRequest: APIPostRequest {
}

struct DeleteAccountRequest: APIPostRequest {
typealias Response = DeleteAccountResponse
typealias Response = SuccessResponse

let instanceURL: URL
let path = "user/delete_account"
Expand Down
2 changes: 1 addition & 1 deletion Mlem/Enums/Settings/CommentSortType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

// lemmy_db_schema::CommentSortType
// TODO: this is not accurate to the Lemmy enum, active -> hot, and "old" is missing
// TODO: this is not accurate to the Lemmy enum, "controversial" is missing
enum CommentSortType: String, Codable, CaseIterable, Identifiable {
case top, hot, new, old

Expand Down
1 change: 1 addition & 0 deletions Mlem/Models/PictrsImageModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct PictrsImageModel {
case uploaded(file: PictrsFile?)
case failed(String?)
}

var image: Image?
var state: UploadState = .waiting
}
4 changes: 4 additions & 0 deletions Mlem/Repositories/InboxRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class InboxRepository {
recipient: reply.recipient,
counts: updatedCommentView.counts,
creatorBannedFromCommunity: updatedCommentView.creatorBannedFromCommunity,
creatorIsModerator: false,
creatorIsAdmin: false,
subscribed: updatedCommentView.subscribed,
saved: updatedCommentView.saved,
creatorBlocked: updatedCommentView.creatorBlocked,
Expand Down Expand Up @@ -96,6 +98,8 @@ class InboxRepository {
recipient: mention.recipient,
counts: updatedCommentView.counts,
creatorBannedFromCommunity: updatedCommentView.creatorBannedFromCommunity,
creatorIsModerator: false,
creatorIsAdmin: false,
subscribed: updatedCommentView.subscribed,
saved: updatedCommentView.saved,
creatorBlocked: updatedCommentView.creatorBlocked,
Expand Down
1 change: 1 addition & 0 deletions Mlem/Views/Shared/Links/User/UserLabelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ struct UserLinkViewPreview: PreviewProvider {
community: community,
creatorBannedFromCommunity: false,
creatorIsModerator: false,
creatorIsAdmin: false,
counts: postVotes,
subscribed: .notSubscribed,
saved: false,
Expand Down
1 change: 1 addition & 0 deletions Mlem/Views/Tabs/Profile/User View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ struct UserViewPreview: PreviewProvider {
community: community,
creatorBannedFromCommunity: false,
creatorIsModerator: false,
creatorIsAdmin: false,
counts: postVotes,
subscribed: .notSubscribed,
saved: false,
Expand Down

0 comments on commit 77b9cd0

Please sign in to comment.