//tips
嶋津さんからNFT×MANGAの青柳さんの情報を教えてもらった。今度スペースに参加させていただこう。NFT自体はgenerativeではないが活動自体が興味深い。確か自分が保有しているPAWのNFTも漫画化のロードマップはひいていたはず。一周回ってまたNFTブームのようなものがくるのか。観測する。
https://jackpot-arts.com/
//smart contract
Twitterの処置に移る。
Tweetの場合は削除するidが複数個あり、ユーザーがいちいちidを覚えるのは手間なのでtweetごとに削除できるようにしてあげる必要がある。
先にtweetidの追加登録から行う。
{openflagt && (
<div>
Twitter id 登録・更新
<form noValidate autoComplete="off" onSubmit={()=>console.log('tweetid')}>
<TextField
onChange={(e)=>setTid(e.target.value)}
variant="outlined"
color="secondary"
fullWidth
required
/>
<Box textAlign="center">
<Button
type="submit"
varient="contained"
onClick={()=>console.log('aa')}
>
submit
</Button>
</Box>
</form>
これはdebankidと同じ流れで良い。
async function handleOnTweetCard(e) {
e.preventDefault();
const endpoint = tid;
//const feed_url = "https://medium.com/feed/@"+uname;
// 区切り文字を「正規表現」で指定
var result = endpoint.split( '/');
var rnum=result.length;
console.log(rnum);
var fresult = result[rnum-1];
console.log(fresult);
var final=fresult.split('?');
console.log(final[0]);
setMytwt(final[0])
//ここまではtweeturlからのid抽出
//ここからはfirestorageへの登録
addDoc(colRef,{
userid:ninja[0].userid,
username:ninja[0].username,
date:Date.now(),
mail:ninja[0].mail,
tweetId:final[0]
})
router.reload()
}
無事に新たなtweetidの登録成功。
現在tweetの表示は下記のようになっているのでそちらにdeleteボタンも間に挟めるようにする。
{ninja.map((item,index) => (
<div key={index} >
{item.tweetId&&(
<TwitterTweetEmbed
tweetId={item.tweetId}
/>
)}
</div>
Muiのbuttonコンポーネントでクリック後の遷移先に引数を渡す方法を探していたら参考を発見。
https://dev.classmethod.jp/articles/handler-to-know-which-button-was-clicked-generated-by-loop-in-material-ui/
() => onClickHandler(index)のように引数を取れる形でイベント関数を作れば良さそう。
const onClickHandler = (index: number) => {
window.alert(index + 1);
};
Popの中のyesを押すと展開されるitemの中のドキュメントのdocidを取得し関数に渡す。
<Button
type="submit"
varient="contained"
onClick={()=>handleDeleteTweet(item.docid)}
>
YES
</Button>
まずは渡された関数で意図したdocidが出力されるか確認。
const handleDeleteTweet=async(id)=>{
console.log(id)
//const docRef=doc(firebaseApp,"mydata",id.toString())
//deleteDoc(docRef).then(()=>{router.reload()})
}
素晴らしい。成功した。
このままコメントアウトを外し、データベースからの削除まで持っていく。無事にデータベースから削除し、更新することができた。若干ページの更新が遅かったが許容範囲か。
同じくカードのドラッグで順番を入れ替えることができる機能も模索する。