mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-05 18:38:54 +00:00
fix: extract product fixes from Detox PR and stabilize related E2E Move Saved, thread follow, bookmarks image_url, tables, search persist, create-channel retry, and sidebar padding onto their own branch so they can land or revert independently of the E2E harness. Also includes: - iOS search clear/Cancel overlap and resting margin fixes - Saved messages subscription distinctUntilChanged guards (no flicker) - Table horizontal inset derived from a single padding constant - Manual time entry commits on parse (not only blur/submit) - Presence sheet dismiss-before-status-update (Android Fabric crash) - Bounded keyboard dismiss on Android edge-to-edge only; iOS unbound - Create-channel retry leaves header button enabled on failure - E2E flakiness: Maestro attach_logs/subflows, bookmark Edit wait, status sheet timing, classification lock transport retries, apiCreatePost throws on network errors, flow-header contract in CI - Unit/integration coverage and CodeRabbit follow-ups for the above
83 lines
3.4 KiB
TypeScript
83 lines
3.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import urlParse from 'url-parse';
|
|
|
|
import {buildQueryString} from '@utils/helpers';
|
|
|
|
import type ClientBase from './base';
|
|
|
|
export interface ClientChannelBookmarksMix {
|
|
createChannelBookmark(channelId: string, bookmark: ChannelBookmark, connectionId?: string): Promise<ChannelBookmarkWithFileInfo>;
|
|
updateChannelBookmark(channelId: string, bookmark: ChannelBookmark, connectionId?: string): Promise<UpdateChannelBookmarkResponse>;
|
|
updateChannelBookmarkSortOrder(channelId: string, bookmarkId: string, newSortOrder: number, connectionId?: string): Promise<ChannelBookmarkWithFileInfo[]>;
|
|
deleteChannelBookmark(channelId: string, bookmarkId: string, connectionId?: string): Promise<ChannelBookmarkWithFileInfo>;
|
|
getChannelBookmarksForChannel(channelId: string, since: number, groupLabel?: RequestGroupLabel): Promise<ChannelBookmarkWithFileInfo[]>;
|
|
}
|
|
|
|
const ClientChannelBookmarks = <TBase extends Constructor<ClientBase>>(superclass: TBase) => class extends superclass {
|
|
createChannelBookmark = async (channelId: string, bookmark: ChannelBookmark, connectionId = '') => {
|
|
const parsedImageUrl = urlParse(bookmark.image_url ?? '');
|
|
const hasValidImageUrl = (parsedImageUrl.protocol === 'http:' || parsedImageUrl.protocol === 'https:') && Boolean(parsedImageUrl.host);
|
|
const body = {
|
|
channel_id: channelId,
|
|
display_name: bookmark.display_name,
|
|
type: bookmark.type,
|
|
...(bookmark.file_id ? {file_id: bookmark.file_id} : {}),
|
|
...(bookmark.link_url ? {link_url: bookmark.link_url} : {}),
|
|
...(hasValidImageUrl ? {image_url: bookmark.image_url} : {}),
|
|
...(bookmark.emoji ? {emoji: bookmark.emoji} : {}),
|
|
};
|
|
|
|
return this.doFetch(
|
|
this.getChannelBookmarksRoute(channelId),
|
|
{
|
|
method: 'post',
|
|
body,
|
|
headers: {'Connection-Id': connectionId},
|
|
},
|
|
);
|
|
};
|
|
|
|
updateChannelBookmark(channelId: string, bookmark: ChannelBookmark, connectionId?: string) {
|
|
return this.doFetch(
|
|
this.getChannelBookmarkRoute(channelId, bookmark.id),
|
|
{
|
|
method: 'patch',
|
|
body: bookmark,
|
|
headers: {'Connection-Id': connectionId},
|
|
},
|
|
);
|
|
}
|
|
|
|
updateChannelBookmarkSortOrder(channelId: string, bookmarkId: string, newSortOrder: number, connectionId?: string) {
|
|
return this.doFetch(
|
|
`${this.getChannelBookmarkRoute(channelId, bookmarkId)}/sort_order`,
|
|
{
|
|
method: 'post',
|
|
body: newSortOrder,
|
|
headers: {'Connection-Id': connectionId},
|
|
},
|
|
);
|
|
}
|
|
|
|
deleteChannelBookmark(channelId: string, bookmarkId: string, connectionId?: string) {
|
|
return this.doFetch(
|
|
this.getChannelBookmarkRoute(channelId, bookmarkId),
|
|
{
|
|
method: 'delete',
|
|
headers: {'Connection-Id': connectionId},
|
|
},
|
|
);
|
|
}
|
|
|
|
getChannelBookmarksForChannel(channelId: string, since: number, groupLabel?: RequestGroupLabel) {
|
|
return this.doFetch(
|
|
`${this.getChannelBookmarksRoute(channelId)}${buildQueryString({bookmarks_since: since})}`,
|
|
{method: 'get', groupLabel},
|
|
);
|
|
}
|
|
};
|
|
|
|
export default ClientChannelBookmarks;
|