Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed May 22, 2024
1 parent f70275b commit 40d6a58
Showing 1 changed file with 80 additions and 86 deletions.
166 changes: 80 additions & 86 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,65 +818,63 @@ export function getRenoteMenu(props: {
}));
},
});
}

// Add visibility section
if (
defaultStore.state.renoteVisibilitySelection &&
!['followers', 'specified'].includes(appearNote.visibility) &&
(!appearNote.channel || appearNote.channel.allowRenoteToExternal)
) {
// renote to public
if (appearNote.visibility === 'public') {
visibilityRenoteItems.push({
text: `${i18n.ts.renote} (${i18n.ts._visibility.public})`,
icon: 'ti ti-world',
action: () => {
const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;
misskeyApi('notes/create', {
localOnly,
visibility: 'public',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
},
});
}
// Add visibility section
if (
defaultStore.state.renoteVisibilitySelection &&
!['followers', 'specified'].includes(appearNote.visibility)
) {
const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;

// renote to public
if (appearNote.visibility === 'public') {
visibilityRenoteItems.push({
text: `${i18n.ts.renote} (${i18n.ts._visibility.public})`,
icon: 'ti ti-world',
action: () => {
misskeyApi('notes/create', {
localOnly,
visibility: 'public',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
},
});
}

// renote to home
if (['home', 'public'].includes(appearNote.visibility)) {
visibilityRenoteItems.push({
text: `${i18n.ts.renote} (${i18n.ts._visibility.home})`,
icon: 'ti ti-home',
action: () => {
misskeyApi('notes/create', {
localOnly,
visibility: 'home',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
},
});
}

// renote to home
if (['home', 'public'].includes(appearNote.visibility)) {
// renote to followers
visibilityRenoteItems.push({
text: `${i18n.ts.renote} (${i18n.ts._visibility.home})`,
icon: 'ti ti-home',
text: `${i18n.ts.renote} (${i18n.ts._visibility.followers})`,
icon: 'ti ti-lock',
action: () => {
const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;
misskeyApi('notes/create', {
localOnly,
visibility: 'home',
visibility: 'followers',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
},
});
}

// renote to followers
visibilityRenoteItems.push({
text: `${i18n.ts.renote} (${i18n.ts._visibility.followers})`,
icon: 'ti ti-lock',
action: () => {
const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;
misskeyApi('notes/create', {
localOnly,
visibility: 'followers',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
},
});
}

const renoteItems = addDividersBetweenMenuSections(
Expand Down Expand Up @@ -960,49 +958,45 @@ export async function getRenoteOnly(props: {
os.toast(i18n.ts.renoted, 'renote');
});
}
}

// Add visibility section
if (
!defaultStore.state.renoteVisibilitySelection &&
defaultStore.state.forceRenoteVisibilitySelection !== 'none' &&
!['followers', 'specified'].includes(appearNote.visibility) &&
(!appearNote.channel || appearNote.channel.allowRenoteToExternal)
) {
// renote to public
if (appearNote.visibility === 'public' && defaultStore.state.forceRenoteVisibilitySelection === 'public') {
const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;
misskeyApi('notes/create', {
localOnly,
visibility: 'public',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
}
// Add visibility section
if (
!defaultStore.state.renoteVisibilitySelection &&
defaultStore.state.forceRenoteVisibilitySelection !== 'none' &&
!['followers', 'specified'].includes(appearNote.visibility)
) {
// renote to public
if (appearNote.visibility === 'public' && defaultStore.state.forceRenoteVisibilitySelection === 'public') {
misskeyApi('notes/create', {
localOnly,
visibility: 'public',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
}

// renote to home
if (['home', 'public'].includes(appearNote.visibility) && defaultStore.state.forceRenoteVisibilitySelection === 'home') {
const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;
misskeyApi('notes/create', {
localOnly,
visibility: 'home',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
}
// renote to home
if (['home', 'public'].includes(appearNote.visibility) && defaultStore.state.forceRenoteVisibilitySelection === 'home') {
misskeyApi('notes/create', {
localOnly,
visibility: 'home',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
}

// renote to followers
if (defaultStore.state.forceRenoteVisibilitySelection === 'followers') {
const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;
misskeyApi('notes/create', {
localOnly,
visibility: 'followers',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
// renote to followers
if (defaultStore.state.forceRenoteVisibilitySelection === 'followers') {
misskeyApi('notes/create', {
localOnly,
visibility: 'followers',
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted, 'renote');
});
}
}
}
}

0 comments on commit 40d6a58

Please sign in to comment.