upd: show menu to update or remove background and banner if set

Closes #298
This commit is contained in:
Marie 2024-01-02 14:00:10 +01:00
parent 1f0c6adc68
commit 5659ed24f9
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
6 changed files with 1228 additions and 50 deletions

View file

@ -251,6 +251,10 @@ function changeAvatar(ev) {
}
function changeBanner(ev) {
if ($i.bannerId) {
os.popupMenu([{
text: 'Update Banner',
action: async () => {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner).then(async (file) => {
let originalOrCropped = file;
@ -273,9 +277,48 @@ function changeBanner(ev) {
$i.bannerId = i.bannerId;
$i.bannerUrl = i.bannerUrl;
});
},
}, {
text: 'Remove Banner',
action: async () => {
const i = await os.apiWithDialog('i/update', {
bannerId: null,
});
$i.bannerId = i.bannerId;
$i.bannerUrl = i.bannerUrl;
},
}], ev.currentTarget ?? ev.target);
} else {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner).then(async (file) => {
let originalOrCropped = file;
const { canceled } = await os.confirm({
type: 'question',
text: i18n.t('cropImageAsk'),
okText: i18n.ts.cropYes,
cancelText: i18n.ts.cropNo,
});
if (!canceled) {
originalOrCropped = await os.cropImage(file, {
aspectRatio: 2,
});
}
const i = await os.apiWithDialog('i/update', {
bannerId: originalOrCropped.id,
});
$i.bannerId = i.bannerId;
$i.bannerUrl = i.bannerUrl;
});
}
}
function changeBackground(ev) {
if ($i.backgroundId) {
os.popupMenu([{
text: 'Update Background',
action: async () => {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.background).then(async (file) => {
let originalOrCropped = file;
@ -298,6 +341,41 @@ function changeBackground(ev) {
$i.backgroundId = i.backgroundId;
$i.backgroundUrl = i.backgroundUrl;
});
},
}, {
text: 'Remove Banner',
action: async () => {
const i = await os.apiWithDialog('i/update', {
backgroundId: null,
});
$i.backgroundId = i.backgroundId;
$i.backgroundUrl = i.backgroundUrl;
},
}], ev.currentTarget ?? ev.target);
} else {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.background).then(async (file) => {
let originalOrCropped = file;
const { canceled } = await os.confirm({
type: 'question',
text: i18n.t('cropImageAsk'),
okText: i18n.ts.cropYes,
cancelText: i18n.ts.cropNo,
});
if (!canceled) {
originalOrCropped = await os.cropImage(file, {
aspectRatio: 1,
});
}
const i = await os.apiWithDialog('i/update', {
backgroundId: originalOrCropped.id,
});
$i.backgroundId = i.backgroundId;
$i.backgroundUrl = i.backgroundUrl;
});
}
}
const headerActions = computed(() => []);

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.494Z
* version: 2023.12.0.beta3
* generatedAt: 2024-01-02T12:58:03.874Z
*/
import type { SwitchCaseResponseType } from '../api.js';
@ -33,7 +33,6 @@ declare module '../api.js' {
/**
* No description provided.
*
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
* **Credential required**: *No*
*/
request<E extends 'admin/accounts/create', P extends Endpoints[E]['req']>(
@ -692,6 +691,50 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:admin:nsfw-user*
*/
request<E extends 'admin/nsfw-user', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:admin:unnsfw-user*
*/
request<E extends 'admin/unnsfw-user', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:admin:silence-user*
*/
request<E extends 'admin/silence-user', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:admin:unsilence-user*
*/
request<E extends 'admin/unsilence-user', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -703,6 +746,17 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:admin:approve-user*
*/
request<E extends 'admin/approve-user', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -2202,6 +2256,18 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
* **Credential required**: *Yes*
*/
request<E extends 'i/export-data', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -2343,6 +2409,18 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
* **Credential required**: *Yes*
*/
request<E extends 'i/import-notes', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -2479,6 +2557,17 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *read:account*
*/
request<E extends 'i/registry/get-unsecure', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -2958,6 +3047,17 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *No*
*/
request<E extends 'notes/bubble-timeline', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -3046,6 +3146,17 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:reactions*
*/
request<E extends 'notes/like', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -3178,6 +3289,28 @@ declare module '../api.js' {
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:notes*
*/
request<E extends 'notes/edit', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *No*
*/
request<E extends 'notes/versions', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
@ -3974,5 +4107,16 @@ declare module '../api.js' {
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* Get Sharkey GH Sponsors
*
* **Credential required**: *No*
*/
request<E extends 'sponsors', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
}
}

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.491Z
* version: 2023.12.0.beta3
* generatedAt: 2024-01-02T12:58:03.868Z
*/
import type {
@ -86,7 +86,12 @@ import type {
AdminShowUserResponse,
AdminShowUsersRequest,
AdminShowUsersResponse,
AdminNsfwUserRequest,
AdminUnnsfwUserRequest,
AdminSilenceUserRequest,
AdminUnsilenceUserRequest,
AdminSuspendUserRequest,
AdminApproveUserRequest,
AdminUnsuspendUserRequest,
AdminUpdateMetaRequest,
AdminDeleteAccountRequest,
@ -314,6 +319,7 @@ import type {
IGalleryPostsResponse,
IImportBlockingRequest,
IImportFollowingRequest,
IImportNotesRequest,
IImportMutingRequest,
IImportUserListsRequest,
IImportAntennasRequest,
@ -331,6 +337,7 @@ import type {
IRegenerateTokenRequest,
IRegistryGetAllRequest,
IRegistryGetAllResponse,
IRegistryGetUnsecureRequest,
IRegistryGetDetailRequest,
IRegistryGetDetailResponse,
IRegistryGetRequest,
@ -398,6 +405,8 @@ import type {
NotesFeaturedResponse,
NotesGlobalTimelineRequest,
NotesGlobalTimelineResponse,
NotesBubbleTimelineRequest,
NotesBubbleTimelineResponse,
NotesHybridTimelineRequest,
NotesHybridTimelineResponse,
NotesLocalTimelineRequest,
@ -411,6 +420,7 @@ import type {
NotesReactionsResponse,
NotesReactionsCreateRequest,
NotesReactionsDeleteRequest,
NotesLikeRequest,
NotesRenotesRequest,
NotesRenotesResponse,
NotesRepliesRequest,
@ -432,6 +442,10 @@ import type {
NotesUnrenoteRequest,
NotesUserListTimelineRequest,
NotesUserListTimelineResponse,
NotesEditRequest,
NotesEditResponse,
NotesVersionsRequest,
NotesVersionsResponse,
NotificationsCreateRequest,
PagePushRequest,
PagesCreateRequest,
@ -540,6 +554,7 @@ import type {
FetchExternalResourcesRequest,
FetchExternalResourcesResponse,
RetentionResponse,
SponsorsRequest,
} from './entities.js';
export type Endpoints = {
@ -605,7 +620,12 @@ export type Endpoints = {
'admin/show-moderation-logs': { req: AdminShowModerationLogsRequest; res: AdminShowModerationLogsResponse };
'admin/show-user': { req: AdminShowUserRequest; res: AdminShowUserResponse };
'admin/show-users': { req: AdminShowUsersRequest; res: AdminShowUsersResponse };
'admin/nsfw-user': { req: AdminNsfwUserRequest; res: EmptyResponse };
'admin/unnsfw-user': { req: AdminUnnsfwUserRequest; res: EmptyResponse };
'admin/silence-user': { req: AdminSilenceUserRequest; res: EmptyResponse };
'admin/unsilence-user': { req: AdminUnsilenceUserRequest; res: EmptyResponse };
'admin/suspend-user': { req: AdminSuspendUserRequest; res: EmptyResponse };
'admin/approve-user': { req: AdminApproveUserRequest; res: EmptyResponse };
'admin/unsuspend-user': { req: AdminUnsuspendUserRequest; res: EmptyResponse };
'admin/update-meta': { req: AdminUpdateMetaRequest; res: EmptyResponse };
'admin/delete-account': { req: AdminDeleteAccountRequest; res: AdminDeleteAccountResponse };
@ -741,6 +761,7 @@ export type Endpoints = {
'i/claim-achievement': { req: IClaimAchievementRequest; res: EmptyResponse };
'i/change-password': { req: IChangePasswordRequest; res: EmptyResponse };
'i/delete-account': { req: IDeleteAccountRequest; res: EmptyResponse };
'i/export-data': { req: EmptyRequest; res: EmptyResponse };
'i/export-blocking': { req: EmptyRequest; res: EmptyResponse };
'i/export-following': { req: IExportFollowingRequest; res: EmptyResponse };
'i/export-mute': { req: EmptyRequest; res: EmptyResponse };
@ -753,6 +774,7 @@ export type Endpoints = {
'i/gallery/posts': { req: IGalleryPostsRequest; res: IGalleryPostsResponse };
'i/import-blocking': { req: IImportBlockingRequest; res: EmptyResponse };
'i/import-following': { req: IImportFollowingRequest; res: EmptyResponse };
'i/import-notes': { req: IImportNotesRequest; res: EmptyResponse };
'i/import-muting': { req: IImportMutingRequest; res: EmptyResponse };
'i/import-user-lists': { req: IImportUserListsRequest; res: EmptyResponse };
'i/import-antennas': { req: IImportAntennasRequest; res: EmptyResponse };
@ -765,6 +787,7 @@ export type Endpoints = {
'i/read-announcement': { req: IReadAnnouncementRequest; res: EmptyResponse };
'i/regenerate-token': { req: IRegenerateTokenRequest; res: EmptyResponse };
'i/registry/get-all': { req: IRegistryGetAllRequest; res: IRegistryGetAllResponse };
'i/registry/get-unsecure': { req: IRegistryGetUnsecureRequest; res: EmptyResponse };
'i/registry/get-detail': { req: IRegistryGetDetailRequest; res: IRegistryGetDetailResponse };
'i/registry/get': { req: IRegistryGetRequest; res: IRegistryGetResponse };
'i/registry/keys-with-type': { req: IRegistryKeysWithTypeRequest; res: IRegistryKeysWithTypeResponse };
@ -808,6 +831,7 @@ export type Endpoints = {
'notes/favorites/delete': { req: NotesFavoritesDeleteRequest; res: EmptyResponse };
'notes/featured': { req: NotesFeaturedRequest; res: NotesFeaturedResponse };
'notes/global-timeline': { req: NotesGlobalTimelineRequest; res: NotesGlobalTimelineResponse };
'notes/bubble-timeline': { req: NotesBubbleTimelineRequest; res: NotesBubbleTimelineResponse };
'notes/hybrid-timeline': { req: NotesHybridTimelineRequest; res: NotesHybridTimelineResponse };
'notes/local-timeline': { req: NotesLocalTimelineRequest; res: NotesLocalTimelineResponse };
'notes/mentions': { req: NotesMentionsRequest; res: NotesMentionsResponse };
@ -816,6 +840,7 @@ export type Endpoints = {
'notes/reactions': { req: NotesReactionsRequest; res: NotesReactionsResponse };
'notes/reactions/create': { req: NotesReactionsCreateRequest; res: EmptyResponse };
'notes/reactions/delete': { req: NotesReactionsDeleteRequest; res: EmptyResponse };
'notes/like': { req: NotesLikeRequest; res: EmptyResponse };
'notes/renotes': { req: NotesRenotesRequest; res: NotesRenotesResponse };
'notes/replies': { req: NotesRepliesRequest; res: NotesRepliesResponse };
'notes/search-by-tag': { req: NotesSearchByTagRequest; res: NotesSearchByTagResponse };
@ -828,6 +853,8 @@ export type Endpoints = {
'notes/translate': { req: NotesTranslateRequest; res: NotesTranslateResponse };
'notes/unrenote': { req: NotesUnrenoteRequest; res: EmptyResponse };
'notes/user-list-timeline': { req: NotesUserListTimelineRequest; res: NotesUserListTimelineResponse };
'notes/edit': { req: NotesEditRequest; res: NotesEditResponse };
'notes/versions': { req: NotesVersionsRequest; res: NotesVersionsResponse };
'notifications/create': { req: NotificationsCreateRequest; res: EmptyResponse };
'notifications/mark-all-as-read': { req: EmptyRequest; res: EmptyResponse };
'notifications/test-notification': { req: EmptyRequest; res: EmptyResponse };
@ -900,4 +927,5 @@ export type Endpoints = {
'fetch-rss': { req: FetchRssRequest; res: FetchRssResponse };
'fetch-external-resources': { req: FetchExternalResourcesRequest; res: FetchExternalResourcesResponse };
'retention': { req: EmptyRequest; res: RetentionResponse };
'sponsors': { req: SponsorsRequest; res: EmptyResponse };
}

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.489Z
* version: 2023.12.0.beta3
* generatedAt: 2024-01-02T12:58:03.865Z
*/
import { operations } from './types.js';
@ -88,7 +88,12 @@ export type AdminShowUserRequest = operations['admin/show-user']['requestBody'][
export type AdminShowUserResponse = operations['admin/show-user']['responses']['200']['content']['application/json'];
export type AdminShowUsersRequest = operations['admin/show-users']['requestBody']['content']['application/json'];
export type AdminShowUsersResponse = operations['admin/show-users']['responses']['200']['content']['application/json'];
export type AdminNsfwUserRequest = operations['admin/nsfw-user']['requestBody']['content']['application/json'];
export type AdminUnnsfwUserRequest = operations['admin/unnsfw-user']['requestBody']['content']['application/json'];
export type AdminSilenceUserRequest = operations['admin/silence-user']['requestBody']['content']['application/json'];
export type AdminUnsilenceUserRequest = operations['admin/unsilence-user']['requestBody']['content']['application/json'];
export type AdminSuspendUserRequest = operations['admin/suspend-user']['requestBody']['content']['application/json'];
export type AdminApproveUserRequest = operations['admin/approve-user']['requestBody']['content']['application/json'];
export type AdminUnsuspendUserRequest = operations['admin/unsuspend-user']['requestBody']['content']['application/json'];
export type AdminUpdateMetaRequest = operations['admin/update-meta']['requestBody']['content']['application/json'];
export type AdminDeleteAccountRequest = operations['admin/delete-account']['requestBody']['content']['application/json'];
@ -316,6 +321,7 @@ export type IGalleryPostsRequest = operations['i/gallery/posts']['requestBody'][
export type IGalleryPostsResponse = operations['i/gallery/posts']['responses']['200']['content']['application/json'];
export type IImportBlockingRequest = operations['i/import-blocking']['requestBody']['content']['application/json'];
export type IImportFollowingRequest = operations['i/import-following']['requestBody']['content']['application/json'];
export type IImportNotesRequest = operations['i/import-notes']['requestBody']['content']['application/json'];
export type IImportMutingRequest = operations['i/import-muting']['requestBody']['content']['application/json'];
export type IImportUserListsRequest = operations['i/import-user-lists']['requestBody']['content']['application/json'];
export type IImportAntennasRequest = operations['i/import-antennas']['requestBody']['content']['application/json'];
@ -333,6 +339,7 @@ export type IReadAnnouncementRequest = operations['i/read-announcement']['reques
export type IRegenerateTokenRequest = operations['i/regenerate-token']['requestBody']['content']['application/json'];
export type IRegistryGetAllRequest = operations['i/registry/get-all']['requestBody']['content']['application/json'];
export type IRegistryGetAllResponse = operations['i/registry/get-all']['responses']['200']['content']['application/json'];
export type IRegistryGetUnsecureRequest = operations['i/registry/get-unsecure']['requestBody']['content']['application/json'];
export type IRegistryGetDetailRequest = operations['i/registry/get-detail']['requestBody']['content']['application/json'];
export type IRegistryGetDetailResponse = operations['i/registry/get-detail']['responses']['200']['content']['application/json'];
export type IRegistryGetRequest = operations['i/registry/get']['requestBody']['content']['application/json'];
@ -400,6 +407,8 @@ export type NotesFeaturedRequest = operations['notes/featured']['requestBody']['
export type NotesFeaturedResponse = operations['notes/featured']['responses']['200']['content']['application/json'];
export type NotesGlobalTimelineRequest = operations['notes/global-timeline']['requestBody']['content']['application/json'];
export type NotesGlobalTimelineResponse = operations['notes/global-timeline']['responses']['200']['content']['application/json'];
export type NotesBubbleTimelineRequest = operations['notes/bubble-timeline']['requestBody']['content']['application/json'];
export type NotesBubbleTimelineResponse = operations['notes/bubble-timeline']['responses']['200']['content']['application/json'];
export type NotesHybridTimelineRequest = operations['notes/hybrid-timeline']['requestBody']['content']['application/json'];
export type NotesHybridTimelineResponse = operations['notes/hybrid-timeline']['responses']['200']['content']['application/json'];
export type NotesLocalTimelineRequest = operations['notes/local-timeline']['requestBody']['content']['application/json'];
@ -413,6 +422,7 @@ export type NotesReactionsRequest = operations['notes/reactions']['requestBody']
export type NotesReactionsResponse = operations['notes/reactions']['responses']['200']['content']['application/json'];
export type NotesReactionsCreateRequest = operations['notes/reactions/create']['requestBody']['content']['application/json'];
export type NotesReactionsDeleteRequest = operations['notes/reactions/delete']['requestBody']['content']['application/json'];
export type NotesLikeRequest = operations['notes/like']['requestBody']['content']['application/json'];
export type NotesRenotesRequest = operations['notes/renotes']['requestBody']['content']['application/json'];
export type NotesRenotesResponse = operations['notes/renotes']['responses']['200']['content']['application/json'];
export type NotesRepliesRequest = operations['notes/replies']['requestBody']['content']['application/json'];
@ -434,6 +444,10 @@ export type NotesTranslateResponse = operations['notes/translate']['responses'][
export type NotesUnrenoteRequest = operations['notes/unrenote']['requestBody']['content']['application/json'];
export type NotesUserListTimelineRequest = operations['notes/user-list-timeline']['requestBody']['content']['application/json'];
export type NotesUserListTimelineResponse = operations['notes/user-list-timeline']['responses']['200']['content']['application/json'];
export type NotesEditRequest = operations['notes/edit']['requestBody']['content']['application/json'];
export type NotesEditResponse = operations['notes/edit']['responses']['200']['content']['application/json'];
export type NotesVersionsRequest = operations['notes/versions']['requestBody']['content']['application/json'];
export type NotesVersionsResponse = operations['notes/versions']['responses']['200']['content']['application/json'];
export type NotificationsCreateRequest = operations['notifications/create']['requestBody']['content']['application/json'];
export type PagePushRequest = operations['page-push']['requestBody']['content']['application/json'];
export type PagesCreateRequest = operations['pages/create']['requestBody']['content']['application/json'];
@ -542,3 +556,4 @@ export type FetchRssResponse = operations['fetch-rss']['responses']['200']['cont
export type FetchExternalResourcesRequest = operations['fetch-external-resources']['requestBody']['content']['application/json'];
export type FetchExternalResourcesResponse = operations['fetch-external-resources']['responses']['200']['content']['application/json'];
export type RetentionResponse = operations['retention']['responses']['200']['content']['application/json'];
export type SponsorsRequest = operations['sponsors']['requestBody']['content']['application/json'];

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.485Z
* version: 2023.12.0.beta3
* generatedAt: 2024-01-02T12:58:03.862Z
*/
import { components } from './types.js';

File diff suppressed because it is too large Load diff